Jump to content

Working Register


e4games

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...