Jump to content

Sign Up page error!


webby121

Recommended Posts

This is my code!

 

<?php

 

// Set error message as blank upon arrival to page

$errorMsg = "";

// First we check to see if the form has been submitted

if (isset($_POST['firstname'])){

//Connect to the database through our include

include_once "connect_to_mysql.php";

// Filter the posted variables

$accounttype = ereg_replace("[^a-z]", "", $_POST['accounttype']); // filter everything but lowercase letters

$companyname = ereg_replace("[^A-Za-z]", "", $_POST['companyname']); // filter everything but letters

$firstname = ereg_replace("[^A-Za-z]", "", $_POST['firstname']); // filter everything but letters

$lastname = ereg_replace("[^A-Za-z]", "", $_POST['lastname']); // filter everything but letters

$d_m = ereg_replace("[^A-Za-z]", "", $_POST['d_m']); // filter everything but letters

$d_d = ereg_replace("[^0-9]", "", $_POST['d_d']); // filter everything but number

$d_y = ereg_replace("[^0-9]", "", $_POST['d_y']); // filter everything but number

 

$housenumber = ereg_replace("[^0-9]", "", $_POST['housenumber']); // filter everything but number

$address = ereg_replace("[^A-za-z]", "", $_POST['address']); // filter everything but number

$address1 = ereg_replace("[^A-za-z]", "", $_POST['address1']); // filter everything but number

$town = ereg_replace("[^A-Za-z]", "", $_POST['town']); // filter everything but letters

$postcode = ereg_replace("[^A-Z a-z0-9]", "", $_POST['postcode']); // filter everything but letters and numbers and spaces

$phone = ereg_replace("[^0-9]", "", $_POST['postcode']); // filter everything but numbers

$studentnumber = ereg_replace("[^0-9]", "", $_POST['studentnumber']); // filter everything but numbers

$username = ereg_replace("[^A-Za-z0-9]", "", $_POST['username']); // filter everything but numbers and letters

 

 

 

 

 

$email = stripslashes($_POST['email']);

$email = strip_tags($email);

$email = mysql_real_escape_string($email);

$password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters

 

 

 

// Check to see if the user filled all fields with

// the "Required"(*) symbol next to them in the join form

// and print out to them what they have forgotten to put in

if((!$accounttype) || (!$firstname) || (!$lastname) || (!$d_d) || (!$d_m) || (!$d_y)  || (!$housenumber)|| (!$address)|| (!$town)|| (!$postcode)|| (!$phone) || (!$username)|| (!$email)|| (!$confirmemail)|| (!$password)  || (!$confirmpassword)      ){

 

$errorMsg = "You did not submit the following required information!<br /><br />";

if(!$accounttype){

$errorMsg .= "--- Account Type";

} else if(!$firstname){

$errorMsg .= "--- First Name";

} else if(!$lastname){

    $errorMsg .= "--- Last Name";

  } else if(!$d_d){

      $errorMsg .= "--- Date of Birth Day";

  } else if(!$d_m){

      $errorMsg .= "--- Date of Birth Month";

  } else if(!$d_y){

      $errorMsg .= "--- Date of Birth Year";

  } else if(!$housenumber){

      $errorMsg .= "--- Housenumber";

  } else if(!$address){

      $errorMsg .= "--- Address";

  }else if(!$town){

      $errorMsg .= "--- Town";

  }else if(!$postcode){

      $errorMsg .= "--- Postcode";

  }else if(!$phone){

      $errorMsg .= "--- Phone";

  }else if(!$username){

      $errorMsg .= "--- Username";

  }else if(!$email){

      $errorMsg .= "--- Email";

    }else if(!$password){

      $errorMsg .= "--- Password";

  }

} else {

// Database duplicate Fields Check

$sql_username_check = mysql_query("SELECT id FROM member WHERE username='$username' LIMIT 1");

$sql_email_check = mysql_query("SELECT id FROM members WHERE email='$email' LIMIT 1");

$username_check = mysql_num_rows($sql_username_check);

$email_check = mysql_num_rows($sql_email_check);

 

}

if ($username_check > 0){

$errorMsg = "<u>ERROR:</u><br />Your User Name is already in use inside our system. Please try another.";

} else if ($email_check > 0){

$errorMsg = "<u>ERROR:</u><br />Your Email address is already in use inside our system. Please try another.";

}

    if($password != $confirmpassword)

          {

            echo "Passwords do not match. Please try again.";

          }

 

if($email != $confirmemail)

          {

            echo "Emails do not match. Please try again.";

          }

 

    else {

// Add MD5 Hash to the password variable

      $hashedPass = md5($password);

 

 

 

 

    // Convert Birthday to a DATE field type format(YYYY-MM-DD) out of the month, day, and year supplied

  $dateofbirth = "$d_y-$d_m-$d_d";

 

 

 

// Add user info into the database table, claim your fields then values

$sql = mysql_query("INSERT INTO member (username, companyname, firstname, lastname, dateofbirth, accounttype, email, password, lastlogin, phone)

VALUES('$username','$companyname','$firstname','$lastname','$dateofbirth','$accounttype','$email', '$hashedPass',now(),'$phone')") or die (mysql_error());

 

 

$sql = mysql_query("INSERT INTO address (housenumber, postcode, town, address, address1)

VALUES('$housenumber','$postcode','$town','$address','$address1')") or die (mysql_error());

 

$sql = mysql_query("INSERT INTO student (studentnumber)

VALUES('$studentnumber')") or die (mysql_error());

 

 

// Get the inserted ID here to use in the activation email

$id = mysql_insert_id();

 

// Create directory(folder) to hold each user files(pics, MP3s, etc.)

mkdir("memberFiles/$id", 0755);

 

// Start assembly of Email Member the activation link

$to = "$email";

 

// From

$from = "http://users.ecs.soton.ac.uk/alw3g08/index.php";

$subject = "Complete your registration";

 

//Begin HTML Email Message where you need to change the activation URL inside

$message = '<html>

<body bgcolor="#FFFFFF">

Hi ' . $username . ',

<br /><br />

You must complete this step to activate your account with us.

<br /><br />

Please click here to activate now >>

<a href="http://users.ecs.soton.ac.uk/alw3g08/activation.php?id=' . $id . '">

ACTIVATE NOW</a>

<br /><br />

Your Login Data is as follows:

<br /><br />

E-mail Address: ' . $email . ' <br />

Password: ' . $password . '

<br /><br />

Thanks!

</body>

</html>';

// end of message

 

$headers = "From: $from\r\n";

$headers .= "Content-type: text/html\r\n";

$to = "$to";

 

// Finally send the activation email to the member

mail($to, $subject, $message, $headers);

 

// Then print a message to the browser for the joiner

print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br />

We just sent an Activation link to: $email<br /><br />

<strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br />

Link inside the message. After email activation you can log in.";

exit();

 

// Exit so the form and page does not display, just this success message

} // Close else after database duplicate field value checks

  } // Close else after missing vars check

//Close if $_POST

?>

Link to comment
https://forums.phpfreaks.com/topic/231945-sign-up-page-error/#findComment-1193202
Share on other sites

Could you provide a little more information. Which error messages are being displayed and when? For example, which one gets displayed when the passwords and emails match?

 

 

Also, when posting code please use the code tag [ code]...[ /code]. Of course you'll need to remove the space after the open square bracket. You can also click the pound sign (#) button when composing a message to get the code tag.

Link to comment
https://forums.phpfreaks.com/topic/231945-sign-up-page-error/#findComment-1193207
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.