ok I have created a register page the code is as follows:
<?php
require_once ('lib/register_functions.php');
if ($submit == 'Mail confirmation')
{
$feedback = user_register();
$feedback_str = "<P class=\"errormess\">$feedback</p>";
}
else
{
$feedback_str ='';
}
$php_self = $_SERVER['PHP_SELF'];
$reg_str = <<< EOREGSTR
<table cellpadding=0 cellspacing=0 border=0 align=center width=621>
<tr>
<td rowspan=10><img width=15 height=1 src=../images/spacer.gif></td>
<td width=606></td>
</tr>
<tr>
<td>
$feedback_str
<p class="left"><b>REGISTER</b><br>
Fill out this form and a confirmation email will be sent to you.
Once you click on the link in the email your account will be
confirmed and you can begin to contribute to the community.</P>
<FORM ACTION="$php_self" METHOD="POST">
<p class ="bold">First Name<br>
<INPUT TYPE="text" NAME="first_name" VALUE="$first_name" size="20" maxlength="25"></p>
<p class ="bold">Last Name<br>
<INPUT TYPE="text" NAME="last_name" VALUE="$last_name" size="20" maxlength="25"></p>
<p class ="bold">User Name<br>
<INPUT TYPE="text" NAME="user_name" VALUE="$user_name" size="10" maxlength="25"></p>
<p class ="bold">Password<br>
<INPUT TYPE="text" NAME="password1" VALUE="" size="10" maxlength="25"></p>
<p class ="bold">Password Again<br>
<INPUT TYPE="text" NAME="password2" VALUE="" size="10" maxlength="25"></p>
<p class ="bold">Email - Required<br>
<INPUT TYPE="text" NAME="email" VALUE="$email" size="30" maxlength="50"></p>
<p><INPUT TYPE="SUBMIT" NAME="submit" VALUE ="Mail confirmation"></p>
</FORM>
</td>
</tr>
</table>
EOREGSTR;
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Register for an Account</title>
</head>
<body>
<?php echo $reg_str; ?>
</body>
</html>
Now my include page of register_functions - code is below:
<?php
include_once('config.php');
$supersecret_hash_padding = 'A string that is used to pad' . 'out short strings for md5 encryption.';
function user_regester() {
global $supersecret_hash_padding;
//Are all VARS present and do passwords MATCH
if (strlen($_POST['user_name']) <= 25 &&
strlen($_POST['password1']) <= 25 && ($_POST['password1'] ==
$_POST['password2']) && strlen($_POST['email']) <= 50 &&
validate_email($_POST['email'])) {
//Validate UserName and PassWord
if(account_namevalid($_POST['user_name']) ||
strlen($_POST['password1'] >= 6 )) {
$user_name = strtolower($_POST['user_name']);
$user_name = trim($user_name);
$email = $_POST['email'];
$query = "SELECT user_id
FROM user
WHERE user_name = '$user_name'
AND email = '$email'";
$result = mysql_query($query);
if ($result && mysql_num_rows($result) > 0) {
$feedback = 'ERROR - - UserName and or EMAIL is already taken';
return $feedback;
} else {
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$password = md5($_POST['password1']);
$user_ip = $_SERVER['REMOTE_ADDR'];
//Create new HASH to insert into DB and the Conformation EMAIL
$hash = md5($email.$supersecret_hash_padding);
$query = "INSERT INTO user (user_name, first_name, last_name, password, email, remote_addr, confirm_hash, is_confirmed, date_created)
VALUES ('$user_name', '$first_name', '$last_name', '$password', '$email', '$user_ip', '$hash', '0', NOW())";
$result = mysql_query($query);
if (!$result) {
$feedback = 'ERROR - - Database ERROR';
return $feedback;
} else {
//Send Conformation EMAIL
$encoded_email = urlencode($_POST['email']);
$mail_body = <<< EOMAILBODY
Thank you for registering at www.okaucheewi.com! Click this link below to confirm registration.
http://localhost/confirm.php?hash=$hash$email=$encoded_email
Once you see a confirmation message, you will be logged into www.okacuheewi.com
EOMAILBODY;
mail ($email, 'OkaucheeWI Registration Confirmation' , $mail_body, 'FROM: noreply@okaucheewi.com');
// Give a successfull registration message
$feedback = 'YOU HAVE SUCCESSFULLY REGISTER. You will receive a confirmation email shortly';
return $feedback;
}
}
} else {
$feedback = 'ERROR - - UserName or PassWord Invalid';
return $feedback;
}
} else {
$feedback = 'ERROR - - Please fill in all required fields correctly';
return $feedback;
}
}
function account_namevalid() {
$span_str = "abcdefghijklmnopqrstuvwxyz" . "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-";
//Must have at least 1 character
if(strspn($_POST['user_name'],$span_str) == 0) {
return false;
}
//Must contain legal characters
if(strspn($_POST['user_name'],$span_str) != strlen($name)) {
return false;
}
//Min and Max Length
if (strlen($_POST['user_name']) <5) {
return false;
}
if (strlen($_POST['user_name']) > 25) {
return false;
}
//Illegal names
if
(eregi("^((root) | (bin) | (daemon) | (adm) | (lp) | (sync) | (shutdown) |
(halt) | (mail) | (news) | (uucp) | (operator) | (games) | (mysql) |
(httpd) | (nobody) | (dummy) | (www) | (cvs) | (shell) | (ftp) | (irc) |
(debian) | (ns) | ( donwload))$", $_POST['user_name'])) {
return false;
}
if (eregi("^(anoncvs_)", $_POST['user_name'])) {
return false;
}
return false;
}
function validate_email() {
return (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'. '@' . '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.' . '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $_POST['email']));
}
function user_confirm() {
global $supersecret_hash_padding;
//Verify no tampering with email address
$new_hash = md5($_GET['email'].$supersecret_hash_padding);
if ($new_hash && ($new_hash == $_GET['hash'])) {
$query = "SELECT user_name
FROM user
WHERE confirm_hash = '$new_hash'";
$result = mysql_query($query);
if (!$result || mysql_num_rows($result) < 1) {
$feedback = 'ERROR - - Hash not found';
return $feedback;
} else {
//Confirm email and set account active
$email = $_GET['email'];
$hash = $_GET['hash'];
$query = "UPDATE user SET email ='$email', is_confirmed='1' WHERE confirm_hash = '$hash'";
$result = mysql_query($query);
return 1;
}
} else {
$feedback = 'ERROR - - Values do not match';
return $feedback;
}
}
?>
Now when I go to register.php and submit, it does nothing but reload the page.
Also, if I were to put in passwords that don't match, my error msgs don't come up.
http://www.fearfx.com/OkaucheeWI/register.php
The link above is a live demonstration of what I am working on.
I really would appreciate the help!
Thank you.