Anxious Posted April 7, 2009 Share Posted April 7, 2009 I've seen a post of this before, I'm having similar problems, using the same format. Location and Gender error fields are getting mixed up, aswell as not getting a value. If I removed the gender, so it's back to how it was before. It worked. Can somebody assist me. I use, Register.php, Process.php, Database.php, Session.php. There big code files. Hope you can assist, Thanks. Anxious Quote Link to comment https://forums.phpfreaks.com/topic/152986-error-field-problems/ Share on other sites More sharing options...
mrMarcus Posted April 7, 2009 Share Posted April 7, 2009 I've seen a post of this before, I'm having similar problems, using the same format. Location and Gender error fields are getting mixed up, aswell as not getting a value. If I removed the gender, so it's back to how it was before. It worked. Can somebody assist me. I use, Register.php, Process.php, Database.php, Session.php. There big code files. Hope you can assist, Thanks. Anxious sorry, this isn't the Psychic PHPFreaks network, it's just the PHPFreaks network .. we actually need to see code to troubleshoot it. just mentioning the names of your scripts doesn't spark any ideas. Quote Link to comment https://forums.phpfreaks.com/topic/152986-error-field-problems/#findComment-803453 Share on other sites More sharing options...
Anxious Posted April 7, 2009 Author Share Posted April 7, 2009 Yeah, I guess showing the PHP would be a good idea, What would be best to look at first? I'd have to post alot of of the PHP. Quote Link to comment https://forums.phpfreaks.com/topic/152986-error-field-problems/#findComment-803457 Share on other sites More sharing options...
Fruct0se Posted April 7, 2009 Share Posted April 7, 2009 Back again I see, lets take a look at session and process Quote Link to comment https://forums.phpfreaks.com/topic/152986-error-field-problems/#findComment-803461 Share on other sites More sharing options...
Anxious Posted April 7, 2009 Author Share Posted April 7, 2009 <?php function register($subuser, $subpass, $subemail, $sublocation){ global $database, $form, $mailer; //The database, form and mailer object /* Username error checking */ $field = "user"; //Use field name for username if(!$subuser || strlen($subuser = trim($subuser)) == 0){ $form->setError($field, "* Username not entered"); } else{ /* Spruce up username, check length */ $subuser = stripslashes($subuser); if(strlen($subuser) < 5){ $form->setError($field, "* Username below 5 characters"); } else if(strlen($subuser) > 30){ $form->setError($field, "* Username above 30 characters"); } /* Check if username is not alphanumeric */ else if(!eregi("^([0-9a-z])+$", $subuser)){ $form->setError($field, "* Username not alphanumeric"); } /* Check if username is reserved */ else if(strcasecmp($subuser, GUEST_NAME) == 0){ $form->setError($field, "* Username reserved word"); } /* Check if username is already in use */ else if($database->usernameTaken($subuser)){ $form->setError($field, "* Username already in use"); } /* Check if username is banned */ else if($database->usernameBanned($subuser)){ $form->setError($field, "* Username banned"); } } /* Password error checking */ $field = "pass"; //Use field name for password if(!$subpass){ $form->setError($field, "* Password not entered"); } else{ /* Spruce up password and check length*/ $subpass = stripslashes($subpass); if(strlen($subpass) < 4){ $form->setError($field, "* Password too short"); } /* Check if password is not alphanumeric */ else if(!eregi("^([0-9a-z])+$", ($subpass = trim($subpass)))){ $form->setError($field, "* Password not alphanumeric"); } } /* Email error checking */ $field = "email"; //Use field name for email if(!$subemail || strlen($subemail = trim($subemail)) == 0){ $form->setError($field, "* Email not entered"); } else{ /* Check if valid email address */ $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*" ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*" ."\.([a-z]{2,}){1}$"; if(!eregi($regex,$subemail)){ $form->setError($field, "* Email invalid"); $subemail = stripslashes($subemail); } else if($database->emailTaken($subemail)){ $form->setError($field, "* Email already in use"); } } /* Gender error checking */ $field = "gender"; //Use field name for gender if(!$subgender || strlen($subgender = trim($subgender)) == 0){ $form->setError($field, "* Gender not selected"); } /* Location error checking */ $field = "location"; //Use field name for location if(!$sublocation || strlen($sublocation = trim($sublocation)) == 0){ $form->setError($field, "* Location not selected"); } /* Errors exist, have user correct them */ if($form->num_errors > 0){ return 1; //Errors with form } /* No errors, add the new account to the */ else{ if($database->addNewUser($subuser, md5($subpass), $subemail, $sublocation)){ if(EMAIL_WELCOME){ $mailer->sendWelcome($subuser,$subemail,$subpass,$sublocation); } return 0; //New user added succesfully }else{ return 2; //Registration attempt failed } } } ?> <?php function procRegister(){ global $session, $form; /* Convert username to all lowercase (by option) */ if(ALL_LOWERCASE){ $_POST['user'] = strtolower($_POST['user']); } /* Registration attempt */ $retval = $session->register($_POST['user'], $_POST['pass'], $_POST['email'], $_POST['gender'], $_POST['location']); /* Registration Successful */ if($retval == 0){ $_SESSION['reguname'] = $_POST['user']; $_SESSION['regsuccess'] = true; header("Location: ".$session->referrer); } /* Error found with form */ else if($retval == 1){ $_SESSION['value_array'] = $_POST; $_SESSION['error_array'] = $form->getErrorArray(); header("Location: ".$session->referrer); } /* Registration attempt failed */ else if($retval == 2){ $_SESSION['reguname'] = $_POST['user']; $_SESSION['regsuccess'] = false; header("Location: ".$session->referrer); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/152986-error-field-problems/#findComment-803469 Share on other sites More sharing options...
Fruct0se Posted April 7, 2009 Share Posted April 7, 2009 change: function register($subuser, $subpass, $subemail, $sublocation){ to: function register($subuser, $subpass, $subemail, $subgender, $sublocation){ then if($database->addNewUser($subuser, md5($subpass), $subemail, $sublocation)){ to if($database->addNewUser($subuser, md5($subpass), $subemail, $subgender, $sublocation)){ And now I need to see your database.php file to finish Quote Link to comment https://forums.phpfreaks.com/topic/152986-error-field-problems/#findComment-803491 Share on other sites More sharing options...
Anxious Posted April 7, 2009 Author Share Posted April 7, 2009 <?php function addNewUser($username, $password, $email, $gender, $location){ $time = date("F j, Y, g:i"); /* If admin sign up, give admin user level */ if(strcasecmp($username, ADMIN_NAME) == 0){ $ulevel = ADMIN_LEVEL; }else{ $ulevel = USER_LEVEL; } $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', $ulevel, '$email', '$time', '$gender', '$location')"; return mysql_query($q, $this->connection); } ?> I took ID on the database, so its always last, so I wont need to include the other bit you added in. Quote Link to comment https://forums.phpfreaks.com/topic/152986-error-field-problems/#findComment-803515 Share on other sites More sharing options...
Fruct0se Posted April 7, 2009 Share Posted April 7, 2009 Well it looks like it should work now as long as you changed the code I showed you in the post earlier. Quote Link to comment https://forums.phpfreaks.com/topic/152986-error-field-problems/#findComment-803518 Share on other sites More sharing options...
Anxious Posted April 7, 2009 Author Share Posted April 7, 2009 Yeah thanks, another 2 bits I cant believe I missed. Quote Link to comment https://forums.phpfreaks.com/topic/152986-error-field-problems/#findComment-803520 Share on other sites More sharing options...
Fruct0se Posted April 7, 2009 Share Posted April 7, 2009 No problem. Quote Link to comment https://forums.phpfreaks.com/topic/152986-error-field-problems/#findComment-803528 Share on other sites More sharing options...
Anxious Posted April 7, 2009 Author Share Posted April 7, 2009 Last thing is, you know if you submit the form with missing values, it clears the form, well the drop down menu's atleast. Is there anything to stop that? Quote Link to comment https://forums.phpfreaks.com/topic/152986-error-field-problems/#findComment-803530 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.