Wonder if anyone can help, trying to do a register form, once a user submits the form, i have a header location , but I am still get the header error message. I have ob start and ob flush end
code below
Code: Select all
<?php
ob_start();
require_once('../dninfo.php');
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['location'] | !$_POST['email'] )
{$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;}
//check that the email submitted is a genuine email
if ($_POST['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;}}}
?>
?>Just normal hmtl code here
Code: Select all
<html>
<head>
<title>List</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];}}
}
//-->
</script>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
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];}
}
//-->
</script>
<link href="../image/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {
color: #FFFFFF;
font-size: 10px;
}
.style4 {font-size: 12px}
body,td,th {
font-size: 10px;
color: #FFFFFF;
}
-->
</style></head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('../image/Sidebar/sidepanel_r2_c2_f2.gif','../image/Sidebar/sidepanel_r4_c2_f2.gif','../image/Sidebar/sidepanel_r6_c2_f2.gif','../image/Sidebar/sidepanel_r8_c2_f2.gif','../image/Sidebar/sidepanel_r10_c2_f2.gif','../image/Sidebar/000456_r6_c3_f2.gif','../image/Sidebar/sidepanel_r14_c2_f2.gif','../image/Sidebar/sidepanel_r16_c2_f2.gif','../image/Sidebar/sidepanel_r18_c2_f2.gif','../image/Sidebar/sidepanel_r20_c2_f2.gif')">
<div align="center">
<table width="800" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td nowrap><img src="../image/Title1.jpg" width="800" height="82"></td>
</tr>
<tr>
<td nowrap><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr bgcolor="#6699FF">
<td bgcolor="#0066cc">&nbsp;</td>
<td align="center" bgcolor="#0066cc">&nbsp;</td>
<td bgcolor="#0066cc">&nbsp;</td>
</tr>
</table></td>
</tr>
</table>
<div align="center"></div>
<table width="800" height="800" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="102" height="800" valign="top" bgcolor="3366cc" >
<table border="0" cellpadding="0" cellspacing="0" width="1">
<? include_once('../include/sidepanel2.php');?></td>
<td width="551" align="center" valign="top" bgcolor="3366cc">
<table width="100%" height="321" border="0" align="center">
<tr>
<td height="21" bgcolor="3366cc" >
<a href="../index.php"><u><font size="-1"><strong><span class="style4">Home
/</a><font color="#FFFFFF"> Anime list
/</u>
</td>
</tr>
<tr>
<td height="21" valign="top" bgcolor="3366cc" >
<table border="0" cellpadding="2" cellspacing="2">Code: Select all
<?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,website,location,email,
datejoined,lastlog,valid) values ('$username', '$password', '$website','$location', '$email'
, 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: Jamrop Database <jamrop@database.co.uk>\n";
$subject = "Member Details";
$body ="<html><head></head><body>Welcome $username to Jamrops Anime Database.
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");
} ?>header infomarion above
Code: Select all
</b>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
</table>
<p><br>
<br>
</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"></td>
</tr>
<tr>
<td>Confirm Password:</td>
<td><input type="password" name="confirm"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<td>Location:</td>
<td><input type="text" name="location" value="<?php echo $_POSTї'location'] ?>" maxlength="20"></td>
</tr>
<tr>
<td></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Email: </td>
<td><input type="text" name="email" value="<?php echo $_POSTї'email'] ?>" size="30" maxlength="40"><span class="sytle1">
(You will need a valid email to activate your account)</td>
</tr>
<tr>
<td>Website: </td>
<td><input type="text" name="website" value="<?php echo $_POSTї'website'] ?>" size="40" maxlength="45">Optional
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" name="submit" value="Submit">
</form>
<td width="102" align="left" valign="top" bgcolor="#3366cc">
<p class="style1">List anime shows all the anime in my list. Click on the info button to get more details e.g. what category it is, information about fansub, and reviews of the title</p>
<p class="style1">Reviews shows the top 10, newly added reviews to the database </p> <p class="style1">Register to add reviews to my list </p>
<table width="100%" border="0" bgcolor="#6699FF">
</table> </td>
</tr>
</table>
</div>
</body>
</html>flush is here
Code: Select all
<?php
ob_end_flush()
?>