This is the drop down list of security questions:

<form action="ddlprocess.php" method="post">
	<select name="security1">
	<option value="placeOfBirth">What city were you born in?</option>
	<option value="childhoodFriend">Who was your childhood best friend?</option>
	<option value="mothersMaiden">What is your mother's maiden name?</option>
	<option value="mothersMiddle">What is your mother's middle name?</option>
	<option value="fathersMiddle">What is your father's middle name?</option>
	</select><br />
	<input type="submit" value="Register"></input>
		
</form>

This is the page to process it (ddlprocess.php):

<?php 

if ($_POST['security1'])

{
		// db connection established
				
	$sq1 = ($_POST['security1']) or die("evil bug " . mysql_error());		
			
		echo $security1 or die("cannot find security1 ");

}
?>

When php echoes security1, it gives me the number 1 instead of the value of the drop down list.

I have scoured the web and search engines trying to find someone with a similar problem or to learn additional information on how $_POST works, and i have learned nothing but that this should be working the way it is!

Heeellllppp Meeeeee Pleeaasssee!!!:(

Use:

echo $_POST['security1'];

and get rid of the or die() statement as that is not how its suppose to be used.

Don't use:

if ($_POST['security1']) {

You need to use isset() otherwise you will get errors.

When I use "isset" I get errors. I fixed the other, but it still gives me the same response.

<?php

if ( isset( $_POST['security1'] ) ) {
	echo $_POST['security1'];
}
else {
	echo 'Security1 not set';
}

?>

That should work. There is no reason why it shouldn't.

You can also put echo '<pre>' . print_r( $_POST,true ) . '</pre>'; to check the values of post.

I still get the same response. Number 1 and not POST value.

I dont know if you are still having this problem or not, but I was having the same exact problem. To solve it I copied the POST array to an alternate array at the very start of the script. I then used the alternate array instead of POST. For what ever reason POST is changed by the time I called it later in my script.

Verified by print_r($_POST) at start and then again print_r($_POST) at time of calling.

Corrected by placing POST in alternate array:

if($action == "register")
{
    $user_name  = $_POST['USER_NAME'];
    $password1  = isset($_POST['PASSWORD1']);
    $password2  = isset($_POST['PASSWORD2']);
    $email      = isset($_POST['EMAIL']);
    $first_name = isset($_POST['FIRST_NAME']);
    $last_name  = isset($_POST['LAST_NAME']);
    $phone      = isset($_POST['PHONE']);

    $registerData = array('USER_NAME'=>$user_name,'PASSWORD1'=>$password1, 'PASSWORD2'=>$password2, 'EMAIL'=>$email,'FIRST_NAME'=>$first_name, 'LAST_NAME'=>$last_name, 'PHONE'=>$phone);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.