Jump to content

script never getting to if statement!!


thefortrees

Recommended Posts

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');

}

Link to comment
https://forums.phpfreaks.com/topic/53888-script-never-getting-to-if-statement/
Share on other sites

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?

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.