e4games Posted July 21, 2009 Share Posted July 21, 2009 So I used "justsomeguys" reigster code and changed it a little bit, would this still work? <?phprequire_once 'db.php';$page_mode = isset($_POST['page_mode']) ? $_POST['page_mode'] : '';$error_string = '';if ($page_mode == 'register'){ $email = trim($_POST['email']); // trim to remove whitespace $username = trim($_POST['username']); // trim to remove whitespace $password = $_POST['password']; $conf_password = $_POST['conf_password']; if (!isValidEmail($email)) $error_string .= 'Please enter a valid email address.<br>'; if ($name == '') $error_string .= 'Please enter your username.<br>'; if (strlen(trim($password)) < 6) $error_string .= 'You must enter a password of at least 6 characters.<br>'; if ($password != $conf_password) $error_string .= 'The password and confirmation password do not match.<br>'; if ($error_string == '') { $result = db_query("SELECT id FROM users WHERE email='" . mysql_real_escape_string($email) . "'"); if (mysql_num_rows($result) > 0) $error_string .= 'That email address is already registerd.<br>'; else { $email = mysql_real_escape_string($email); // protect against SQL attacks $name = mysql_real_escape_string($name); $password = sha1($password); // hash password db_query("INSERT INTO users (email, username, password) VALUES ('{$email}', '{$name}', '{$password}')"); header('Location: thankyou.php'); exit(); } }}function isValidEmail($email = ''){ return preg_match("/^[\d\w\/+!=#|$?%{^&}*`'~-][\d\w\/\.+!=#|$?%{^&}*`'~-]*@[A-Z0-9][A-Z0-9.-]{1,61}[A-Z0-9]\.[A-Z]{2,6}$/ix",$email);}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head> <title>Register</title> <style type="text/css"> .error_text { color: #FF0000; width: 400px; text-align: center; } .left_box { float: left; width: 150px; text-align: right; padding-right: 5px; } .right_box { clear: right; } </style> </head> <body> <div class="error_text"><?php echo $error_string; ?></div> <form action="register.php" method="post"> <input type="hidden" name="page_mode" value="register"> <div class="left_box">Email address</div> <div class="right_box"><input type="text" name="email" size="30" maxlength="255" value="<?php if (isset($email)) echo $email; ?>"></div> <div class="left_box">Username</div> <div class="right_box"><input type="text" name="username" size="30" maxlength="255" value="<?php if (isset($name)) echo $name; ?>"></div> <div class="left_box">Password</div> <div class="right_box"><input type="password" name="password" size="30"></div> <div class="left_box">Confirm Password</div> <div class="right_box"><input type="password" name="conf_password" size="30"></div> <div class="right_box><form action=""><select name="PokemonStarter"><option value="pokemon">Bulbasuar</option><option value="pokemon">Charmander</option><option value="pokemon">Squirtle</option><option value="pokemon">Piplup</option><option value="pokemon">Chimchar</option><option value="pokemon">Turtwig</option></select></form> <div class="left_box"> </div> <div class="right_box"><input type="submit" value="Register" size="30"></div> </form> </body></html> If it does, I then have one question, how do you then link the page that says "thank you for registering" or something like that when you click on the submit button Link to comment Share on other sites More sharing options...
justsomeguy Posted July 21, 2009 Share Posted July 21, 2009 What did you change? Did you test it? This line is redirecting to the thank you page after it inserts into the database:header('Location: thankyou.php'); Link to comment Share on other sites More sharing options...
e4games Posted July 21, 2009 Author Share Posted July 21, 2009 in the database, how do you make it so it has ID's like so that evertime someone registers the ID goes up by 1, like when it asks you (when making table for database) what is the Length/Value of it, what should you say Link to comment Share on other sites More sharing options...
smerny Posted July 21, 2009 Share Posted July 21, 2009 increment Link to comment Share on other sites More sharing options...
e4games Posted July 21, 2009 Author Share Posted July 21, 2009 you have to put a number, and for type would it be INT Link to comment Share on other sites More sharing options...
justsomeguy Posted July 22, 2009 Share Posted July 22, 2009 Yeah use int. You don't need to put a length for number fields, it will already be set. Link to comment Share on other sites More sharing options...
e4games Posted July 22, 2009 Author Share Posted July 22, 2009 What does it mean when it asks for Attributes and Collation...what am I supposed to put Link to comment Share on other sites More sharing options...
justsomeguy Posted July 22, 2009 Share Posted July 22, 2009 The best thing to do is to read through the MySQL documentation about those options so that you know what your options are. Collation doesn't apply to numbers, only text. For whatever reason I'm not able to load this page, but the information is here:http://dev.mysql.com/doc/refman/5.0/en/create-table.html Link to comment Share on other sites More sharing options...
e4games Posted July 22, 2009 Author Share Posted July 22, 2009 I can't load that page either Link to comment Share on other sites More sharing options...
justsomeguy Posted July 22, 2009 Share Posted July 22, 2009 mysql.com might be temporarily fubar. Try again later, or check for MySQL database design tutorials online. Link to comment Share on other sites More sharing options...
e4games Posted July 25, 2009 Author Share Posted July 25, 2009 the link worked! thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.