Well I will start out on what I have. I have a registration form and a table for users that register. Table has these fields:
id (auto inc)
f_name
l_name
u_name User Name
u_pass Password
e_mail Email Address
created
created_ip
last_login
last_ip
gender
address1
address2
city
state
zip
web_q (bool)
web_s
Now I have a few users in there for testing and all works well with the script in general. Here is the script:
[code=php]
<?
if($_POST[op] != “ds”) {
$d_created = date(“Y-m-d”);
$IP = getenv(“REMOTE_ADDR”);
$seeform = “yes”;
$formblock = ”
<form method=”post” action=”$SERVER[PHP_SELF]”>
<input type=”hidden” name=”created” value=”$d_created”>
<input type=”hidden” name=”last_login” value=”$d_created”>
<input type=”hidden” name=”last_ip” value=”$IP”>
<input type=”hidden” name=”op” value=”ds”>
<label>First Name<br />
</label>
<input type=”text” name=”f_name” size=”25″ maxlength=”25″ /><br />
<label>Last Name<br />
</label>
<input type=”text” name=”l_name” size=”25″ maxlength=”25″ /><br />
<label>Desired User Name<br />
</label>
<input type=”text” name=”u_name” size=”25″ maxlength=”50″ /><br />
<label>Password<br />
</label>
<input type=”password” name=”u_pass” size=”10″ maxlength=”10″ /><br />
<label>E-Mail<br />
</label>
<input type=”text” name=”e_mail” size=”25″ maxlength=”50″ /><br />
<label>Gender<br /></label>
Male<input type=”radio” name=”gender” value=”Male” />
Female<input type=”radio” name=”gender” value=”Female” />
Not Disclosed<input type=”radio” name=”gender” value=”Not Disclosed” /><br />
<label>Address Line 1</label>
<br />
<input type=”text” name=”address1″ size=”50″ maxlength=”100″ /><br />
<label>Address Line 2</label>
<br />
<input type=”text” name=”address2″ size=”50″ maxlength=”100″ /><br />
<label>City</label>
<br />
<input type=”text” name=”city” size=”50″ maxlength=”100″ /><br />
<label>State</label>
<br />
<input type=”text” name=”state” size=”25″ maxlength=”50″ /><br />
<label>Postal Code<br />
</label>
<input type=”text” name=”zip” size=”10″ maxlength=”10″ /><br />
<label>Web Site?</label>
<input type=”checkbox” name=”web_q” value=”1″ /><br />
<label>If so, Whats the address?</label>
<br />
<input type=”text” name=”web_s” size=”50″ maxlength=”100″ /><br />
<div align=”center”>
<input type=”submit” name=”submit” value=”Submit” />
</div>
</form>
“;
} else if ($_POST[op] == “ds”){
$seeform = “no”;
if ($_POST[f_name] == “”) {
$fname_err = “<span style=”color:red;”>You must enter a first name.</span><br />”;
$send = “no”;
}
if ($_POST[l_name] == “”) {
$lname_err = “<span style=”color:red;”>You must enter a last name.</span><br />”;
$send = “no”;
}
if ($_POST[u_name] == “”) {
$user_err = “<span style=”color:red;”>You must enter a user name.</span><br />”;
$send = “no”;
}
if ($_POST[u_pass] == “”) {
$user_err = “<span style=”color:red;”>You must enter a Password.</span><br />”;
$send = “no”;
}
if ($_POST[e_mail] == “”) {
$email_err = “<span style=”color:red;”>You must enter a valid E-Mail address.</span><br />”;
$send = “no”;
}
if ($_POST[gender] == “”) {
$gender_err = “<span style=”color:red;”>You must specify gender.</span><br />”;
$send = “no”;
}
if ($_POST[address1] == “”) {
$address_err = “<span style=”color:red;”>You must enter a Address.</span><br />”;
$send = “no”;
}
if ($_POST[city] == “”) {
$city_err = “<span style=”color:red;”>You must enter a City.</span><br />”;
$send = “no”;
}
if ($_POST[state] == “”) {
$state_err = “<span style=”color:red;”>You must enter a State.</span><br />”;
$send = “no”;
}
if ($_POST[zip] == “”) {
$zip_err = “<span style=”color:red;”>You must enter a Zip Code.</span><br />”;
$send = “no”;
}
if ($send != “no”) {
$db_name = “markbad_markbadsql”;
$connection = mysql_connect (“localhost”, “user”, “password”)
or die (‘Error line x:’ . mysql_error());
$db = mysql_select_db ($db_name, $connection)
or die (‘Error line x:’ . mysql_error());
function sanitize($input)
{
if(get_magic_quotes_gpc())
{
$input = stripslashes($input);
}
return(mysql_real_escape_string($input));
}
$address1 = sanitize($_POST[‘address1’]);
$address2 = sanitize($_POST[‘address2’]);
$web_s = sanitize($_POST[‘web_s’]);
$sql = “INSERT INTO users
(id, f_name, l_name, u_name, u_pass, e_mail, created, last_login, last_ip, gender, address1, address2, city, state, zip, web_q, web_s)
VALUES
(”,
‘$_POST[f_name]’,
‘$_POST[l_name]’,
‘$_POST[u_name]’,
‘$_POST[u_pass]’,
‘$_POST[e_mail]’,
‘$_POST[created]’,
‘$_POST[last_login]’,
‘$_POST[last_ip]’,
‘$_POST[gender]’,
‘$address1’,
‘$address2’,
‘$_POST[city]’,
‘$_POST[state]’,
‘$_POST[zip]’,
‘$_POST[web_q]’,
‘$web_s’
)”;
$result = mysql_query($sql, $connection) or die (‘line 148’ . mysql_error());
// Display Confirmation to the user
$display_block = “<h4>Thanks for Registering, $_POST[f_name]</h4>
<p>User Name: $_POST[u_name]</p>
<p>E-Mail Address: $_POST[e_mail]</p>
<p>City: $_POST[city]</p>
<p>State: $_POST[state]</p>”;
}
else if ($send == “no”) {
$display_block = ”
$fname_err
$lname_err
$user_err
$email_err
$gender_err
$address_err
$city_err
$state_err
$zip_err
<p>Please hit your back to restore the form</p>”;
}
}
if ($seeform == “yes”){
$display_block = $formblock;
}
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head><title>The Erie Scene :: Registration Form</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<link href=”/favicon.ico” rel=”SHORTCUT ICON” />
<link href=”layout5.css” type=”text/css” rel=”stylesheet” />
</head>
<body>
<table cellpadding=”0″ cellspacing=”0″ align=”center”>
<tr>
<td colspan=”2″ id=”title”>
<img src=”images/corner.gif” alt=”Erie Chatroom” border=”0″ usemap=”#Map” /> </td>
</tr>
<tr valign=”top”>
<td id=”lh-col”>
<? require(“http://www.eriescene.com/includes/menus.php”); ?>
<div id=”katetguy”> </div>
</td>
<!– right column –>
<td id=”rh-col” rowspan=”2″>
<!–Show Form or Results–>
<? echo “$display_block”;?>
</td>
</tr>
<tr>
<td id=”footer” colspan=”2″>
<h5 align=”center” style=”margin:0px; padding:0px; “>Thanks For visiting The Erie Scene. We hope you have enjoyed our Erie Bar, Erie Event, and Erie Venue listings</h5>
<h6 align=”center”>Badaracco Web Development Copyright 2005</h6>
</td>
</tr>
</table>
</body>
</html>
But now (you can see up there) I have no checking against multiple names. I almost need a check against Duplicate E-Mail addresses and User Names. How can I do this please please please help. I have some ideas like making an array with all the user names in one and all the e_mail address in the other and checking it against what is posted. I also would like help on how to make my passwords in MD5 format. Can I have some clarity on this please please please!