What is wrong with this code

  • AHaz
  • Graduate
  • Graduate
  • User avatar
  • Posts: 144
  • Loc: New York

Post 3+ Months Ago

it wont send the activateurl in the email...what is wrong with it? please help me
Code: [ Select ]
<?

include 'db.php';
// Define post fields into simple variables
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$username = $_POST['username'];

/* Let's strip some slashes in case the user entered
any escaped characters. */

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


if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
  echo '<strong><font color=red>You did not submit the following required information!</font></strong> <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 'register.htm'; // Show the form again!
  /* End the error checking and if everything is ok, we'll move on to
   creating the user account */
  exit(); // if the error checking has failed, we'll exit the script!
}

/* Let's do some checking and ensure that the user's email address or username
does not exist in the database */

$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><font color=red>Your email address has already been used by another member. Please submit a different Email address!</font></strong><br />";
    unset($email_address);
  }
  if($username_check > 0){
    echo "<strong><font color=red>The username you have selected has already been used by another member. Please choose a different Username!</font></strong><br />";
    unset($username);
  }
  include 'register.htm'; // Show the form again!
  exit(); // exit the script so that we do not create this account!
}



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);

// Enter info into the Database.

$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address,
    username, password, signup_date)
  VALUES('$first_name', '$last_name', '$email_address',
    '$username', '$db_password', 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();

$activateurl="http://www.ahazdesigns.com/activate.php?id=$userid&code=$db_password";


  $subject = "Thankyou for Joining";
  $message = "
Thank you for joining\n
Your User information:\n
Username: $username\n
Password: $random_password\n
Once you login you can change your password\n
Thanks\n
Admin";
  
  mail($email_address, $subject, $message,
    "From: \" Member Services \" <registration@ahazdesigns.com>\n X-Mailer: chfeedback.php 2.01");
  echo '<title>Members - Vertification Sent</title>Your Membership information has been mailed to your email address, Check your email and follow the instructions to activate your account';
}

?>
  1. <?
  2. include 'db.php';
  3. // Define post fields into simple variables
  4. $first_name = $_POST['first_name'];
  5. $last_name = $_POST['last_name'];
  6. $email_address = $_POST['email_address'];
  7. $username = $_POST['username'];
  8. /* Let's strip some slashes in case the user entered
  9. any escaped characters. */
  10. $first_name = stripslashes($first_name);
  11. $last_name = stripslashes($last_name);
  12. $email_address = stripslashes($email_address);
  13. $username = stripslashes($username);
  14. if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
  15.   echo '<strong><font color=red>You did not submit the following required information!</font></strong> <br />';
  16.   if(!$first_name){
  17.     echo "First Name is a required field. Please enter it below.<br />";
  18.   }
  19.   if(!$last_name){
  20.     echo "Last Name is a required field. Please enter it below.<br />";
  21.   }
  22.   if(!$email_address){
  23.     echo "Email Address is a required field. Please enter it below.<br />";
  24.   }
  25.   if(!$username){
  26.     echo "Desired Username is a required field. Please enter it below.<br />";
  27.   }
  28.   include 'register.htm'; // Show the form again!
  29.   /* End the error checking and if everything is ok, we'll move on to
  30.    creating the user account */
  31.   exit(); // if the error checking has failed, we'll exit the script!
  32. }
  33. /* Let's do some checking and ensure that the user's email address or username
  34. does not exist in the database */
  35. $sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address'");
  36. $sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'");
  37. $email_check = mysql_num_rows($sql_email_check);
  38. $username_check = mysql_num_rows($sql_username_check);
  39. if(($email_check > 0) || ($username_check > 0)){
  40.   echo "Please fix the following errors: <br />";
  41.   if($email_check > 0){
  42.     echo "<strong><font color=red>Your email address has already been used by another member. Please submit a different Email address!</font></strong><br />";
  43.     unset($email_address);
  44.   }
  45.   if($username_check > 0){
  46.     echo "<strong><font color=red>The username you have selected has already been used by another member. Please choose a different Username!</font></strong><br />";
  47.     unset($username);
  48.   }
  49.   include 'register.htm'; // Show the form again!
  50.   exit(); // exit the script so that we do not create this account!
  51. }
  52. function makeRandomPassword() {
  53.  $salt = "abchefghjkmnpqrstuvwxyz0123456789";
  54.  srand((double)microtime()*1000000);
  55.    $i = 0;
  56.    while ($i <= 7) {
  57.       $num = rand() % 33;
  58.       $tmp = substr($salt, $num, 1);
  59.       $pass = $pass . $tmp;
  60.       $i++;
  61.    }
  62.    return $pass;
  63. }
  64. $random_password = makeRandomPassword();
  65. $db_password = md5($random_password);
  66. // Enter info into the Database.
  67. $sql = mysql_query("INSERT INTO users (first_name, last_name, email_address,
  68.     username, password, signup_date)
  69.   VALUES('$first_name', '$last_name', '$email_address',
  70.     '$username', '$db_password', now())") or die (mysql_error());
  71. if(!$sql){
  72.   echo 'There has been an error creating your account. Please contact the webmaster.';
  73. } else {
  74.   $userid = mysql_insert_id();
  75. $activateurl="http://www.ahazdesigns.com/activate.php?id=$userid&code=$db_password";
  76.   $subject = "Thankyou for Joining";
  77.   $message = "
  78. Thank you for joining\n
  79. Your User information:\n
  80. Username: $username\n
  81. Password: $random_password\n
  82. Once you login you can change your password\n
  83. Thanks\n
  84. Admin";
  85.   
  86.   mail($email_address, $subject, $message,
  87.     "From: \" Member Services \" <registration@ahazdesigns.com>\n X-Mailer: chfeedback.php 2.01");
  88.   echo '<title>Members - Vertification Sent</title>Your Membership information has been mailed to your email address, Check your email and follow the instructions to activate your account';
  89. }
  90. ?>
  • Cafu
  • Student
  • Student
  • Cafu
  • Posts: 97

Post 3+ Months Ago

Is there a standard response we should use when someone just posts a huge mess of code and says something like "what's wrong with it?"

The same thing is always wrong with it: the person trying to use it either has no idea what he is doing, or isn't willing to put in even a minimum amount effort to narrow down the problem so people can help.
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

Of couse it won't send the activate url in the email:

PHP Code: [ Select ]
 
 
 
$activateurl="http://www.ahazdesigns.com/activate.php?id=$userid&code=$db_password";
 
 
 
$message = "
 
Thank you for joining\n
 
Your User information:\n
 
Username: $username\n
 
Password: $random_password\n
 
Once you login you can change your password\n
 
Thanks\n
 
Admin";
 
 
 
 
  1.  
  2.  
  3.  
  4. $activateurl="http://www.ahazdesigns.com/activate.php?id=$userid&code=$db_password";
  5.  
  6.  
  7.  
  8. $message = "
  9.  
  10. Thank you for joining\n
  11.  
  12. Your User information:\n
  13.  
  14. Username: $username\n
  15.  
  16. Password: $random_password\n
  17.  
  18. Once you login you can change your password\n
  19.  
  20. Thanks\n
  21.  
  22. Admin";
  23.  
  24.  
  25.  
  26.  


You're not telling it to....

.c
[/code]
  • AHaz
  • Graduate
  • Graduate
  • User avatar
  • Posts: 144
  • Loc: New York

Post 3+ Months Ago

Quote:
Is there a standard response we should use when someone just posts a huge mess of code and says something like "what's wrong with it?"


ok i asked y it wouldnt send the activate url... but w/e

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 46 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.