I'm trying to use a drop down menu to assign a value to a variable $status in the form. For some reason the last two values in this script aren't passed to the database. It seems like the variable isn't passed for status but i'm not sure why.
Here's the last piece of the form that includes the status part....
<tr><td>Status:</td>
<td>
<select name="status">
<option selected>Active</option>
<option>Alumni</option>
<option>Facutly</option>
<option>National</option>
</select></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Submit"></td></tr>
</form>
</table>
</body>
</html>
here's the php that processes everything
<?php
require_once 'db.php';
//define the variables
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$IN_number = $_POST['IN_number'];
$password = $_POST['password'];
$phone_number = $_POST['phone_number'];
$email_address = $_POST['email_address'];
$street_address = $_POST['street_address'];
$major = $_POST['major'];
$year = $_POST['year'];
$big_brother = $_POST['big_brother'];
$little_brother = $_POST['little_brother'];
$little_brother2 = $_POST['little_brother2'];
$little_brother3 = $_POST['little_brother3'];
$status = $_POST['$status'];
//Strip slashes from the user input values
$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$IN_number = stripslashes($IN_number);
$password = stripslashes($password);
$phone_number = stripslashes($phone_number);
$street_address = stripslashes($street_address);
$email_address = stripslashes($email_address);
$major = stripslashes($major);
$year = stripslashes($year);
$big_brother = stripslashes($big_brother);
$little_brother = stripslashes($little_brother);
$little_brother2 = stripslashes($little_brother2);
$little_brother3 = stripslashes($little_brother3);
$status = stripslashes($status);
/* Do some error checking on the form posted fields */
if((!$first_name) || (!$last_name) || (!$email_address) || (!$IN_number) || (!$password)){
echo 'You did not submit the following required information! <br />';
if(!$first_name){
echo "First Name is a required field. Please enter it below.<br />";
} if(!$last_name){
echo "Last Name is a required field. Please enter it below.<br />";
} if(!$email_address){
echo "Email Address is a required field. Please enter it below.<br />";
} if(!$IN_number){
echo "IN number is a required field. Please enter it below.<br />";
} if(!$password){
echo "Password is a required field. Please enter it below.<br />";
} include 'newbrother.html';
// Show the form again!
/* End the error checking and if everything is ok, we'll move on to
creating the user account */
exit(); // if the error checking has failed, we'll exit the script!
}
//check to ensure the user names aren't the same
$sql_email_check = mysql_query("SELECT email_address FROM brothers WHERE email_address='$email_address'");
$sql_username_check = mysql_query("SELECT IN_number FROM brothers WHERE IN_number='$IN_number'");
$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);
if(($email_check > 0) || ($username_check > 0)){
echo "Please fix the following errors: <br />";
if($email_check > 0){
echo "<strong>Your email address has already been used by another member in our database. Please submit a different Email address!<br />";
unset($email);
} if($username_check > 0){
echo "The IN number you have selected has already been used by another member in our database. Please enter your IN number!<br />";
unset($username);
}
include 'newbrother.html';
// Show the form again!
exit(); // exit the script so that we do not create this account!
}
//encrypt the password
$password = md5($password);
//enter the users information
$sql = mysql_query("INSERT INTO brothers (first_name, last_name, IN_number, password, phone_number,email_address, street_address, major, year, big_brother, little_brother, little_brother2, little_brother3, status)
VALUES('$first_name', '$last_name', '$IN_number','$password', '$phone_number', '$email_address', '$street_address', '$major', '$year', '$big_brother', '$little_brother', '$little_brother2', '$little_brother3', '$status')") or die (mysql_error());
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
$userid = mysql_insert_id();
}
echo $first_name;
echo $last_name;
echo $IN_number;
echo $password;
echo $phone_number;
echo $street_address;
echo $email_address;
echo $major;
echo $year;
echo $big_brother;
echo $little_brother;
echo $little_brother2;
echo $little_brother3;
echo $status;
echo $userid;
?>
so i have two questions, why isn't that working, everything else is the same format and syntax and things unless i've missed something. Also is there a better way to get the status. It eventually will be used for permissions to different areas.