Modernvox Posted February 28, 2010 Share Posted February 28, 2010 Spent too many hours on this as it is, so I am reaching out for assistance. Somewhere in my code there is a statement causing the sending of email to the user to fail? YOUR help greatly appreciated on this matter <?php if (!$_POST['submit'] || !$_POST['name'] || !$_POST['state'] || !$_POST['city'] || !$_POST['email'] || !$_POST['username'] || !$_POST['password'] || !$_POST['confirm_password'] ) { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" name= "register" method= "post"> <tr><td><font face= "arial" size= "2" color= "red">       All fields required</font></td></tr><center><table> <tr> <td><b><font face= "arial" size= "3">FULL NAME</font></b></td> <td><input type= "text" name= "name" size= "40" /></td> </tr> <tr> <td><b><font face= "arial" size= "3">CITY</font></b></td> <td><input type= "text" name= "city" size= "30" /></td> </tr> <tr> <td><b><font face= "arial" size= "3">STATE</font></b></td> <td><input type= "text" name= "state" size= "2" /></td> </tr> <tr> <td><b><font face= "arial" size= "3">USERNAME</font></b></td> <td><input type= "text" name= "username" size= "25" /></td> </tr> <tr> <td><b><font face= "arial" size= "3">PASSWORD</font></b></td> <td><input type= "password" name= "password" size= "25" /></td> </tr> <tr> <td><b><font face= "arial" size= "3">CONFIRM PASSWORD</font></b></td> <td><input type= "password" name= "confirm_password" size= "25" /></td> </tr> <tr> <td><b><font face= "arial" size= "3">EMAIL</font></b></td> <td><input type= "text" name= "email" size= "35" /></td> </tr> <tr> <td><input type="hidden" name="form_submitted" value="1"/></td> </tr> </table></center> <br><center><input type="submit" value= "Register" name="submit" /></center> </form> <?php } else { $name= $_POST['name']; $state= $_POST['state']; $city= $_POST['city']; $email= $_POST['email']; $username= $_POST['username']; $password= $_POST['password']; $confirm_password= $_POST['confirm_password']; $errorlist= array(); if (strlen($username) > 20 || strlen($username) <5){ $errorlist[] = "ERROR: <font face= \"tahoma\" color= \"red\" size= \"2\">Username must be between 5 and 25 characters long.</font>"; } if($password != $confirm_password){ $errorlist[] = "ERROR:<font face= \"tahoma\" color= \"red\" size= \"2\">Your passwords don't match, try again</font>"; } if ($password == "" || strlen($password) <{ $errorlist[] = "ERROR: <font face= \"tahoma\" color= \"red\" size= \"2\">Password must be at least 8 characters long.</font>"; } $pattern = '/^[a-z0-9]{4,}+.?([a-z0-9]+)?@([gmail]+\.)+[a-z]{3,4$/i'; //exclude Gmail here if (preg_match($pattern, $email)){ $errorlist[] = "ERROR: <font face= \"tahoma\" color= \"red\" size= \"2\">Sorry, Gmail accounts not allowed</font>"; } $pattern = '/^[a-z0-9]{4,}+.?([a-z0-9]+)?@([a-z0-9]+\.)+[a-z]{3,4}$/i'; if (!preg_match($pattern, $email)) { $errorlist[] = "ERROR: <font face= \"tahoma\" color= \"red\" size= \"2\">That's not a valid email</font>"; } if (sizeof($errorlist) > 0) { echo "Please review and correct the following errors: <br/>"; foreach ($errorlist as $e) { echo "$e <br/>"; } } else { if (Form_submitted == "1") { $activationKey = mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand(); include("configclass.php"); $conn = mysql_connect($host, $dbuser, $password); if (!$conn) { die('Could not connect: ' . mysql_error()); } mysql_select_db($dbname, $conn); if (!get_magic_quotes_gpc()) { $username = addslashes($username); } $usercheck = $username; $check = mysql_query("SELECT username FROM members WHERE username = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) { die('Sorry, the username '.$username.' is already in use.'); } //creates a 3 character sequence function createSalt() { $string = md5(uniqid(rand(), true)); return substr($string, 0, 3); } $salt = createSalt(); $hash = sha1($salt . $hash); $hash = sha1($password); //sanitize username $username = mysql_real_escape_string($username); $query = "INSERT INTO members ( name, city, state, username, password, email, activationkey, status ) VALUES ( '$name', '$city', '$state', '$username', '$password', '$email', '$activationKey', '$verify' )"; mysql_query($query); if (!empty($query)) { echo "An email has been sent to $email . Please click on the verification link to register your new account"; //Send activation Email $to = $email; $subject = " I Wanna JAM! Registration"; $message = "Verify your registration by clicking the following link:\rhttp://dezi9er.net16.net/process_registration.php?$activationKey\r\rRegards, I Wanna JAM! Team"; $headers = 'From: noreply@ IWannaJAM.com' . "\r\n" . 'Reply-To: noreply@ IWannaJAM.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); } else { echo "nothing here"; $queryString = $_SERVER['QUERY_STRING']; $query = "SELECT * FROM members"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ if ($queryString == $row["activationkey"]){ echo "Thank You! Your registration has been verified and is now active. Welcome aboard! "; $sql="UPDATE members SET activationkey = '', status='activated' WHERE (id = $row[id])"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } mysql_close(); } } } } } } ?> Link to comment https://forums.phpfreaks.com/topic/193621-someone-save-me-if-you-will/ Share on other sites More sharing options...
Modernvox Posted February 28, 2010 Author Share Posted February 28, 2010 I should say NO values are being entered into DB Link to comment https://forums.phpfreaks.com/topic/193621-someone-save-me-if-you-will/#findComment-1019216 Share on other sites More sharing options...
seventheyejosh Posted February 28, 2010 Share Posted February 28, 2010 What error are you getting? If that is your whole script and you don't have errors enabled, try pasting this at the top of your script and see what it says ini_set('display_errors', 1); error_reporting(E_ALL); Link to comment https://forums.phpfreaks.com/topic/193621-someone-save-me-if-you-will/#findComment-1019218 Share on other sites More sharing options...
jcanker Posted February 28, 2010 Share Posted February 28, 2010 There's a bit here that I've not seen used before, like putting an include 1/2 way through the script in an if statement... and here: if (Form_submitted == "1") , I think you mean $Form_submitted (or $_POST['Form_submitted'] or $_Get['form_submitted'] depending on your php.ini settings and the form config...) Also, if you change mysql_query($query) to $result = mysql_query($query) then you can also perform $result = mysql_errno($result) to get any errors that may be resulting from the mysql db entry attempt. Just for this code, I'd also insert a few echo statements in each of the if & else loops, such as "Right now we're entering the if(state conditions) loop. You can take them out once you figure out the problem, but this helps you see exactly where the program is executing.... Link to comment https://forums.phpfreaks.com/topic/193621-someone-save-me-if-you-will/#findComment-1019225 Share on other sites More sharing options...
Modernvox Posted February 28, 2010 Author Share Posted February 28, 2010 There's a bit here that I've not seen used before, like putting an include 1/2 way through the script in an if statement... and here: if (Form_submitted == "1") , I think you mean $Form_submitted (or $_POST['Form_submitted'] or $_Get['form_submitted'] depending on your php.ini settings and the form config...) Also, if you change mysql_query($query) to $result = mysql_query($query) then you can also perform $result = mysql_errno($result) to get any errors that may be resulting from the mysql db entry attempt. Just for this code, I'd also insert a few echo statements in each of the if & else loops, such as "Right now we're entering the if(state conditions) loop. You can take them out once you figure out the problem, but this helps you see exactly where the program is executing.... Oh Man, that's right $_POST['form_submitted'] good eye, good eye Link to comment https://forums.phpfreaks.com/topic/193621-someone-save-me-if-you-will/#findComment-1019227 Share on other sites More sharing options...
Modernvox Posted February 28, 2010 Author Share Posted February 28, 2010 Now.....Undefined index: Form_submitted Link to comment https://forums.phpfreaks.com/topic/193621-someone-save-me-if-you-will/#findComment-1019231 Share on other sites More sharing options...
jcanker Posted February 28, 2010 Share Posted February 28, 2010 is the form POST or GET? Make sure you've named it exactly as the submit button is named and that the value of the submit button is "1" and not "submit" since your code is expecting it to ==1. Link to comment https://forums.phpfreaks.com/topic/193621-someone-save-me-if-you-will/#findComment-1019232 Share on other sites More sharing options...
Modernvox Posted February 28, 2010 Author Share Posted February 28, 2010 is the form POST or GET? Make sure you've named it exactly as the submit button is named and that the value of the submit button is "1" and not "submit" since your code is expecting it to ==1. Had Form_submitted instead of form_submitted Thanks brother. Link to comment https://forums.phpfreaks.com/topic/193621-someone-save-me-if-you-will/#findComment-1019237 Share on other sites More sharing options...
jcanker Posted February 28, 2010 Share Posted February 28, 2010 NP...I hope everything works now Link to comment https://forums.phpfreaks.com/topic/193621-someone-save-me-if-you-will/#findComment-1019238 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.