xbl1 Posted April 9, 2008 Share Posted April 9, 2008 Hi:i am trying write some code for user register to get in my website, but i got some error massage as following, could anyone help, please.///////////////////////////////////////////email matchyour password is strong.Your passwords is strong.Your passwords is strong.Warning: Cannot modify header information - headers already sent by (output started at RegisterP2.php:15) in /home/biznisfi/public_html/RegisterP2.php on line 59//////////////////////////////////////////the following is my code:index.php <?php session_start(); //error massage for validate form $_SESSION['register_errorM_Email']=""; $_SESSION['register_errorM_Password']=""; ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"><html lang="en"> <head><title> Welcome to login </title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><head><style type="text/css">body{ padding: 0px; margin: 0px; border: 0px; background-color: white;}#container{ padding: 0px; border-top: 2px solid #1d2add; border-bottom: 2px solid #1d2add; border-left: 1px solid #3b44b5; border-right: 1px solid #3b44b5; margin-left: auto; margin-right: auto; margin-top: 5%; margin-bottom: auto; width: 330px; height: 370px;}#t1{ font-weight: bold; font-size: 18px; color: white; background-color:#3542eb;}form{ padding:0px; border: 0px; margin: auto; width: 280px;}#JoinMe{ background-color: #41ac1c; padding: 2px; border: 2px solid #94e07a; color: white; font-size: 12px; font-weight: bold;}#JoinMe:hover{ background-color: #237516; border: 2px solid #104108; padding: 2px;}td{ padding: 0; border: 0; margin: 0;}</style></head><body> <div id="container"> <form action="/RegisterP2.php" method="post"> <table> <tr><td colspan="2" id="t1">Welcome to join xxxx</td></tr> <tr><td> Email Address:</td><td><input type="text" name="email" maxlength="60"><?php if($_SESSION['register_errorM_Email']!="") echo $_SESSION['register_errorM_Email']; ?></td></tr> <tr><td>Password:</td><td><input type="password" name="pass1" maxlength="30"><?php if($_SESSION['register_errorM_Password']!="") echo $_SESSION['register_errorM_Password']; ?></td></tr> <tr><td>Confirm Password:</td><td><input type="password" name="pass2" maxlength="30"><?php if($_SESSION['register_errorM_Password']!="") echo $_SESSION['register_errorM_Password']; ?></td></tr> <tr><td colspan="2"><hr></td></tr> <tr><td> Display Name:</td><td><input type="text" name="DisplayName" maxlength="30"></td></tr> <tr><td> First Name:</td><td><input type="text" name="FirstName" maxlength="30"></td></tr> <tr><td>Last Name:</td><td><input type="text" name="LastName" maxlength="30"></td></tr> <tr><td>Country:</td><td><input type="text" name="Country" maxlength="30"></td></tr> <tr><td>State or City:</td><td><input type="text" name="StateCity" maxlength="30"></td></tr> <tr><td colspan="2"><hr></td></tr> <tr><td>Age</td><td><input type="text" name="age" maxlength="30"></td></tr> <tr><td>Gender:</td><td><input type="radio" checked="checked"name="######" value="male">Male <input type="radio" checked="checked"name="######" value="female">Female </td></tr><tr><td colspan="2" align="right"> <input type="submit" name="Join" value="Sign Up" id="JoinMe"></td></tr> </table></form></container></body></html> ////////////////////////////////////////////////RegisterP2.php <?php session_start(); //flag to check user input, 1=valid, 0=invalid $flag=1; if(isset($_POST['Join'])){ $email_pattern = '#.*@.*\..*#'; $email = $_POST['email']; if (preg_match($email_pattern, $_POST['email']) > 0) { echo " email match"; } else{ echo " email don't match"; $_SESSION['register_errorM_Email']="*"; $flag=0; } $password1 = $_POST['pass1']; $password2 = $_POST['pass2']; if ($password2==$password1) { echo "your password is strong."; } else { echo "Your password 2 is weak."; $_SESSION['register_errorM_Password']="*"; $flag=0; } if (preg_match("/^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$/", $password1)) { echo "Your passwords is strong."; } else { echo "Your password is weak."; $_SESSION['register_errorM_Password']="*"; $flag=0; } if (preg_match("/^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$/", $password2)) { echo "Your passwords is strong."; } else { echo "Your password is weak."; $_SESSION['register_errorM_Password']="*"; $flag=0; } if($flag==1) header('Location:RegisterP3.php'); }?> Link to comment Share on other sites More sharing options...
real_illusions Posted April 9, 2008 Share Posted April 9, 2008 Your outputting stuff to the browser before you using the header location function.You cant do that.See the php documentation about it - http://uk2.php.net/manual/en/function.header.php Link to comment Share on other sites More sharing options...
jeffman Posted April 9, 2008 Share Posted April 9, 2008 I got burned by that error myself the other day. The script was a bit complicated, with lots of different HTML sections and different php sections. Turned out I had a single blank space in what was an HTML section. Hard to notice if you're a dumb old human like me. Of course, the php interpreter picked it up and wouldn't let me send a header. ONE LOUSY SPACE. But that's the rules. Link to comment Share on other sites More sharing options...
justsomeguy Posted April 9, 2008 Share Posted April 9, 2008 There's more information about that warning here:http://w3schools.invisionzone.com/index.php?showtopic=12509 Link to comment Share on other sites More sharing options...
xbl1 Posted April 10, 2008 Author Share Posted April 10, 2008 Your outputting stuff to the browser before you using the header location function.You cant do that.See the php documentation about it - http://uk2.php.net/manual/en/function.header.phpyes, you are right. it works after i get rid off the out massage.Thanks a lot Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.