thefortrees Posted June 1, 2007 Share Posted June 1, 2007 Hi all - I have created an online survey, and the script I am having problems with is a simple entry page where you enter a code given to you that will be stored in the database with each question you answer to track who answered it. The script never enters the second if statement, so you can never get to index.php. Any ideas? $dbhost = '***; $dbuser = '***'; $dbpass = '***'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'vecsurvey'; mysql_select_db($dbname); //Passcode to log on to survey that is unique to each company. $passcode = $_GET['passcode']; $query = "SELECT * FROM clients WHERE passcode = '$passcode';"; $result = mysql_query($query); if ( mysql_num_rows($result) == 0){ header('Location: ../login.html'); } if ( mysql_num_rows($result) == 1 ){ //surveyID cookie will be used in the answers table to tie each answer with a specific //company. Expires after 2 hours. setcookie("passcode", $passcode, time()+7200); header('Location: ../index.php'); } Quote Link to comment https://forums.phpfreaks.com/topic/53888-script-never-getting-to-if-statement/ Share on other sites More sharing options...
penguin0 Posted June 1, 2007 Share Posted June 1, 2007 Where is passcode coming from? Usually if I have a problem, the variable is not posting over. Quote Link to comment https://forums.phpfreaks.com/topic/53888-script-never-getting-to-if-statement/#findComment-266437 Share on other sites More sharing options...
thefortrees Posted June 1, 2007 Author Share Posted June 1, 2007 variable posts over - i echoed it to make sure of that. one weird thing - in my html form method is post but $_POST['passcode'] doesn't work. however, $_GET['passcode'] does (posting the variable to the script i mean) Quote Link to comment https://forums.phpfreaks.com/topic/53888-script-never-getting-to-if-statement/#findComment-266440 Share on other sites More sharing options...
AndyB Posted June 1, 2007 Share Posted June 1, 2007 one weird thing - in my html form method is post but $_POST['passcode'] doesn't work. however, $_GET['passcode'] does (posting the variable to the script i mean) I don't believe that for a moment. Are you 100% certain that you have the right versions of each file on the server where you think they are? Quote Link to comment https://forums.phpfreaks.com/topic/53888-script-never-getting-to-if-statement/#findComment-266539 Share on other sites More sharing options...
per1os Posted June 1, 2007 Share Posted June 1, 2007 I am with Andy, are you sure your form is not setup like so: <form method="POST" action="script.php?passcode=1"> <input type="hidden" name="test" value="yes" /> <input type="submit" name="submit" value="yes" /> </form> If so, than rightfully passcode is part of the get data, and submit/test is post. reason being is you are passing passcode just like you would in a get string. However if it was done this way passcode would be in the post. <form method="POST" action="script.php"> <input type="hidden" name="test" value="yes" /> <input type="hidden" name="passcode" value="1" /> <input type="submit" name="submit" value="yes" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/53888-script-never-getting-to-if-statement/#findComment-266541 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.