Jump to content

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.