Leggo Posted September 24, 2010 Share Posted September 24, 2010 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? Link to comment https://forums.phpfreaks.com/topic/214325-checking-radio-buttons/ Share on other sites More sharing options...
milesap Posted September 24, 2010 Share Posted September 24, 2010 You have: name"gender" Change to: name="gender" Link to comment https://forums.phpfreaks.com/topic/214325-checking-radio-buttons/#findComment-1115309 Share on other sites More sharing options...
Leggo Posted September 24, 2010 Author Share Posted September 24, 2010 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 Link to comment https://forums.phpfreaks.com/topic/214325-checking-radio-buttons/#findComment-1115328 Share on other sites More sharing options...
milesap Posted September 24, 2010 Share Posted September 24, 2010 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 happens to me to sometimes, take more breaks or else nothing makes sense lol Link to comment https://forums.phpfreaks.com/topic/214325-checking-radio-buttons/#findComment-1115331 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.