wonder if anyone can help. I have a register page but when someone submits the page i get the error
Warning: Cannot add header information - headers already sent by (output started at /usr/local/psa/home/vhosts/test.co.uk/httpdocs/reg/register.php:1) in /usr/local/psa/home/vhosts/test.co.uk/httpdocs/reg/register.php on line 710
i am using ob_flush but still getting the error. can anyone help?
code below
Code: Select all
<?php
<?php
ob_start();
// get database info
require('../dbinfo.php');
//get the required count info
require('../allcat.php');
//if the form has been submitted
if (isset($_POST['submit'])) {
$valid=true;
//check to see if the following fields has been filled out
if (!$_POST['username'] | !$_POST['password'] | !$_POST['confirm'] | !$_POST['contact'] |
!$_POST['location'] |!$_POST['postcode'] | !$_POST['email'] | !$_POST['area'] | !$_POST['homtel'] )
{$errmsg.="You have not filled in a required field<br>"; $valid=false;}
//check to see if the username has already been taken
$sql = "select username from members where username = '$username'";
$rs=mysql_query($sql,$db);
$numofrows =mysql_num_rows($rs);
if($numofrows !=0) {
$errmsg.=" Sorry, the username: <strong> $username </strong>
is already taken, please pick another one<br>"; $valid=false;}
//make sure that the password field and the confirm password field match up
if ($_POST['password'] != $_POST['confirm']){
$errmsg.="Passwords did not match, Please try again<br>"; $valid=false;}
//also check that the password is 5 or more words
if (strlen($_POST['password']) <= 5)
{$errmsg.="You password must be 6 letters or longer<br>"; $valid=false;}
//check to see if the phone area code is a number
if (!is_numeric($_POST['area']))
{$errmsg.="Your area code must contain numbers"; $valid=False;}
//check to see if the hoe telephone is a number
if (!is_numeric($_POST['homtel']))
{$errmsg.="Your Home Telephone number must contain numbers"; $valid=False;}
//if someone adds there mobile then check to see if it is a number
if ($_POST['mobtel']){
if (!is_numeric($_POST['mobtel']))
{$errmsg.="Your Mobile Telephone number must contain numbers"; $valid=False;}}
//check that the email submitted is a genuine email
$_POST['email'] = trim($email);
$_name = "/^[-!#$%&''*+\\.\/0-9=?A-Z^_'{|}~]+";
$_host = "([-0-9A-Z]+\.)+";
$_tlds = "([0-9A-Z]){2,4}$/i";
if (!preg_match($_name."@".$_host .$_tlds,$email) )
{$errmsg.="Invalid email address, Please try again<br>";
$valid= false;}
$checkemail = "select email from members where email = '$email'";
$em=mysql_query($checkemail,$db);
$numofrowsem =mysql_num_rows($em);
if($numofrowsem !=0) {
$errmsg.="Sorry, the email: <strong> $email </strong>
is already taken, please pick another one<br>"; $valid=false;}}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Register</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function PopUp(url) { window.open(url,"MyPopup",'height=300,width=300, scrollbars=yes'); }
//-->
</script>
<link href="../style.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('../classfied/home_f2.gif','../classfied/login_f2.gif','../classfied/reg_f2.gif','../classfied/help_f2.gif','../classfied/contact_f2.gif','../classfied/subhomebut_r1_c2_f2.gif','../classfied/subgardenbut_r1_c2_f2.gif','../classfied/subfamilybut_r1_c2_f2.gif','../classfied/subvehbut_r1_c2_f2.gif','../classfied/substudentbut_r1_c2_f2.gif')">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="90" valign="top"><img src="../classfied/title.gif" width="300" height="80"></td>
<td align="right" valign="bottom"> </td>
</tr>
<tr bordercolor="#000000">
<td width="45%" height="19" align="right" bgcolor="#000099"><font color="#FFFFFF" size="-1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Bringing
People Together</strong></font></td>
<td width="55%" align="left" valign="middle" bgcolor="#000099"> </td>
</tr>
</table>
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
<tr bgcolor="#99CCFF">
<td width="16%" height="29" align="center" valign="middle"><a href="../index.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('home','','../classfied/home_f2.gif',1)"><img src="../classfied/home.gif" name="home" width="105" height="25" border="0"></a></td>
<td width="16%" align="center"><a href="../login/login.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('login','','../classfied/login_f2.gif',1)"><img src="../classfied/login.gif" name="login" width="105" height="25" border="0"></a></td>
<td width="16%" align="center"><a href="register.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('reg','','../classfied/reg_f2.gif',1)"><img src="../classfied/reg.gif" name="reg" width="105" height="25" border="0"></a></td>
<td width="16%" align="center"><a href="javascript:PopUp('../help/help.htm')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('help','','../classfied/help_f2.gif',1)"><img src="../classfied/help.gif" name="help" width="105" height="25" border="0"></a></td>
<td width="16%" align="center"><a href="../contact/contact.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('contact','','../classfied/contact_f2.gif',1)"><img src="../classfied/contact.gif" name="contact" width="105" height="25" border="0"></a></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr bgcolor="#000099">
<td width="50%" height="29" align="right" valign="middle"></td>
<td width="50%" valign="top"></td>
</tr>
</table>
<table width="100%" height="418" border="0">
<tr>
<td width="1%">
<td width="98%" valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="1" bordercolor="#666666">
<tr>
<td width="17%" height="282" align="center" valign="top" bgcolor="#FFFFFF"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Category
</strong> </font>
<?php include_once('../includes/cat2.php'); ?>
<font size="-1" >
<?php include_once('../includes/info2.php'); ?>
<br>
<?php include_once('../includes/jobs3.php') ; ?>
<strong>Search</strong></font>
<table width="100%" border="1" cellpadding="1" cellspacing="1" bordercolor="#33CC99">
<form name="find" action="../adverts/searchall.php" method="post">
<tr>
<td align="center" bgcolor="#99FFCC"> <input type="text" size="20" name="find">
</td>
</tr>
<tr>
<td align="center" bgcolor="#99FFCC"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="36%" height="17">
<input type="radio" name="searchtip" value="advert" checked></td>
<td width="64%">Category</td>
</tr>
<tr>
<td><input type="radio" name="searchtip" value="event"></td>
<td>Notice Board</td>
</tr>
<tr>
<td><input type="radio" name="searchtip" value="job"></td>
<td>Jobs</td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" bgcolor="#99FFCC"><input name="submit" type="submit" value="Submit" size="20"></td>
</tr>
</form>
</table>
<td width="4%" valign="top"></td>
<td width="79%" valign="top"><font size="-1" face="Arial, Helvetica, sans-serif"><strong>Register<br><br>
</strong></font></p>
<p><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Registration
at is easy to do and absolutely free</font></p>
<p><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Please
enter your details below<br><br><br><font color="#FF0000"><b><?php if ($valid!=true)
{echo ( $errmsg.$form);} else {
$_POST['username']= stripslashes($username);
//add the form information in the database
$insert= "insert into members (username,password,member_type,contact,location,email,postcode,area,home_tel,mobile_tel,
datejoined,lastlog,valid) values ('$username', '$password','personal','$contact', '$location', '$email' ,'$postcode', '$area','$homtel',
'$mobtel', now(), 'never' ,0)";
mysql_query($insert,$db) or die("Cannot query the database.<br>" . mysql_error());
//send an email to the user, with the validation information
$id="select member_id, username from members where username = '$username'";
$rs=mysql_query($id,$db);
while ($r = mysql_fetch_array($rs))
{
$member_id = $r["member_id"];
}
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: info@test.co.uk <info@test.co.uk>\n";
$subject = "Member Details";
$body ="<html><head></head><body>Thank you $username for joining AdHudd.
Your username is $username and your password is $password.
Please keep these details safe
<br><br><br>To validate you account please
<a href='http://www.test.co.uk/reg/validate.php?member_id=$member_id'>
click here</a></body></html>";
mail($email, $subject,$body,$headers);
//close the database
mysql_close($db);
//go to this page
header("location: complete.php");
} ?>
</b>
</font></p>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="20%">Username:</td>
<td width="63%"><form name="register" action="<?php $PHP_SELF ?>" method="post">
<input type="text" name="username" value="<?php echo $_POST['username'] ?>"size="20" maxlength="20">
</td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" maxlength="20"><span class="small"><font color="#FF0000">(Your password
needs to be 6 letters or more)</font></span></td>
</tr>
<tr>
<td>Confirm Password:</td>
<td><input type="password" name="confirm"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Contact Name:</td>
<td><input type="text" name="contact" value="<?php echo $_POST['contact'] ?>" size="20" maxlength="20"><span class="small"><font color="#FF0000">(When people contact you, this is what they will use)</font></span></td>
</tr>
<tr>
<td>Location:</td>
<td><input type="text" name="location" value="<?php echo $_POST['location'] ?>" maxlength="20"><span class="small"><font color="#FF0000">(This can be your village or town)</font></span></td>
</tr>
<tr>
<td>Address Postcode</td>
<td><input type="text" name="postcode" value="<?php echo $_POST['postcode'] ?>" size="10" maxlength="10"><span class="small"><font color="#FF0000">(This
will <b>not</b> be displayed
with your adverts, this is for security reasons only)</font></span></td>
</tr>
<tr>
<td></td>
<td> </td>
</tr>
<tr>
<td>Email: </td>
<td><input type="text" name="email" value="<?php echo $_POST['email'] ?>" size="30" maxlength="40"><span class="small"><font color="#FF0000">
(You will need a valid email to activate your account)</font></span></td>
</tr>
<td>Area phone code: </td>
<td><input type="text" name="area" value="<?php echo $_POST['area'] ?>" size="10" maxlength="6"><span class="small"><font color="#FF0000">
</font></span></td>
</tr>
<tr>
<td>Home Telephone :</td>
<td><input type="text" name="homtel" value="<?php echo $_POST['homtel'] ?>"><span class="small"><font color="#FF0000">
(You can choose whether you want your number displayed on your advert when adding an advert)</td>
</tr>
<tr>
<td>Mobile Telephone :</td>
<td><input type="text" name="mobtel" value="<?php echo $_POST['mobtel'] ?>"><font color="#FF0000"><span class="small">(Optional)</span></font></td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="submit" value="Submit">
</form><br>
</td>
</tr>
</table>
</td>
</tr>
</table></tr>
</table>
</body>
</html>
<?php
ob_end_flush()
?>
?>