PHP - My Register.php For Custom Site
Hi I really need help coding my register.php
please flag any mistakes and suggest additions to the code
please help
<html> <head> <title>______________</title> </head> <body> <h2>Registration Page</h2> <a href="index.php">Click here to go back<br/><br/> <form action="register.php" method="POST"> Enter Company Name: <input type="text" name="Company_Name" required="required" /> <br/> Enter Unit: <input type="text" name="Unit" required="required" /> <br/> Enter Street: <input type="text" name="Street" required="required" /> <br/> Enter Town: <input type="text" name="Town" required="required" /> <br/> Enter County: <input type="text" name="County" required="required" /> <br/> Enter Postcode: <input type="text" name="Postcode" required="required" /> <br/> Enter Country: <input type="text" name="Country" required="required" /> <br/> Enter Phone Number: <input type="text" name="Phone_Number" required="required" /> <br/> Enter Email: <input type="text" name="Email" required="required" /> <br/> Enter Password: <input type="password" name="Password" required="required" /> <br/> <input type="submit" value="Register"/> </form> </body> </html> <?php if($_SERVER["REQUEST_METHOD"]== "POST"){ $Company_Name = mysql_real_escape_string($POST['Company Name']); $Unit = mysql_real_escape_string($POST['Unit']); $Street = mysql_real_escape_string($POST['Street']); $Town = mysql_real_escape_string($POST['Town']); $County = mysql_real_escape_string($POST['County']); $Postcode = mysql_real_escape_string($POST['Postcode']); $Country = mysql_real_escape_string($POST['Country']); $Phone_Number = mysql_real_escape_string($POST['Phone Number']); $Email = mysql_real_escape_string($POST['Email']); $Password = mysql_real_escape_string($POST['Password']); echo "Company Name entered is: ". $Company_Name . "<br/>"; echo "Unit entered is: ". $Unit . "<br/>"; echo "Street entered is: ". $Street . "<br/>"; echo "Town entered is: ". $Town . "<br/>"; echo "County entered is: ". $County . "<br/>"; echo "Postcode entered is: ". $Postcode . "<br/>"; echo "Country entered is: ". $Country . "<br/>"; echo "Phone Number entered is: ". $Phone_Number . "<br/>"; echo "Email entered is: ". $Email. "<br/>"; echo "Password entered is: ". $Password . "<br/>"; } ?> Similar TutorialsIf I wanted to create a custom CMS that will allow people to be able to upload files, register a new account, to be able to add to a blog article, edit one's article but not someone else's, edit one's profile, be able to leave comments, edit comments as well as edit their blog articles in something similar to this forum's post box (with Bold, Italic, etc options), how would I go about it? I have no idea where to start or which board would be the proper place to put this but what I"m attempting to do is integrate this idea with my custom cms I'm making now is that once inside I can take down my site in case I (administrator) wanted to perform some maintenance on my site and have it instead display a custom 404 page. Any ideas on where to start. I tried using my best friend google but he gave me nothing. Maybe a few tutorials of this might help. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=323879.0 I'm sure it's not much, but I'm not understanding something with custom error handlers: I've created a custom error handler, which I initially set when my page loads : set_error_handler(array ( new ErrorHandler(), 'handleError' ));
It seems to catch all internal PHP errors, such as if I: var_dump($non_existing_var); right after the set_error_handler.... Now, I have an object that throws an exception after: set_error_handler(array ( new ErrorHandler(), 'handleError' )); $locale = new \CorbeauPerdu\i18n\Locale(...); // this should throw an exception ... I thought that with an error handler set, I could 'skip' the try/catch for it, but doing so, PHP spits out in its internal log: PHP Fatal error: Uncaught CorbeauPerdu\i18n\LocaleException: ....
My error handler doesn't catch it at all before, thus my page breaks!! If I want it to go through the error handler, I have to init my Locale with a try/catch and use trigger_error() like so: set_error_handler(array ( new ErrorHandler(), 'handleError' )); try { $locale = new \CorbeauPerdu\i18n\Locale(...); // this should throw an exception } catch(Exception $e) { trigger_error($e->getMessage(), E_USER_ERROR); } ... Is this normal ? I thought one of the goals of the error_handler was to catch anything that wasn't dealt with? Thanks for your answers! Hello everyone, I want to make a re-register script that enables a user to re-register once killed.... BUT keep the same email, same profile pic, same profile quote, same friends and a few other things.... BUT register new username etc. Any help would be great. I have a simple register script and some weird things are happening. If i leave blank password or repeat_password then code is still executed. Why? I can't seem to find any mistakes in the code. (only when username is empty then i get "You need to fill everything"). Code: [Select] <?php $submit = $_POST['submit']; $username = strip_tags($_POST['username']); $password = md5(strip_tags($_POST['password'])); $repeat_password = md5(strip_tags($_POST['repeat_password'])); require("connect.php"); if ($submit) { if (!empty($username) && !empty($password) && !empty($repeat_password)) { mysql_query("INSERT INTO users2 VALUES ('', '$username', '$password', '1000', '0', '0','', '', '')"); echo "You are registered <br />Your username is "."<b>$username</b>"."<br /> You may now <a href='index.php'> login </a>"; } else { echo "You have not filled everything."; } } ?> Hi there, There's something wrong with this register form, it's submitting without validation. Code: [Select] <?php require_once('./includes/connectvars.php'); // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (isset($_POST['submit'])) { // Grab the profile data from the POST $username = mysqli_real_escape_string($dbc, trim($_POST['username'])); $password1 = mysqli_real_escape_string($dbc, trim($_POST['password1'])); $password2 = mysqli_real_escape_string($dbc, trim($_POST['password2'])); $firstname = mysqli_real_escape_string($dbc, trim($_POST['first_name'])); $lastname = mysqli_real_escape_string($dbc, trim($_POST['last_name'])); if (!empty($username) && !empty($password1) && !empty($password2) && ($password1 == $password2) && !empty($firstname) && !empty($lastname)) { // Make sure someone isn't already registered using this username $query = "SELECT * FROM users WHERE username = '$username'"; $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 0) { // The username is unique, so insert the data into the database $query = "INSERT INTO users (username, password, join_date, first_name, last_name) VALUES ('$username', SHA('$password1'), NOW(), '$firstname', '$lastname')"; mysqli_query($dbc, $query); // Confirm success with the user echo '<p>Your new account has been successfully created. You\'re now ready to <a href="login.php">log in</a>.</p>'; mysqli_close($dbc); exit(); } else { // An account already exists for this username, so display an error message echo '<p class="error">An account already exists for this username. Please use a different address.</p>'; $username = ""; } } else { echo '<p class="error">You must enter all of the sign-up data, including the desired password twice.</p>'; } } mysqli_close($dbc); ?> <p>Please enter your username and desired password to sign up to Mismatch.</p> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <legend>Registration Info</legend> <label for="username">Username:</label> <input type="text" id="username" name="username" value="<?php if (!empty($username)) echo $username; ?>" /><br /> <label for="password1">Password:</label> <input type="password" id="password1" name="password1" /><br /> <label for="password2">Password (retype):</label> <input type="password" id="password2" name="password2" /><br /> <label for="first_name">first name:</label> <input type="text" id="first_name" name="first_name" /><br /> <label for="last_name">last name:</label> <input type="text" id="last_name" name="last_name" /><br /> <input type="submit" value="Sign Up" name="submit" /> </form> </body> </html> I've had this problem for a while now and can't figure it out, any suggestions are appreciated. Thank you. Okay, I downloaded a PHP Script called RadiPanel which is a User System type thing and uploaded and installed it to my website. Now The problem with RadiPanel is, I have to add users/members to it as there is no registration process. So within the Admin page on RadiPanel I have taken the script out, now when I try view it as a "non logged in" user it just shows a white blank page, I was wondering if anyone here could determine just from the code below what I have to take out/delete in order for the public to view the page fully? Thanks guys Code: [Select] <?php if( !preg_match( "/index.php/i", $_SERVER['PHP_SELF'] ) ) { die(); } if( $_GET['id'] ) { $id = $core->clean( $_GET['id'] ); $query = $db->query( "SELECT * FROM users WHERE id = '{$id}'" ); $data = $db->assoc( $query ); $data['ugroups'] = explode( ",", $data['usergroups'] ); $editid = $data['id']; } ?> <form action="" method="post" id="addUser"> </div> <?php if( $_POST['submit'] ) { try { $username = $core->clean( $_POST['username'] ); $password = $core->clean( $_POST['password'] ); $email = $core->clean( $_POST['email'] ); $habbo = $core->clean( $_POST['habbo'] ); $dgroup = $core->clean( $_POST['dgroup'] ); $query = $db->query( "SELECT * FROM usergroups" ); while( $array = $db->assoc( $query ) ) { if( $_POST['ugroup-' . $array['id']] ) { $ugroups .= $array['id'] . ","; } } $password_enc = $core->encrypt( $password ); if( !$username or ( !$password and !$editid ) or !$dgroup or !$ugroups ) { throw new Exception( "All fields are required." ); } else { if( $editid ) { if( $password ) { $password = ", password = '{$password_enc}'"; } else { unset( $password ); } $db->query( "UPDATE users SET username = '{$username}'{$password}, email = '{$email}', habbo = '{$habbo}', displaygroup = '{$dgroup}', usergroups = '{$ugroups}' WHERE id = '{$editid}'" ); } else { $db->query( "INSERT INTO users VALUES (NULL, '{$username}', '{$password_enc}', '{$email}', '{$habbo}', '{$dgroup}', '{$ugroups}');" ); } echo "<div class=\"square good\">"; echo "<strong>Success</strong>"; echo "<br />"; echo "User added!"; echo "</div>"; } } catch( Exception $e ) { echo "<div class=\"square bad\">"; echo "<strong>Error</strong>"; echo "<br />"; echo $e->getMessage(); echo "</div>"; } } ?> <table width="100%" cellpadding="3" cellspacing="0"> <?php $query = $db->query( "SELECT * FROM usergroups" ); while( $array = $db->assoc( $query ) ) { if( in_array( $array['id'], $data['ugroups'] ) ) { $groups[$array['id'] . '_active'] = $array['name']; } else { $groups[$array['id']] = $array['name']; } if( $array['id'] == $data['displaygroup'] ) { $dgroups[$array['id'] . '_active'] = $array['name']; } else { $dgroups[$array['id']] = $array['name']; } } echo $core->buildField( "text", "required", "username", "Username", "The new username.", $data['username'] ); echo $core->buildField( "password", "<?php if( !$editid ) { ?>required<?php } ?>", "password", "Password", "The new password." ); echo $core->buildField( "text", "", "email", "Email", "The new email (optional).", $data['email'] ); echo $core->buildField( "text", "", "habbo", "Habbo name", "The new Habbo name (optional).", $data['habbo'] ); echo $core->buildField( "select", "required", "dgroup", "Display group", "The user's display group.", $dgroups ); echo $core->buildField( "checkbox", "required", "ugroup", "Active usergroups", "The user's active groups.", $groups ); ?> </table> </div> <div class="box" align="right"> <input class="button" type="submit" name="submit" value="Submit" /> </div> </form> <?php echo $core->buildFormJS('addUser'); ?> Hi, I created a previous thread but the problems were too confusing so I've started this thread again. I have a register form and it's supposed to validate if fields are empty. If fields are not empty, it should enter data on submit, into the table. The problem: The form is able to submit without validation and the data does not enter the table. The code: Code: [Select] <?php require_once('./includes/connectvars.php'); // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (isset($_POST['submit'])) { // Grab the profile data from the POST $username = mysqli_real_escape_string($dbc, trim($_POST['username'])); $password1 = mysqli_real_escape_string($dbc, trim($_POST['password1'])); $password2 = mysqli_real_escape_string($dbc, trim($_POST['password2'])); $firstname = mysqli_real_escape_string($dbc, trim($_POST['first_name'])); $lastname = mysqli_real_escape_string($dbc, trim($_POST['last_name'])); if (!empty($username) && !empty($password1) && !empty($password2) && ($password1 == $password2) && !empty($firstname) && !empty($lastname)) { // Make sure someone isn't already registered using this username $query = "SELECT * FROM cuser WHERE username = '$username'"; $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 0) { // The username is unique, so insert the data into the database $query = "INSERT INTO cuser (username, password, join_date, first_name, last_name) VALUES ('$username', SHA('$password1'), NOW(), '$firstname', '$lastname')"; mysqli_query($dbc, $query); // Confirm success with the user echo '<p>Your new account has been successfully created. You\'re now ready to <a href="login.php">log in</a>.</p>'; mysqli_close($dbc); exit(); } else { // An account already exists for this username, so display an error message echo '<p class="error">An account already exists for this username. Please use a different address.</p>'; $username = ""; } } else { echo '<p class="error">You must enter all of the sign-up data, including the desired password twice.</p>'; } } mysqli_close($dbc); ?> <p>Please enter your username and desired password to sign up to Mismatch.</p> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <legend>Registration Info</legend> <label for="username">Username:</label> <input type="text" id="username" name="username" value="<?php if (!empty($username)) echo $username; ?>" /><br /> <label for="password1">Password:</label> <input type="password" id="password1" name="password1" /><br /> <label for="password2">Password (retype):</label> <input type="password" id="password2" name="password2" /><br /> <label for="first_name">first name:</label> <input type="text" id="first_name" name="first_name" /><br /> <label for="last_name">last name:</label> <input type="text" id="last_name" name="last_name" /><br /> <input type="submit" value="Sign Up" name="submit" /> </form> </body> </html> Any ideas on what the problem is? I've sent my sessions in another file. Hi, I'm looking to change my 'Dead' page on my Mafia game to enable users to register a new account as soon as they log in to their dead one. I would like them to be able to just enter a new Username and then the email, password etc stay the same. Is this possible? Just ask for any parts of the register code you guys need. Thanks in advance,. hi guys i need help i started a code of a page Register.php and i need to now what to do now and if this function is 100% ok with the php rules <?php // ---- session_start(); error_reporting(E_ALL); include_once("...\\config.php") //---------------------------------------------------- function getRegisteredBy($Reg); { switch($Reg){ case 0: return "AccountName"; case 1: return "AccountPassword"; case 2: return "AccountEmail"; } } $Reg = mssql_query("INSERT INTO MEMB_INFO (memb___id,memb__pwd,memb_mail,) VALUES ($AccountName,$AccountPassword,$AccountEmail)"); ?> thanks for the help and have a good day Ok so im working on this register script and trying to implement a select value field along with a email field and password field. At the moment i have given it my best shot and typed in most of the code, although im still not satisfied with the outcome. For example: When i type in a correct email with a legit password, and i DONT select one of the drop down options, i want it to say the error: "Please type in all fields.". This would be vise versa for each other field also! If the user again types in a legit email and password, and selects a value from the dropdown menu, but is already registered in the database, i would want another error message saying: "This club has already been registered to the database". I given it my best shot but simply not getting the above result. <?php include"database.php";?> <html><head><title>Register</title></head><body><h1>Register</h1><form name="register" action="register.php" method="post">Email: <input type="text" name="email"><br>Password: <input type="password" name="password"><br>Club: <select name="club"> <option value="">Select...</option> <option value="npob">Old Boys</option> <option value="tukupa">Tukupa</option> <option value="coastal">Coastal</option> <option value="inglewood">Inglewood</option> <option value="clifton">Clifton</option> <option value="stratford">Stratford</option> <option value="hawera">Hawera</option> </select><br><input type='submit' name='submit' value='Submit'></form> <?php if (isset($_POST['submit'])) { if (empty($_POST['email']) && empty($_POST['password']) && empty($_POST['club'])) { $errors[] = "Please fill out all fields."; } $email = addslashes(strip_tags($_POST['email'])); $password = addslashes(strip_tags($_POST['password'])); $club = addslashes(strip_tags($_POST['club'])); if (!empty($email)) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors[] = "This email address is not valid."; } } if (!empty($password)){ if (strlen($password)>25 || strlen($password)<6) { $errors[] = "Password must be betwen 6 and 25 characters.<br>"; } } if (!empty($club)){ $errors[] = "Please select a Club.<br>"; } $check = mysql_query("SELECT * FROM users WHERE email='".$email."'"); if (mysql_num_rows($check)>=1) { $errors[] = "Email is already taken!"; } $check = mysql_query("SELECT * FROM users WHERE club='".$club."'"); if (mysql_num_rows($check)>=1) { $errors[] = "Sorry this club has already been registered with the NZRU."; } if (empty($errors)) { $register = mysql_query("INSERT INTO users (email, password, club, level) VALUES ('".$email."', '".md5($password)."', '".$club."', '')"); echo "You have succesfully registered!"; } else { foreach($errors as $nErrors){ echo $nErrors . "<br>"; } } } ?>() Thankyou. I'm trying to make my register script check the database's IP column and compare it with the user's IP. If the User's IP equals that in the DB column, it should say "Sorry, there is already an account registered with your IP Address. Please log in.", and if there's no IP match, it should allow them to continue with registering. I've been tinkering around with this for a while and I can't seem to figure it out. Any help would be appreciated if ($_SERVER['REMOTE_ADDR'] == mysql_query("SELECT ip FROM users")) { die('Sorry, there is already an account registered with your IP Address. Please <a href="/login.php>log in.</a>'); }else{ echo ''; } I think the problem is with the mySQL query... Hello everyone,i was trying to make a register/login pages on my own and well i got stuck..and my good friend google couldn't help me :S So well i came to ask proffesionals Okay here is it: First thing i don't get is about email activation that i wanted to use on my register page... I got do_reg.php file that looks like this: Code: [Select] <?php include 'connection.php'; //grab data from form $name = $_POST['username']; $pass = $_POST['password']; $pass_conf = $_POST['pass_conf']; $email = $_POST['email']; $ip = $_POST['ip']; //if else if($name == false || $pass == false || $pass_conf == false || $email == false){ echo "Please fill in all the required fields."; }; if($pass != $pass_conf){ echo "Blah..Passwords do not match."; }else{ //generate random code $code = rand(11111111,99999999); //send email $subject = "Activate your account"; $headers = "From: admin@mysite.com"; $body = "Hello $name,\n\nYou registered and need to activate your account. Click the link below or paste it into the URL bar of your browser\n\n http://localhot/login/activate.php?code=$code\n\nThanks!"; if (!mail($email,$subject,$body,$headers)) echo "Error,what a shame!"; else { $sql = mysql_query("INSERT INTO users (username,password,email,code,active,ip) VALUES('$name','$pass','$email','$code',0,'$ip')") or die(mysql_error()); $result = mysql_query($sql); echo "Thank you for registering! But your account is not still active :'( Please check your email ($email) for activation code! :)"; } }; ?>I went through thousands of erros and still couldn't make it work,i am using xampp localhost server for now and maybe that is the reason it wont work even if i tried to activate SMTP and that stuff in php.ini conf file (as my friend google told me).. So this is one of the errors: Quote Warning: mail() [function.mail]: SMTP server response: 550 relaying denied in C:\xampp\htdocs\login\do_reg.php on line 25 Error,what a shame! Now the next thing i couldn't understand is where is the error inside this script... (do_login.php) Code: [Select] <?php include 'connection.php'; $session_username = $_SESSION['username']; if($_POST['login']) { //get form data $username = $_POST['username']; $password = $_POST['password']; } if(!$username||!$password) echo "Username and password missing!"; else { //login $login = mysql_query("SELECT * FROM users WHERE username='$username'"); } if (mysql_query($login)==0) echo "No souch user!"; else { while ($login_row = mysql_fetch_assoc($login)) { $password_db = $login_row['password']; $password = md5($password); if ($password!=$password_db) echo "Incorect password!"; else { //check if active $active = $login_row['active']; $email = $login_row['email']; if ($active==0) echo "You haven't activated your account, please check your email ($email) for activation!"; else { $_SESSION['username']=$username; //assign session header("Location: index.php");//refresh } } } } ?> Thank you for your spent time and help.. Hi nothing seems to work! No error messages appear and no data enters my database! Can people please help me please! Needs to be solved by today! Thanks <?php //connect to db $connect = mysql_connect("l", "", ""); mysql_select_db("", $connect); //if submit button gets pressed if(isset($_POST['submit'])){ //Grab data from the form $username = preg_replace('#[^A-Za-z0-9]#i','', $_POST['username']); // filter everything but letters and numbers $firstname = preg_replace('#[^A-Za-z]#i', '', $_POST['firstname']); // filter everything but Letters $lastname = preg_replace('#[^A-Za-z]#i', '', $_POST['lastname']); // filter everything but Letters $phone = preg_replace('#[^0-9]#i', '', $_POST['phone']); // filter everything but numbers $address= preg_replace('#[^A-Za-z]#i', '', $_POST['address']); // filter everything but Letters $postcode= preg_replace('#[^A-Za-z]#i', '', $_POST['postcode']); // filter everything but Letters $town= preg_replace('#[^A-Za-z]#i', '', $_POST['town']); // filter everything but Letters $housenumber= preg_replace('#[^0-9]#i', '', $_POST['housenumber']); // filter everything but numbers $b_m = preg_replace('#[^0-9]#i', '', $_POST['birth_month']); // filter everything but numbers $b_d = preg_replace('#[^0-9]#i', '', $_POST['birth_day']); // filter everything but numbers $b_y = preg_replace('#[^0-9]#i', '', $_POST['birth_year']); // filter everything but numbers $email1 = mysql_real_escape_string (stripslahes (strip_tags($_POST['email1']))); $email2 = mysql_real_escape_string (stripslahes (strip_tags($_POST['email2']))); $pass1 = md5(mysql_real_escape_string (stripslahes (strip_tags($_POST['pass1'])))); $pass2 = stripslashes(strip_tags($_POST['pass2'])); $emailCHecker = mysql_real_escape_string($email1); $emailCHecker = str_replace("`", "", $emailCHecker); // Database duplicate username check setup for use below in the error handling if else conditionals $sql_uname_check = mysql_query("SELECT username FROM member WHERE username='$username'"); $uname_check = mysql_num_rows($sql_uname_check); // Database duplicate e-mail check setup for use below in the error handling if else conditionals $sql_email_check = mysql_query("SELECT email FROM member WHERE email='$emailCHecker'"); $email_check = mysql_num_rows($sql_email_check); // Convert Birthday to a DATE field type format(YYYY-MM-DD) out of the month, day, and year supplied $dateofbirth = "$b_y-$b_m-$b_d"; //If any errors have been found, DO NOT register the member, and instead, redisplay the form } if (!isset($username) || !isset($firstname) || !isset ($lastname) || !isset($address) || !isset($postcode) || !isset($town) || !isset($b_m) || !isset($b_d) || !isset($b_y) || !isset($email1) || !isset($email2) || !isset($pass1) || !isset($pass2)) { $errorMsg = 'ERROR: You did not submit the following required information:<br /><br />'; if(!isset($username)){ $errorMsg .= ' * User Name<br />'; } if(!isset($firstname)){ $errorMsg .= ' * First Name<br />'; } if(!isset($lastname)){ $errorMsg .= ' * Last Name<br />'; } if(!isset($address)){ $errorMsg .= ' * Address<br />'; } if(!isset($postcode)){ $errorMsg .= ' * postcode<br />'; } if(!isset($town)){ $errorMsg .= ' * town<br />'; } if(!isset($b_m)){ $errorMsg .= ' * Birth Month<br />'; } if(!isset($b_d)){ $errorMsg .= ' * Birth Day<br />'; } if(!isset($b_y)){ $errorMsg .= ' * Birth year<br />'; } if(!isset($email1)){ $errorMsg .= ' * Email Address<br />'; } if(!isset($email2)){ $errorMsg .= ' * Confirm Email Address<br />'; } if(!isset($pass1)){ $errorMsg .= ' * Login Password<br />'; } if(!isset($pass2)){ $errorMsg .= ' * Confirm Login Password<br />'; } if ($email1!= $email2){ $errorMsg.='ERROR: Your email fields below do not match<br />'; } if ($pass1!= $pass2){ $errorMsg.='ERROR: Your password fields below do not match<br />'; } if(strlen($username)<6){ $errorMsg.="<u>ERROR:</u><br/>Your User Name is too short. 6-20 characters please. <br/>"; } if(strlen($username)>20){ $errorMsg.="<u>ERROR:</u><br/>Your User Name is too long. 6-20 characters please. <br/>"; } if($username_check>0){ $errorMsg.="<u>ERROR:</u><br/> Your User Name is already in use inside of our system. Please try another.<br/>"; } if($email_check >0){ $errorMsg.="<u>ERROR:</u><br/>Your Email address is already in use inside of our system. Please use another.<br/>"; } } else{ mysql_query("INSERT INTO member (username, firstname, lastname, email, password, dateofbirth, phone, lastlogin) VALUES('$username','$firstname','$lastname','$email1','$password', '$dateofbirth','$phone', now())") or die (mysql_error()); $sql = mysql_query("INSERT INTO address (address, postcode, town, housenumber) VALUES('$adress','$postcode,'$town','$housenumber'") or die (mysql_error()); mysql_close(); Echo "Welcome to my site, $username! You may now <a href=\"index.php\">login</a>."; } ?> Hello, I changed my register table and it seems to have made it stop working, All's i changed is the layout of the 'Username, Email' etc so it looks better, nothing else, but the register button aint working!! Old Code: Code: [Select] <table width="700" height="900" background="registerpic.jpg"> <tr valign="middle"> <td align="center"> <br> <div align="center" class="style4"> <? echo REGIS ?></div> <table width="28%" border="0" align="center" cellpadding="0" cellspacing="0"> <form action="" method="post"> <tr> <td><div align="right" class="style6 style1"><strong><? echo USEE ?></strong></div></td> <td width="9">:</td> <td width="192"><div align="left"> <input name="reg_username" type="text" class="input" id="reg_username" value="" size="32" maxlength="64"> </div></td> </tr> <tr> <td><div align="right" class="style6 style1"><strong><? echo PASSS ?></strong></div></td> <td><span class="style6 style1"><strong>:</strong></span></td> <td><div align="left"> <input name="reg_password" type="password" class="input" id="reg_password" value="" size="32" maxlength="40"> </div></td> </tr> <tr> <td><div align="right" class="style6 style1"><strong><? echo CONPASS ?></strong></div></td> <td><span class="style6 style1"><strong>:</strong></span></td> <td><div align="left"> <input name="reg_password2" type="password" class="input" id="reg_password2" value="" size="32" maxlength="40"> </div></td> </tr> <tr> <td><div align="right" class="style6 style1"><strong><? echo EM ?></strong></div></td> <td><span class="style6 style1"><strong>:</strong></span></td> <td><div align="left"> <input name="email" type="text" class="input" id="username3" value="" size="32" maxlength="150" > </div></td> </tr> <tr> <td><div align="right" class="style6 style1"><strong><? echo GENDER ?></strong></div></td> <td><span class="style6 style1"><strong>:</strong></span></td> <td><div align="left"> <select name="gender" class="input" id="starting" > <option value="Male"><? echo MALE ?></option> <option value="Female"><? echo FEMALE ?></option> </select> </div></td> </tr> <tr> <td><div align="right" class="style6 style1"><strong><? echo LANGU ?></strong></div></td> <td><span class="style6 style1"><strong>:</strong></span></td> <td><div align="left"> <select name="lang" class="input" id="starting" > <option value="English"><? echo ENG ?></option> <option value="Turkish"><? echo TR ?></option> </select> </div></td> </tr> <tr> <td><div align="right" class="style5"><? echo START ?></div></td> <td><span class="style6 style1"><strong>:</strong></span></td> <td><div align="left"> <select name="location" class="input" id="starting" > <option value="England" selected>England</option> <option value="Japan">Japan</option> <option value="Colombia">Colombia</option> <option value="Usa">Usa </option> <option value="Russia">Russia </option> <option value="Italy">Italy</option> <option value="Turkey">Turkey</option> </select> <input type="hidden" name="ref" value="<?php echo "$_GET[ref]"; ?>"> </div></td> </tr> <tr> <td colspan="3"><div align="center"> <p style="display: inline"> </p> <p style="display: inline"><em><strong> <? echo SEC ?> </strong></em></p> </div></td> </tr><tr> <td colspan="2" class="TableArea"><img src="eng/CaptchaSecurityImages.php" width="171" height="50" /></td> <td class="TableArea" valign="top"><fieldset> <legend><font color="#6F6F6F"><b><? echo SECC ?></b>:</font></legend> <span class="tablearea"> <input id="security_code" class="button" name="security_code" size="20" type="text"/> </span> <span style="display: inline"> <input name=Submit type=submit value= <? echo REGGG ?> > </span> </fieldset></td> </tr> <tr> <td colspan="3"><div align="center"></div></td> </tr> </table> <center><p><b><font color= "ffffff"><? echo "$message"; ?></font></p> <p> </p></td> <a href='register.php'><font size="1" color="#CCCCCC"><b><a href='index.php'>Home</a> - <a href='lost2.php'>Lost Password</a> - <a href='screens.php'>Screenshots</a></b></i></font> <td align="center" width="238"></form> </table> New Code: Code: [Select] <div id="main"> <img src="images/register(1).jpg"> <form action="" method="post"> <div id="register_table"> <div class="row"> <div class="title_column">Username</div> <div class="space_column">~</div> <div class="input_column"><input type="text" name="reg_username" id="reg_username" value="" class="text" /></div> </div> <div class="row"> <div class="title_column">Email</div> <div class="space_column">~</div> <div class="input_column"><input type="text" name="username3" id="username3" value="" class="text" /></div> </div> <div class="row"> <div class="title_column">Password</div> <div class="space_column">~</div> <div class="input_column"><input type="text" name="reg_password" id="reg_password" value="" class="text" /></div> </div> <div class="row"> <div class="title_column">Retype Pass</div> <div class="space_column">~</div> <div class="input_column"><input type="text" name="reg_password2" id="reg_password2" value="" class="text" /></div> </div> <div class="row"> <div class="title_column">Gender</div> <div class="space_column">~</div> <div class="input_column"><select name="gender" style="font-size:9px;font-family:Tahoma;width:130px;"><option value="Male">Male</option><option value="Female">Female</option></select></div> </div> <div class="row"> <div class="title_column">Location</div> <div class="space_column">~</div> <div class="input_column"><select name="starting" style="font-size:9px;font-family:Tahoma;width:130px;"><option value="England">England</option><option value="Japan">Japan</option><option value="Colombia">Colombia</option><option value="USA">USA</option><option value="Russia">Russia</option><option value="Italy">Italy</option><option value="Turkey">Turkey</option></select></div> </div> <div class="row"> <div class="title_column" style="padding-top: 2px; margin-top: 2px;"><img src="eng/CaptchaSecurityImages.php" alt="Verify" /></div> <div class="space_column">~</div> <div class="input_column"><input type="text" name="security_code" id="security_code" value="" class="text" /></div> </div> <br /> <div style="text-align:center;"><input type="submit" name="submit" value="<? echo Register ?>" class="submit" /> </div> <? echo "$message"; ?> </form></div> Thanks Guys! Hi guys I'm trying to fix my user registration page, I've gotten myself into a real mess here so any help would be appreciated I am getting "Notice: Undefined index" message for my variables (firstname,lastname,password,repeatpasswords) and it is not loading the page only the "die" message which is happening because the script is failing. Code: [Select] <?php session_start(); $con = mysql_connect('localhost','root','abc'); if (!$con) { die ("Could not connect to database" . mysql_error()); } //get data from the form if (isset($_POST['firstname'])) { $firstname = $_POST['firstname']; } if (isset($_POST['lastname'])) { $lastname = $_POST['lastname']; } if (isset($_POST['username'])) { $username = $_POST['username']; } if (isset($_POST['password'])) { $password = $_POST['password']; } if (isset($_POST['repeatpassword'])) { $repeatpassword = $_POST['repeatpassword']; } if (isset($_POST['submit'])) { //check for existance if ($firstname&&$lastname&&$username&&$password&&$repeatpassword) { //check passwords match if ($password==$repeatpassword) { //check char length of username and names if (strlen($username)>25||strlen($firstname)>25) { echo "The first name, last name or username fields are too long!"; } else { //check password length if (strlen($password)>25||strlen($password)<6) { echo "Password must be between 6 and 25characters"; } else { //encrypt password $password = md5 ($password); $repeatpassword = md5 ($repeatpassword); } } } else echo "Your passwords do not match!"; } else echo "Please fill in all fields!"; } //select database table mysql_select_db('theimageworks'); //add data to database $sql="INSERT INTO user (firstname, lastname, username, password) VALUES ('$_POST[firstname]', '$_POST[lastname]', '$_POST[username]', '$_POST[password]')"; if (!mysql_query($sql,$con)) { die ('Error: ' . mysql_error()); } die ("You have been registered! Return to <a href='loginpage.php'>login page</a>"); mysql_close($con); ?> Sorry for many posts, trying to make my website
When I press the register button on my website it will just act as if the page is refreshing and not send any information to mysql
I believe I have connected everything up correctly, can anyone tell my what I have done wrong please?
If you want to check out the website to see what is going on check out www.jokestary.comli.com
<?php //This function will display the registration form function register_form(){ $date = date('D, M, Y'); echo "<form action='?act=register' method='post'>" ."Username: <input type='text' name='username' size='30'><br>" ."Password: <input type='password' name='password' size='30'><br>" ."Confirm your password: <input type='password' name='password_conf' size='30'><br>" ."Email: <input type='text' name='email' size='30'><br>" ."<input type='hidden' name='date' value='$date'>" ."<input type='submit' value='Register'>" ."</form>"; } //This function will register users data function register(){ //Connecting to database include('connect.php'); if(!$connect){ die(mysql_error()); } //Selecting database $select_db = mysql_select_db("database", $connect); if(!$select_db){ die(mysql_error()); } //Collecting info $username = $_REQUEST['username']; $password = $_REQUEST['password']; $pass_conf = $_REQUEST['password_conf']; $email = $_REQUEST['email']; $date = $_REQUEST['date']; //Here we will check do we have all inputs filled if(empty($username)){ die("Please enter your username!<br>"); } if(empty($password)){ die("Please enter your password!<br>"); } if(empty($pass_conf)){ die("Please confirm your password!<br>"); } if(empty($email)){ die("Please enter your email!"); } //Let's check if this username is already in use $user_check = mysql_query("SELECT username FROM users WHERE username='$username'"); $do_user_check = mysql_num_rows($user_check); //Now if email is already in use $email_check = mysql_query("SELECT email FROM users WHERE email='$email'"); $do_email_check = mysql_num_rows($email_check); //Now display errors if($do_user_check > 0){ die("Username is already in use!<br>"); } if($do_email_check > 0){ die("Email is already in use!"); } //Now let's check does passwords match if($password != $pass_conf){ die("Passwords don't match!"); } //If everything is okay let's register this user $insert = mysql_query("INSERT INTO users (username, password, email) VALUES ('$username', '$password', '$email')"); if(!$insert){ die("There's little problem: ".mysql_error()); } echo $username.", you are now registered. Thank you!<br><a href=login.php>Login</a> | <a href=index.php>Index</a>"; } switch($act){ default; register_form(); break; case "register"; register(); break; } ?>Here is the connect.php code <?php $hostname="mysql6.000webhost.com"; //local server name default localhost $username="a5347792_users"; //mysql username default is root. $password=""; //blank if no password is set for mysql. $database="a5347792_users"; //database name which you created $con=mysql_connect($hostname,$username,$password); if(! $con) { die('Connection Failed'.mysql_error()); } mysql_select_db($database,$con); ?> I'am trying to make the page show the errors in the same page under the register button, but it always disable all the forms and show the error by it self. my code: Quote <?php ob_start(); session_start(); include_once "functions.php"; connect(); if(!$_POST['submit']){ echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<form method=\"post\" action=\"register.php\">\n"; echo "<tr><td colspan=\"2\" align=\"center\">Registration Form</td></tr>\n"; echo "<tr><td>Username</td><td><input type=\"text\" name=\"name\" maxLength=14></td></tr>\n"; echo "<tr><td>Password</td><td><input type=\"password\" name=\"password\" maxLength=14></td></tr>\n"; echo "<tr><td>Confirm</td><td><input type=\"password\" name=\"passconf\" maxLength=14></td></tr>\n"; echo "<tr><td>E-Mail</td><td><input type=\"text\" name=\"email\" maxLength=24></td></tr>\n"; echo "<tr><td>Question</td><td><input type=\"text\" name=\"idnumber\" maxLength=14></td></tr>\n"; echo "<tr><td>Answer</td><td><input type=\"text\" name=\"phone\" maxLength=14></td></tr>\n"; echo "<form method=\"post\" action=\"captcha.php\">\n"; echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<tr><td>Type The Letters You See Below Into the Box</td></tr>\n"; echo "<tr><td align=\"center\"><img src=\"image.php\"></td></tr>\n"; echo "<tr><td align=\"center\"><input type=\"text\" name=\"image\"></td></tr>\n"; echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Register\"></td></tr>\n"; echo "</form></table>\n"; }else { $errors = array(); $name = protect($_POST['name']); $password = protect($_POST['password']); $confirm = protect($_POST['passconf']); $email = protect($_POST['email']); $phone = protect($_POST['idnumber']); $ownerReply = protect($_POST['phone']); $image = $_POST['image']; if($image == $_SESSION['string']){}else{ $errors[] = "Wrong Captcha!"; }ob_end_flush(); if(!$name){ $errors[] = "Username is not defined!"; } if(!$password){ $errors[] = "Password is not defined!"; } if($password){ if(!$confirm){ $errors[] = "Confirmation password is not defined!"; } } if(!$email){ $errors[] = "E-mail is not defined!"; } if(!$idnumber){ $errors[] = "Security Question is not defined!"; } if(!$phone){ $errors[] = "Security Answer is not defined!"; } if($name){ if(!ctype_alnum($name)){ $errors[] = "Username can only contain numbers and letters!"; } $range = range(8,14); if(!in_array(strlen($name),$range)){ $errors[] = "Username must be between 8 and 14 characters!"; } } if($password && $confirm){ if($password != $confirm){ $errors[] = "Passwords do not match!"; } $range = range(10,14); if(!in_array(strlen($password),$range)){ $errors[] = "Password must be between 10 and 14 characters!"; } } if($email){ $checkemail = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i"; if(!preg_match($checkemail, $email)){ $errors[] = "E-mail is not valid, must be name@server.tld!"; } } if($idnumber){ if(!ctype_alnum($phone)){ $errors[] = "Securty Question can only contain numbers and letters!"; } $range = range(8,14); if(!in_array(strlen($idnumber),$range)){ $errors[] = "Securty Question must be between 8 and 14 characters!"; } } if($phone){ if(!ctype_alnum($phone)){ $errors[] = "Securty Answer can only contain numbers and letters!"; } $range = range(8,14); if(!in_array(strlen($phone),$range)){ $errors[] = "Securty Answer must be between 8 and 14 characters!"; } } if($email){ $sql2 = "SELECT * FROM `account` WHERE `email`='".$email."'"; $res2 = mysql_query($sql2) or die(mysql_error()); if(mysql_num_rows($res2) > 0){ $errors[] = "The e-mail address you supplied is already in use of another user!"; } } if(count($errors) > 0){ foreach($errors AS $error){ echo $error . "<br>\n"; } }else { $sql4 = "INSERT INTO `account` (`name`,`password`,`email`,`idnumber`,`phone`) VALUES ('".$name."','".md5($password)."','".$email."','".$idnumber."','".$phone."')"; $res4 = mysql_query($sql4) or die(mysql_error()); echo "You have successfully registered with the username <b>".$name."</b> and the password of <b>".$password."</b>!"; } } ?> Direct link to the register page in case you didn't understand what i mean. http://hebrithco.com/server/bew/ |