hahahahahhah! oh my god! its always something simple. thats what you get for working 10 hours straight!! GAH!! I was going crazy and I was like, i need some new eyes on this... Thank you so much! haha
I have been at this for far too long and really need some help. I am just trying to check if a radio button has been set or not when someone hits submit. My validation looks something like this:
function protect($string){
$string = trim(strip_tags(addslashes($string)));
return $string;
}
if(isset($_POST['submit'])){
//protect and then add the posted data to variables
$username = protect($_POST['username']);
$password = protect($_POST['password']);
$passconf = protect($_POST['passconf']);
$email = protect($_POST['email']);
$fname = protect($_POST['fname']);
$lname = protect($_POST['lname']);
$address = protect($_POST['address']);
$phone = protect($_POST['phone']);
$gender = $_POST['gender'];
if(!$username || !$password || !$passconf || !$email || !$fname || !$lname || !$address || !$phone || !isset($gender)){
echo "<p>Please enter all required fields</p>";
}else{
and my form for the radio button is like this...
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<h1>General</h1>
<p>
<label for="username">Username: </label>
<input type="text" name="username" value="<?=$_POST['username'] ?>" />
</p>
<p>
<label for="password">Password: </label>
<input type="password" name="password" value="<?=$_POST['password'] ?>" />
</p>
<p>
<label for="passconf">Confirm Password: </label>
<input type="password" name="passconf" value="<?=$_POST['passconf'] ?>" />
</p>
<p>
<label for="email">Email: </label>
<input type="text" name="email" value="<?=$_POST['email'] ?>" size="25"/>
</p>
<p>
<label for="fname">First Name: </label>
<input type="text" name="fname" value="<?=$_POST['fname'] ?>" size="25"/>
</p>
<p>
<label for="lname">Last Name: </label>
<input type="text" name="lname" value="<?=$_POST['lname'] ?>" size="25"/>
</p>
<p>
<label for="address">Home Address: </label>
<input type="text" name="address" value="<?=$_POST['address'] ?>" />
</p>
<p>
<label for="phone">Primary Phone Number: </label>
<input type="text" name="phone" value="<?=$_POST['phone'] ?>" size="10" />
</p>
<p>
<label for="genders">Gender: </label>
<input type="radio" name"gender" value="male" /> Male
<input type="radio" name"gender" value="female" /> Female
</p>
everytime i hit submit i get this error:
"Notice: Undefined index: gender in C:\wamp\www\LoginRegistration\register.php on line 37
Please enter all required fields"
can anyone help me please?
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.