SirChick Posted July 22, 2007 Share Posted July 22, 2007 I need to alter some code so that it will check that certain requirements are met before registration submission is pressed. I will explain what i need to have checked below the code i have done so far. Here is what i got so far: <?php if (isset($_POST['RegistrationSubmission'])) { $Username = $_POST['Username']; $Password = $_POST['Password']; $Password2 = $_POST['Password2']; If ($Password == $Password2) { mysql_connect("localhost", "root", "private") or die (mysql_error()); mysql_select_db("database") or die (mysql_error()); $query = "INSERT INTO `registrationdetails` (Username) Values ('$Username')"; echo $query; mysql_query($query) or die(mysql_error()); } else if ($Password != $Password2) { echo "passwords did not match"; } } ?> Basically i need the following added to this code: A)Validate if the check box is checked to agree to the terms of service else give error and reset all fields. B)If the username is taken or not, providing an error and reseting the fields if username is taken. C)Upon a successful registration go to "thisurl" automatically. Is this possible? D)Also just to add, im unsure if this can be done but i want to store the user's IP so they cannot physically access the registration page again, by checking if the IP is registered already... Quote Link to comment https://forums.phpfreaks.com/topic/61293-adding-a-few-things-to-my-registration/ Share on other sites More sharing options...
ki Posted July 22, 2007 Share Posted July 22, 2007 check if checkbox is checked: if(!$_POST['checkboxname']) { die('You did not agree with terms of service'); } check username $chkUSR = mysql_query("SELECT * FROM `registrationdetails` WHERE `user` = '".$_POST['Username']."'"); $getUSR = mysql_fetch_object($chkUSR); if($_POST['Username'] == $getUSR->Username) { die('username already registered'); } redirect header("Location: success.php"); Quote Link to comment https://forums.phpfreaks.com/topic/61293-adding-a-few-things-to-my-registration/#findComment-304988 Share on other sites More sharing options...
SirChick Posted July 22, 2007 Author Share Posted July 22, 2007 could you kindly explain that last bit: header("Location: success.php"); what is success.php exactly? is that where i store the url ? and thankyou so much for your help! Quote Link to comment https://forums.phpfreaks.com/topic/61293-adding-a-few-things-to-my-registration/#findComment-304989 Share on other sites More sharing options...
Aureole Posted July 22, 2007 Share Posted July 22, 2007 For A I would use Javascript for B I'm not too sure how to approach that...I'll have a think about it and for C you would just use like... header('location: somepage.php'); I'm new to all this so if this didn't help then don't complain...there will be someone who knows how to help you. could you kindly explain that last bit: header("Location: success.php"); what is success.php exactly? is that where i store the url ? It will just redirect to that url yes. Quote Link to comment https://forums.phpfreaks.com/topic/61293-adding-a-few-things-to-my-registration/#findComment-304991 Share on other sites More sharing options...
ki Posted July 22, 2007 Share Posted July 22, 2007 header() is a function Location: tells it that you want to redirect it to a page, success.php is any page you want Quote Link to comment https://forums.phpfreaks.com/topic/61293-adding-a-few-things-to-my-registration/#findComment-304992 Share on other sites More sharing options...
SirChick Posted July 22, 2007 Author Share Posted July 22, 2007 ok thanks guys much appreciated. also why is javascript a better choice ? Or is it really the only best choice? Quote Link to comment https://forums.phpfreaks.com/topic/61293-adding-a-few-things-to-my-registration/#findComment-304995 Share on other sites More sharing options...
Aureole Posted July 23, 2007 Share Posted July 23, 2007 If you used Javascript you could make sure that if they clicked Submit they would be informed that they have to tick the checkbox whereas if you user Php it will take you to another page then say they need to go back and click the checkbox...which is...annoying. If you want I can try find you a Javascript code snippet to do what you want? Quote Link to comment https://forums.phpfreaks.com/topic/61293-adding-a-few-things-to-my-registration/#findComment-305031 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.