i am making a website in php all on one page. here is my script
<a href='?goto=register'>register</a>
<?php
if ($_GET['goto']=='register'){
?>
<form name='register' method='POST' action='?goto=reg'>
<table style='margin-left: auto; margin-right: auto; color: white; font-weight: bold;'>
<tr><td style='text-align:center;'>First Name: <input type='text' name='first'></td></tr>
<tr><td style='text-align:center;'>Last Name: <input type='text' name='last'></td></tr>
<tr><td style='text-align:center;'>Email: <input type='text' name='email'></td></tr>
<tr><td style='text-align:center;'>Password: <input type='text' name='pass'></td></tr>
<tr><td style='text-align:center;'><INPUT TYPE='SUBMIT' value='Register' name='submit' id='submit'></td></tr>
</table>
</form>
<?php
}
else if($_GET['goto']=='reg'){
include "dbconnect.php";
$fname=$_POST['first'];
$lname=$_POST['last'];
$email=$_POST['email'];
$email=mysql_real_escape_string($email);
$password=$_POST['pass'];
$password=md5($password);
$date=date("y-m-d");
$query="INSERT INTO members (name, lname, email, password, date) VALUES ('$fname','$lname','$email','$password','$date')";
$result=mysql_query($query);
if ($result){
header("location:?goto=thankyou");
}else{
echo"<font color='white'>nope</font>";
}
}
but i keep getting the error "cannot modify header information - header already sent"