Search the Community
Showing results for tags 'signup'.
-
Hello, Currently having issues with my sign up form. I feel I'm missing a bit of code for this form to work properly. Currently, I have a signup form that adds a new user into the site, this works fine and adds all the details to the database. The problem is, is that the button has to go through the signup_process php file, but currently it echos that the "new user has been created" on that file, but I need to use this file but echo that the "new user has been created" in the signup file (redirecting the user back to the signup page after clicking the button, but still goes through the signup_process file for processing) Also, I need a way that will log the new user in, instantly after they have signed up so that don't have to login after successful sign up. I'm also trying to validate my form so that details have to be entered in, I've started adding this, but doesn't seem to work right; it either does work and doesn't add a new user or it doesn't work and adds a new user. I appreciate that the code I have may be old and does not contain proper security measures; but this is not at all important for the assignment I'm doing. Thanks for any help. PHP PROCESS FILE <?php session_start(); include "./includes/connect.php"; include "./includes/lists.php"; include "./includes/functions.php"; ?> <?php $username = $_POST['regusername']; $password = $_POST['regpassword']; $firstname = $_POST['regfirstname']; $surname = $_POST['regsurname']; $email = $_POST['regemail']; $dob = $_POST['regdob']; $gender = $_POST['reggender']; $city = $_POST['regcityname']; $sports = $_POST['regsports']; $query = "INSERT INTO `user` (user_username, user_password, user_firstname, user_surname, user_email, user_dob, user_gender, user_city) VALUES ('$username', '$password', '$firstname', '$surname', '$email', '$dob', '$gender', '$city')"; $result = mysql_query($query); if($result) { echo "New user has been created!"; } ?> PHP SIGN UP FILE <?php session_start(); include "./includes/connect.php"; include "./includes/lists.php"; include "./includes/functions.php"; ?> <?php include "./includes/pagetop.php"; ?> <?php include "./includes/heading.php"; ?> <?php include "./includes/nav.php"; ?> <?php // form validation $usernamevalid = $passwordvalid = ""; $usernamefield = $passwordfield = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["regusername"])) { $usernamevalid = "Username required!";} else { $usernamefield = ($_POST["regusername"]);} if (empty($_POST["regpassword"])) { $passwordvalid = "Password required!";} else { $passwordfield = ($_POST["regpassword"]);} } ?> <div id="content"> <h3>Sign up</h3> <form name="input" action="signup_process.php" method="post"> <b>Login Details</b> <b>Username</b><input type="text" name="regusername"> <font color=red><?php echo $usernamevalid;?></font><br /> <b>Password</b> <input type="password" name="regpassword"> <font color=red><?php echo $passwordvalid;?></font> </br> <b>Personal Details</b> <b>First Name</b><input type="text" name="regfirstname"><br /> <b>Surname</b> <input type="text" name="regsurname"><br /> <b>Email</b> <input type="text" name="regemail"><br /><br /> <b>Date of Birth</b> <input type="text" name="regdob"><br /><br /> <b>Gender</b> <input type="radio" name="reggender" value="1">Male <input type="radio" name="reggender" value="2">Female <br /><br /> <b>City</b> <select id="cityname" name="regcityname"> <?php // city names foreach ($citynames as $key => $value){ echo "<option value=\"$key\">$value</option>"; } ?> </select> </br> <b>Sports</b> <?php // lists of sports $query = "SELECT sport_id, sport_name FROM sport"; $result = mysql_query($query) or die (mysql_error()); while($row = mysql_fetch_array($result)){ $sports[$row['sport_id']] = $row['sport_name']; } foreach ($sports as $key => $value){ echo "<div>\n"; echo "<input type=\"checkbox\" id=\"$value\" name=\"sport[]\" value=\"$key\">\n"; echo "<label for=\"$value\">$value</label>\n"; echo "</div>\n"; } ?> </select> </br> <center><input type="submit" name="regsubmit" value="Sign up"></center><br /> </form> </div> <?php include "./includes/adverts.php"; ?> <?php include "./includes/footer.php"; ?> <?php include "./includes/pagebottom.php"; ?>
-
Hi , i'm new to php. i'm creating a signup form with email verification (PHPmailer) everything seems to work except when the user confirm the email, their information does not save to the database , so they can't login their account. the error is with the INSERT INTO customer part. can someone help me? thanks <?php if (isset($_GET["passkey"])) { $confirm = $_GET["passkey"]; $con = mysql_connect("localhost","root"); if (!$con) echo(mysql_error()); else { mysql_select_db("dbhotel",$con); $sql = "SELECT * FROM temp WHERE ConfirmCode = '" . $confirm . "'"; $rs = mysql_query($sql,$con); if (mysql_num_rows($rs) == 1) { $rows = mysql_fetch_assoc($rs); $sql = "INSERT INTO customers(FName,LName,Title,Address,Phone,Email,Password) VALUES ('". $rows["FName"] . "','" . $rows["LName"] . "','" . $rows["Title"] . "','" . $rows["Address"] . "','" . $rows["Phone"] . "','" . $rows["Email"] . "','" . $rows["Password"]."')"; mysql_query($sql,$con); $sql = "DELETE FROM temp WHERE ConfirmCode = '" . $confirm . "'"; mysql_query($sql,$con); echo "Congratulations " . $rows["Title"] ." ". $rows["FName"] ." ". $rows["LName"] . ", you are now a member!"; } else { echo "Sorry, we are unable to process your request at this moment. Please try again later."; } } mysql_close($con); } else { echo "You do not have enough permissions to access this page."; } ?>
- 5 replies
-
- php
- registration
-
(and 3 more)
Tagged with: