dominic600 Posted August 25, 2011 Share Posted August 25, 2011 Ok so for some reasons on my register and edit profile page when i hit submit it says that i have not filled in all the info i need.. Even after i fill all of them in.. but heres the code for the register form.. <?php require("top.php"); ?> <div id='homeright'> <?php echo "<font size='6'>Sign up</font>"; echo "<hr width='75%' align='left'/>"; $form = "<form action='index.php' method='post'> <table cellspacing='5px'> <tr> <td>First Name:</td> <td class='register'><input type='text' name='firstname' class='textbox' size='35'></td> </tr> <tr> <td>Last Name:</td> <td><input type='text' name='lastname' class='textbox' size='35'></td> </tr> <tr> <td>Username:</td> <td><input type='text' name='username' class='textbox' size='35'></td> </tr> <tr> <td>E-mail:</td> <td><input type='text' name='email' class='textbox' size='35'></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password' class='textbox' size='35'></td> </tr> <tr> <td>Confirm Password:</td> <td><input type='password' name='repassword' class='textbox' size='35'></td> </tr> <tr> <td></td> <td><input type='submit' name='submitbtn' value='Register' class='button'></td> </tr> </table> </form>"; if ($_POST['submitbtn']){ $firstname = fixtext($_POST['firstname']); $lastname = fixtext($_POST['lastname']); $username = fixtext($_POST['username']); $email = fixtext($_POST['email']); $password = fixtext($_POST['password']); $repassword = fixtext($_POST['repassword']); $website = fixtext($_POST['website']); $youtube = fixtext($_POST['youtube']); $bio = fixtext($_POST['bio']); $name = $_FILES['avatar'] ['name']; $type = $_FILES['avatar'] ['type']; $size = $_FILES['avatar'] ['size']; $tmpname = $_FILES['avatar']['tmpname']; $ext = substr($name, strrpos($name, '.')); if ($firstname && $lastname && $username && $email && $password && $repassword){ if ($password == $repassword){ if (strstr($email, "@") && strstr($email, ".") && strlen($email) >= 6){ require("scripts/connect.php"); /*$query = mysql_query("SELECT * FROM users WHERE username='$username' ");*/ $query=mysql_query("SELECT * FROM users WHERE username='$username' ") or die(mysql_error()); $numrows = mysql_num_rows($query); if ($numrows == 0){ /*$query=mysql_query("SELECT * FROM users WHERE email='$email' ");*/ $query=mysql_query("SELECT * FROM users WHERE email='$email' ") or die(mysql_error()); $numrows=mysql_num_rows($query); if ($numrows == 0){ $pass = md5(md5($password)); $date = date("F d, Y"); if($name){ move_uploaded_file($tmpname, "avatars/$username.$ext"); $avatar = "$username.$ext"; } else $avatar = "/avatars/default_avatar.png"; $code = substr (md5(rand(11111111111, 999999999999999)), 2, 25); mysql_query("INSERT INTO users (`first_name`,`last_name`,`username`,`email`,`password`,`avatar`,`bio`,`website`,`youtube`,`last_login`,`active`,`code`,`locked`,`date`) VALUES ( '$firstname', '$lastname', '$username', '$email', '$pass', '$avatar', '$bio', '$website', '$youtube', '', '0', '$code', '0', '$date')"); /*mysql_query("INSERT INTO users (Field, Type) VALUES ('', '$firstname', '$lastname', '$username', '$email', 'pass', '$avatar', '$bio', '$website', '$youtube', '', '0', '$code', '0', '$date')");*/ $webmaster = "Admin@trucksite.com"; $subject = "Activate Your Account!"; $headers = "From: Admin <$webmaster>"; $message = "Hello $firstname.\n\nWelcome to trucksite below is a link for you to activate your account!.\n http://tprofiletesting.net23.net/activate.php?code=$code"; mail($email, $subject, $message, $headers); echo "Your activation email has been sent to <b>$email</b>."; } else echo "That email is currently in use."; } else echo "That username is currently in use."; } else echo "You did not enter a vaild email."; } else echo "Your passwords did not match."; } else echo"You did not fill in all the required fields."; } echo "$form"; ?> </div> <div id='homeleft'> <center><font size='6'>Create! Showoff! Educate!</font></center> <hr /> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/245653-not-putting-in-all-info/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 25, 2011 Share Posted August 25, 2011 When validating user supplied information, you should supply as much information as possible as to why the information did not validate. You should individually test each value and output a specific message for each validation problem found. Quote Link to comment https://forums.phpfreaks.com/topic/245653-not-putting-in-all-info/#findComment-1261679 Share on other sites More sharing options...
dominic600 Posted August 25, 2011 Author Share Posted August 25, 2011 how would i do that? Just make an if statement for each value? Quote Link to comment https://forums.phpfreaks.com/topic/245653-not-putting-in-all-info/#findComment-1261687 Share on other sites More sharing options...
PFMaBiSmAd Posted August 25, 2011 Share Posted August 25, 2011 The recommend way of validating all the form fields individually is to use an array to hold the error message(s). You run all the possible validation tests and then at the end you simply test if there were any errors or not. See the following post for some example code - http://www.phpfreaks.com/forums/index.php?topic=340943.msg1607829#msg1607829 Quote Link to comment https://forums.phpfreaks.com/topic/245653-not-putting-in-all-info/#findComment-1261698 Share on other sites More sharing options...
dominic600 Posted August 25, 2011 Author Share Posted August 25, 2011 but why would i do this? like i know im filling in all the boxes and i know that only certin ones are required but idk why its not picking up on the info i put in .. on either form. could it be becasue i copied and pasted the form from one page to antother? Quote Link to comment https://forums.phpfreaks.com/topic/245653-not-putting-in-all-info/#findComment-1261890 Share on other sites More sharing options...
PFMaBiSmAd Posted August 25, 2011 Share Posted August 25, 2011 but why would i do this? So that your code would tell you which field(s) are failing, as that would point to where to look to find the cause of the problem. Right now, you don't even know if it is just one field or all of the fields that are not working. Quote Link to comment https://forums.phpfreaks.com/topic/245653-not-putting-in-all-info/#findComment-1261900 Share on other sites More sharing options...
dominic600 Posted August 26, 2011 Author Share Posted August 26, 2011 yeah, but idk what to do to do that thing to show the errors.. Cause i just get confused when i look at that link you pointed me too. Quote Link to comment https://forums.phpfreaks.com/topic/245653-not-putting-in-all-info/#findComment-1262086 Share on other sites More sharing options...
dominic600 Posted August 27, 2011 Author Share Posted August 27, 2011 okay well i did that and well it gave me an error: Fatal error: Call to undefined function fixtext() in /home/truckste/public_html/index.php on line 61 im not sure why i would get en error on that. Quote Link to comment https://forums.phpfreaks.com/topic/245653-not-putting-in-all-info/#findComment-1262530 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.