Jump to content

Register.php not functioning correctly.


smashmouth

Recommended Posts

This is my code:

 

<?php
include ("common/config.php");
include ("common/database.class.php");
include_once ("securimage/securimage.php");
include ("header.php");


$securimage = new Securimage();

$db = new database;

# Email Validation Function

function check_email_address($email) {
  // First, we check that there's one @ symbol, 
  // and that the lengths are right.
  if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
    // Email invalid because wrong number of characters 
    // in one section or wrong number of @ symbols.
    return false;
  }
  // Split it into sections to make life easier
  $email_array = explode("@", $email);
  $local_array = explode(".", $email_array[0]);
  for ($i = 0; $i < sizeof($local_array); $i++) {
    if
(!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&
?'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",
$local_array[$i])) {
      return false;
    }
  }
  // Check if domain is IP. If not, 
  // it should be valid domain name
  if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
    $domain_array = explode(".", $email_array[1]);
    if (sizeof($domain_array) < 2) {
        return false; // Not enough parts to domain
    }
    for ($i = 0; $i < sizeof($domain_array); $i++) {
      if
(!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|
?([A-Za-z0-9]+))$",
$domain_array[$i])) {
        return false;
      }
    }
  }
  return true;
}

# Programmed by tony tony Copyright (c) 2008 All rights 

reserved.

$GetFileMain = file("html/register.html") ;
$webpage = join("",$GetFileMain) ;

if ($_POST["submit"] == "Register"){

if ($securimage->check($_POST['captcha_code']) == false) {
	echo "<span class='error'>Security Code does not Match. Please Try 

Again</span>";
	exit;
}

# Validate the data passed.
if (empty($_POST[firstname])){
	echo "<span class='error'>Firstname is a required field</span>";
	exit;
}else{
	$firstname = $_POST[firstname];
}
if (empty($_POST[lastname])){
	echo "<span class='error'>Lastname is a required field</span>";
	exit;
}else{
	$lastname = $_POST[lastname];
}

if (empty($_POST[email])){
	echo "<span class='error'>Email is a required field</span>";
	exit;
}else{
	$email = $_POST[email];
}
if (empty($_POST[emailconfirm])){
	echo "<span class='error'>Confirmation Email is a required field</span>";
	exit;
}else{
	$emailconfirm = $_POST[emailconfirm];
}	
if ($email <> $emailconfirm){
	echo "<span class='error'>Your email and conformation emails do not 

match</span>";
	exit;
}
if (empty($_POST[username])){
	echo "<span class='error'>Username is a required field</span>";
	exit;
}else{
	$username = $_POST[username];
}
if (empty($_POST[password])){
	echo "<span class='error'>Password is a required field</span>";
	exit;
}else{
	$password = $_POST[password];
}
if (empty($_POST[confirmpassword])){
	echo "<span class='error'>Confirm Password is a required field</span>";
	exit;
}else{
	$confirmpassword = $_POST[confirmpassword];
}

# Check to see if the password and confirm password match.

if ($password <> $confirmpassword){
	echo "<span class='error'>Password and Confirm Passwords must 

match.</span>";
	exit;
}

# Check email address for format.

$email_check = check_email_address($email);

if ($email_check == false){
	echo "<span class='error'>You must enter a valid email address</span>";
	exit;
}

$date = date('Y-m-d');

# Write data to database.
$ip = $_SERVER['REMOTE_ADDR']; 

$chk_user_sql = "SELECT count(*) usrcnt FROM members WHERE username = '$username' 

OR email = '$email'";
$chk_user_result = $db->get_a_line($chk_user_sql);
$user_count = $chk_user_result[0];

if ($user_count > 0){
	echo "<span class='error'>User Record Already Exists for either $email, 

$username or $ip</span>";
	exit;
}

$code = md5(uniqid(rand(), true));
$source = $_POST["source"];

$insert_member_sql = "INSERT INTO members (firstname, lastname, email, username, 

password, date, type, ipaddress, active, code, source)
							   	   VALUES 

('$firstname','$lastname','$email','$username','$password','$date','Free', '$ip', 'Y', 

'$code', '$source')";
$member_id = $db->insert_data_id($insert_member_sql);

$ins_fdlr_sql = "INSERT INTO folders (owner, foldername) VALUES 

('$username','default')";
$db->insert($ins_fdlr_sql);
$ins_fdlr_sql2 = "INSERT INTO folders (owner, foldername) VALUES ('$username','Sent 

Items')";
$db->insert($ins_fdlr_sql2);

# Create the Chat User

$url = "http://96.228.176.19/chat/scripts/signup.php"; 
$postfields["username"] = $username;
$postfields["password"] = $password;
$postfields["email"] = $email;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$data = curl_exec($ch);
curl_close($ch);


require ("send_smtp.php");


$body = "Thank you for registering at site. To activate your account, 

please click on this link:\n\n";
  	$body .= "http://www.site.com/activate.php?x=" . $member_id . 

"&y=$code";
  	//mail($_POST['email'], 'Registration Confirmation', $body, 'From: 

[email protected]');
  	
  	$_SESSION["member_type"] = "Free";
$_SESSION["logged_in"] = "Y";
$_SESSION["user_name"] = $username;
$_SESSION["user_id"] = $member_id;
$_SESSION["show"] = "Y";
$_SESSION["shwc"] = "Y";
$_SESSION["injail"] = 'N';
$_SESSION["admin"] = 'N';
$_SESSION["paid"] = 'N';
$_SESSION["password"] = $password;
  	

?>
<SCRIPT LANGUAGE="JavaScript">
alert("You have been registered Successfully. Click OK and you will be autologged 

in to the system.");
window.location="http://www.site.com/index.php";
</script>
<?
exit;
}


$webpage = preg_replace("/{{(.*?)}}/e","$$1",$webpage) ;
echo $webpage;
include ("footer.php");
?>

 

 

When I sign up using this form, I get the "Your email and confirmation emails do not match" but they are the same emails.

 

Wondering why it's doing this? Thanks in Advance!.

Link to comment
https://forums.phpfreaks.com/topic/192754-registerphp-not-functioning-correctly/
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.