I had developed the web-based survey for student.
And I need to check that each only fill in the form once time.
So I write following code to check if the student number
exist in the database or not.
if yes, don't let them to fill in again.
if no, redirect the browser to the page for them to fill in.



 @ $db = mysql_pconnect("localhost", "survey", "survey");

 if (!$db)
  echo "Error: Could not connect to database.";

 $query = mysql_query("select * from surveydb where studno = '$studno'");
 $result = mysql_num_rows($query);

 if ($result>=1)
  echo "Student Number $studno already existed in the database.<br><br>"
  ."You don't need to input again!";
  header("Location: http://www.XXX.edu/index.php";);


the code can check the student no. are exist in database or not
but the browser don't redirect to the page if student not exist
in database and display the following error code:

Warning: Cannot add header information - headers already sent
by (output started at c:\html\html\check.php:4) in
c:\html\html\check.php on line 42

I had no idea about this.
Can anyone tell me what's wrong of my code?



PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to