Jump to content

Archived

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

tomfmason

registration problems

Recommended Posts

I followed the member system tutorial and found several syntax errors. But this one has me stumped I think that it is in my join script.

Here is the join.php
[code]<?php
$filename = "registration.php";
$title = "Registration"; 
$content = "
  <div class=\"feature\">
  <div align=\"center\">
  <p>
    <b>Registration Form</b>
  </div>
  </p>
    <form method=\"POST\" action=\"includes/register.php\">
<p>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  First Name
</p>
<p>
  <input type=\"text\"  name=\"first_name\" id=\"first_name2\">
</p>
<p>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  Last Name
</p>
<p>
  <input type=\"text\"  name=\"last_name\" id=\"last_name\">
</p>
<p>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  Email
</p>
<p>
  <input type=\"text\"  name=\"email\" id=\"email\">
</p>
<p>
  &nbsp;&nbsp;&nbsp;
  Desired Username
</p>
<p>
  <input type=\"text\"  name=\"username\" id=\"username\">
</p>
<div align=\"center\">
<p>
  <input type=\"submit\"  name=\"Submit\" value=\"Join Now\">
</p>
</div>
    </form>
  </div>
  </div>";
include("includes/main.php"); 
?>[/code]

The problem that I am having is that the join.php is not posting the user information to register.php

here is the register.php
[code]  <?php
include 'db.php';
$first_name = $_POST['first_name'];
$lastname_name = $_POST['last_name'];
$username = $_POST['username'];
$email_address = $_POST['email_address'];

$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$username = stripslashes($username);
$email_address = stripslashes($email_address);

if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
    echo "You did not submit the following required information ! </br>";
}
    if(!$first_name){
echo "Your first name is a required field. Please enter it below. </br>";
}
if(!$last_name){
echo "Your last name is a required field. Please enter it below. </br>";
}
if(!$username){
echo "Your username is a required field. Please enter it below. </br>";
}
if(!$email_address){
echo "Your email address is a required field. Please enter it below. </br>";
}
include '..\join.php';
exit();


$sql_email_check = mysql_query("SELECT email_address FROM home WHERE email_address='$email_address'");
$sql_username_check = mysql_query("SELECT username FROM home 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 use 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 'join.php'; 
    exit();


function makeRandomPassword() {
  $salt = "abchefghjkmnpqrstuvwxyz0123456789";
  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, password, signup_date, 

decrypted_password)
        VALUES('$first_name', '$last_name', '$email_address', '$username', '$db_password', now(), '$random_password')") 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 at owpt.biz";
    $message = "Dear $first_name $last_name,
    You are now registered at our website, http://www.owpt.biz!
   
    To activate your membership, please login here: http://www.owpt.biz/home/index.php
   
    Once you activate your membership, you will be able to login with the following information:
    Username: $username
    Password: $random_password
    Please keep this username and password in a location that is easily accessible by you.
   
    Thanks!
    WebMaster, Owpt.biz
   
    This is an automated response, please do not reply!";
   
    mail($email_address, $subject, $message, "From: Owpt<webmaster@owpt.biz>\nX-Mailer: PHP/" . phpversion());
    echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!';
}
?>[code]

I think that the user information from join.php is not getting passed to register.php  [/code][/code]

Share this post


Link to post
Share on other sites
this was a simple fix..lol. it was the email_address field.

before
[code] <p>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  Email
</p>
<p>
  <input type=\"text\"  name=\"email\" id=\"email\">
</p>[/code]

Now
[code] <p>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  Email
</p>
<p>
  <input type=\"text\"  name=\"email\" id=\"email\">
</p>[/code]

Now I am having another problem. After the register.php checks if the user imputed the correct information it doesn't go any further. What I mean is that it just sends me back to the join.php form.


Here is where I think it is stoping the process.
[code]if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
    echo "You did not submit the following required information ! </br>";
}
    if(!$first_name){
echo "Your first name is a required field. Please enter it below. </br>";
}
if(!$last_name){
echo "Your last name is a required field. Please enter it below. </br>";
}
if(!$username){
echo "Your username is a required field. Please enter it below. </br>";
}
if(!$email_address){
echo "Your email address is a required field. Please enter it below. </br>";
}
include '..\join.php';
exit();[/code]


Any suggestions would be great

Share this post


Link to post
Share on other sites

×

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.