Hello all,
[code=html]
<form action=”http://www.myweb.com/register.php”method=”post” name=”register” id=”register”>
<table width=”80%” border=”0″ cellpadding=”1″ cellspacing=”1″>
<tr bgcolor=”#AA5500″>
<td colspan=”2″ class=”header1″><div align=”center”>YourInfo
</div></td></tr>
<tr>
<td width=”50%” align=”left”><span class=”text”>First Name:</span><br>
<input name=”first_name” type=”text” class=”box2″ id=”first_name” value=”<? echo $first_name; ?>”>
</td>
<td align=”left”><span class=”text”>Last Name:</span><br>
<input name=”last_name” type=”text” class=”box2″ id=”last_name” value=”<? echo $last_name; ?>”>
</td></tr>
<tr>
<td align=”left”><span class=”text”>Email Address:</span><br>
<input name=”email_address” type=”text” class=”box2″ id=”email_address” value=”<? echo $email_address; ?>”>
</td>
<td width=”50%” align=”left”> <span class=”text”>Desired Username: </span><br>
<input name=”username” type=”text” class=”box2″ id=”username” value=”<? echo $username; ?>”>
</td></tr>
<tr>
<td colspan=”2″ align=”left”><div align=”center”><br>
</div></td></tr></table>
<div align=”center”>
<textarea name=”agreement” cols=”40″ rows=”7″ readonly wrap=”VIRTUAL” class=”box2″ id=”agreement”><? echo $agreement; ?>
“agreement”
“agreement”
“agreement”
</textarea></span></div></form>
[/code]
[code=php]
<?include ‘db.php’;
$first_name = $_POST[‘first_name’];
$last_name = $_POST[‘last_name’];
$email_address = $_POST[’email_address’];
$username = $_POST[‘username’];
$agreement = $_POST[“agreement”];
// Strip some slashes IS THIS WRONG?
$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$email_address = stripslashes($email_address);
$username = stripslashes($username);
$agreement = stripslashes($agreement);
if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
echo ‘You did not submit the following required information! <br />’;
if(!$first_name){
echo “First Name is a required field. Please enter it below.<br />”;
}
if(!$last_name){
echo “Last Name is a required field. Please enter it below.<br />”;
}
if(!$email_address){
echo “Email Address is a required field. Please enter it below.<br />”;
}
if(!$username){
echo “Desired Username is a required field. Please enter it below.<br />”;
}
include ‘form.html’;
exit();
}
$sql_email_check = mysql_query(“SELECT email_address FROM users
WHERE email_address=’$email_address'”);
$sql_username_check = mysql_query(“SELECT username FROM users
WHERE username=’$username'”);
$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);
if(($email_check > 0) || ($username_check > 0)){
echo “Please fix the following errors: <br />”;
if($email_check > 0){
echo “<strong>Your email address has already been used by another member in our database. Please submit a different Email address!<br />”;
unset($email_address);
}
if($username_check > 0){
echo “The username you have selected has already been used by another member in our database. Please choose a different Username!<br />”;
unset($username);
}
include ‘form.html’;
exit();
}
function makeRandomPassword() {
$salt = “abcdhfghjklmnopqrtuvwxyyz0123456789”;
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
$random_password = makeRandomPassword();
$db_password = md5($random_password);
$sql = mysql_query(“INSERT INTO users (first_name, last_name, email_address, username)
VALUES(‘$first_name’, ‘$last_name’, ‘$email_address’, ‘$username’, ‘$agreement’, now())”)
or die (mysql_error());
if(!$sql){
echo ‘There has been an error creating your account. Please contact the webmaster.’;
} else {
$userid = mysql_insert_id();
$subject = “Your Membership status at Myweb.com!”;
$message = “Greatings $first_name $last_name,
Welcome to Myweb.com your membership is almost complete!
You are just a few steps away from logging in and accessing our exclusive members area.
To activate your membership, please click here:
http://www.myweb.com/activate.php?id=$userid&code=$db_password
Once you activate your memebership, you will be able to login with the following information:
Username: $username
Password: $random_password
Thanks!
The Webmaster
This is an automated response, please do not reply!”;
mail($email_address, $subject, $message,
“From: MyDomain Webmaster<[email protected]>n
X-Mailer: PHP/” . phpversion());
echo ‘Your membership information has been mailed to
your email address!
Please check it and follow the directions!’;
}
?>[/code]