9homie Posted August 20, 2008 Share Posted August 20, 2008 Hello. I have got this form for the registration (I know it is a table, I am going to change it soon): <form action="process.php" method="POST"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></td></tr> <tr><td>Email:</td><td><input type="text" name="email" maxlength="50" value="<? echo $form->value("email"); ?>"></td><td><? echo $form->error("email"); ?></td></tr> <tr><td colspan="2" align="right"> <input type="hidden" name="subjoin" value="1"> <input type="submit" value="Join!"></td></tr> <tr><td colspan="2" align="left"><a href="index.html">Back Home</a></td></tr> </table> </form> and I also have this to make the form work: /** * register - Gets called when the user has just submitted the * registration form. Determines if there were any errors with * the entry fields, if so, it records the errors and returns * 1. If no errors were found, it registers the new user and * returns 0. Returns 2 if registration failed. */ function register($subuser, $subpass, $subemail){ 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"); } /** * Note: I trimmed the password only after I checked the length * because if you fill the password field up with spaces * it looks like a lot more characters than 4, so it looks * kind of stupid to report "password too short". */ } /* 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); } /* Errors exist, have user correct them */ if($form->num_errors > 0){ return 1; //Errors with form } /* No errors, add the new account to the database */ else{ if($database->addNewUser($subuser, md5($subpass), $subemail)){ if(EMAIL_WELCOME){ $mailer->sendWelcome($subuser,$subemail,$subpass); } return 0; //New user added succesfully }else{ return 2; //Registration attempt failed } } } From that can anyone help me to put in a confirm password and a confirm email fields? Thank You 9homie Quote Link to comment https://forums.phpfreaks.com/topic/120570-confirm-password-and-confirm-email-for-loginregistration-please-help/ Share on other sites More sharing options...
DeanWhitehouse Posted August 20, 2008 Share Posted August 20, 2008 can you atleast try , instead of expecting us just to add it for you Quote Link to comment https://forums.phpfreaks.com/topic/120570-confirm-password-and-confirm-email-for-loginregistration-please-help/#findComment-621302 Share on other sites More sharing options...
bluebutterflyofyourmind Posted August 20, 2008 Share Posted August 20, 2008 do you want to confirm by just making sure that they are the same? if so you can easily do that with javascript before the form is submitted Quote Link to comment https://forums.phpfreaks.com/topic/120570-confirm-password-and-confirm-email-for-loginregistration-please-help/#findComment-621303 Share on other sites More sharing options...
DeanWhitehouse Posted August 20, 2008 Share Posted August 20, 2008 JS can be disabled use PHP. Quote Link to comment https://forums.phpfreaks.com/topic/120570-confirm-password-and-confirm-email-for-loginregistration-please-help/#findComment-621317 Share on other sites More sharing options...
9homie Posted August 20, 2008 Author Share Posted August 20, 2008 Should it not be also easy with PHP... Also why would I not try before hand, of course I did, try and get evidence before you accuse people by the way. If the javascript is more easy then does anyone know it or should I ask it somewhere else? Quote Link to comment https://forums.phpfreaks.com/topic/120570-confirm-password-and-confirm-email-for-loginregistration-please-help/#findComment-621334 Share on other sites More sharing options...
bluebutterflyofyourmind Posted August 20, 2008 Share Posted August 20, 2008 javascript can be disabled but it is also much faster than sending the info to the server just to have it sent back when somethings wrong. pretty much you just have to use javascript and the onKeyup for the input field to trigger the javascript check. then don't let them submit the form until the various inputs match. when they match make submitbutton.disabled = false. (start it off true in your form) you should be able to find how to do that through google. pretty simple stuff. let me know if you have problems. I you want to still do it the php way, just take the values that they send to you and compare them. if they don't match return an error and don't continue with the registration script. Quote Link to comment https://forums.phpfreaks.com/topic/120570-confirm-password-and-confirm-email-for-loginregistration-please-help/#findComment-621365 Share on other sites More sharing options...
DeanWhitehouse Posted August 20, 2008 Share Posted August 20, 2008 If you want to use JS , why not make a form checking function to check the whole form on submit , and then it will return true if it all is good. Quote Link to comment https://forums.phpfreaks.com/topic/120570-confirm-password-and-confirm-email-for-loginregistration-please-help/#findComment-621383 Share on other sites More sharing options...
nitation Posted August 21, 2008 Share Posted August 21, 2008 @blade As you said, javascript is not the best route to take when authenticating. it can be bypassed by a user. @poster, Kindly explain what you mean by confirm password and email. I don't get you Quote Link to comment https://forums.phpfreaks.com/topic/120570-confirm-password-and-confirm-email-for-loginregistration-please-help/#findComment-621559 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.