devinruark Posted January 15, 2014 Share Posted January 15, 2014 Hello, I need help adding email confirmation to my signup script. Any help would be greatly appreciated. Here's the code include("scripts/mysql_connector.php"); //IMPORTANT STUFF$username = mysql_real_escape_string(stripslashes($_POST["strUsername"]));$password = mysql_real_escape_string(stripslashes($_POST["strPassword"]));$pass = md5($password);$age = mysql_real_escape_string(stripslashes($_POST["intAge"]));$dob = mysql_real_escape_string(stripslashes($_POST["strDOB"]));$email = mysql_real_escape_string(stripslashes($_POST["strEmail"]));$gender = mysql_real_escape_string(stripslashes($_POST["strGender"]));$classid = mysql_real_escape_string(stripslashes($_POST["ClassID"]));$eyecolor = mysql_real_escape_string(stripslashes($_POST["intColorEye"]));$skincolor = mysql_real_escape_string(stripslashes($_POST["intColorSkin"]));$haircolor = mysql_real_escape_string(stripslashes($_POST["intColorHair"]));$hairid = $_POST['HairID'];//Grabs IPif ($_SERVER['HTTP_X_FORWARD_FOR']) {$ip = $_SERVER['HTTP_X_FORWARD_FOR'];} else {$ip = $_SERVER['REMOTE_ADDR'];}//Checks if Email has Already been used$emailcheck = mysql_query("SELECT id FROM etl_users WHERE strEmail='$email'") or die("status=Error&strReason=" . mysql_error());if (mysql_num_rows($emailcheck) != 0) {die("status=Taken&strReason=The email is already in used by another user.");}//Checks If Username has been Taken$sql = mysql_query("SELECT * FROM etl_users WHERE strUsername = '$username'") or die("status=Error&strReason=" . mysql_error());if (mysql_num_rows($sql) !=0) {die("status=Taken&strReason=The username is already in use by another character.");} else {//Sets Hairname & hairfileswitch ($hairid) {//MALE HAIRcase 52:$hairname = 'Default';$hairfile = 'hair/M/Default.swf';break;case 55:$hairname = 'Goku1';$hairfile = 'hair/M/Goku1.swf';break;case 58:$hairname = 'Goku2';$hairfile = 'hair/M/Goku2.swf';break;case 64:$hairname = 'Normal2';$hairfile = 'hair/M/Normal2.swf';break;case 92:$hairname = 'Ponytail8';$hairfile = 'hair/M/Ponytail8.swf';break;//FEMALE HAIRcase 14:$hairname = 'Pig1Bangs1';$hairfile = 'hair/F/Pig1Bangs1.swf';break;case 18:$hairname = 'Pig2Bangs2';$hairfile = 'hair/F/Pig2Bangs2.swf';break;case 26:$hairname = 'Pony2Bangs2';$hairfile = 'hair/F/Pony2Bangs2.swf';break;case 83:$hairname = 'Bangs2Long';$hairfile = 'hair/F/Bangs2Long.swf';break;case 84:$hairname = 'Bangs3Long';$hairfile = 'hair/F/Bangs3Long.swf';break;}$regon = date("Y-m-d");//Inserts Character Info into DB$sql2 = mysql_query("INSERT INTO etl_users (realpw, strUsername, strPassword, strEmail, iAge, strGender, currentClass, strHairName, strHairFilename, intColorSkin, intColorHair, intColorEye, registered_ip, sHouseInfo, referredBy, registered_on, strQuests) VALUES ('$password', '$username', '$pass', '$email', '$age', '$gender','$classid','$hairname','$hairfile', '$skincolor', '$haircolor', '$eyecolor', '$ip', '', '', '$regon', '00000000000000000')") or die("status=Error&strReason=" . mysql_error());//Selects New User ID$sql3 = mysql_query("SELECT * FROM etl_users WHERE strUsername='$username'") or die("status=Error&strReason=" . mysql_error());$user = mysql_fetch_assoc($sql3) or die("status=Error&strReason=" . mysql_error());$user_id = $user['id'];//Add's Starting Armorswitch ($classid) {case 2: //Warrior$addarmour = mysql_query("INSERT INTO etl_users_items (item_id, user_id, bEquip, sES, iLvl, iCP) VALUES ('16', '$user_id', '1', 'ar', '1', '0')") or die("status=Error&strReason=" . mysql_error());break;case 4: //Ninja$addarmour = mysql_query("INSERT INTO etl_users_items (item_id, user_id, bEquip, sES, iLvl, iCP) VALUES ('16', '$user_id', '1', 'ar', '1', '0')") or die("status=Error&strReason=" . mysql_error());break;case 3: //Mage$addarmour = mysql_query("INSERT INTO etl_users_items (item_id, user_id, bEquip, sES, iLvl, iCP) VALUES ('16', '$user_id', '1', 'ar', '1', '0')") or die("status=Error&strReason=" . mysql_error());break;case 10: //Berserker$addarmour = mysql_query("INSERT INTO etl_users_items (item_id, user_id, bEquip, sES, iLvl, iCP) VALUES ('16', '$user_id', '1', 'ar', '1', '0')") or die("status=Error&strReason=" . mysql_error());break;}//Adds Default Weapon to User$addweapon = mysql_query("INSERT INTO etl_users_items (item_id, user_id, bEquip, sES, iLvl) VALUES ('1', '$user_id', '1', 'Weapon', '1')") or die("status=Error&strReason=" . mysql_error());//So The User Isn't Lonely$addfriends = mysql_query("INSERT INTO etl_users_friends (user_id) VALUES ('$user_id')") or die("status=Error&strReason=" . mysql_error());//SUCCESSecho "status=Success";} ?> Quote Link to comment Share on other sites More sharing options...
Skewled Posted January 15, 2014 Share Posted January 15, 2014 Linux or Windows, what mail program you using? Quote Link to comment Share on other sites More sharing options...
devinruark Posted January 15, 2014 Author Share Posted January 15, 2014 Windows 7. I'm not sure, I'm using xampp. Sorry I'm a bit of a php newbie lol. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted January 16, 2014 Share Posted January 16, 2014 what's your code where you attempted to add email confirmation to your existing script? help forums are not here to find or to write code for you. we are here to help you with code you have written. if you haven't attempted anything yet, you don't have anything which we can help you with. p.s. just about everything that can be done using php has been done. there are countless examples posted all over the place showing how to accomplish any particular task and sending an email from php is a very common task. p.p.s you need an actual mail server to send any email through. php alone cannot send mail, it's not a mail server. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted January 16, 2014 Share Posted January 16, 2014 here's a programming hint about writing out block after block of code that only differs in the value it produces. you need define data in an array (or a database table), then write general purpose code that will work regardless of how many different data values there are. this will allow you to add, change, or remove values by simply changing the data definition. your hair selection code would look like this - $hair_default = 52; $hair[52] = array('name'=>'Default','file'=>'hair/M/Default.swf'); $hair[55] = array('name'=>'Goku1','file'=>'hair/M/Goku1.swf'); // define the rest of the possible choices here... or simply store this information in a database table and retrieve it when you need it // input is $hairid if(!isset($hair[$hairid])){ $hairid = $hair_default; // if not one of the possible choices, use the default } $hairname = $hair[$hairid]['name']; $hairfile = $hair[$hairid]['file']; also, by having the data defined in an array (or database table), you can dynamically produce the menus used on your web pages by using that same data definition, and again you can add, change, or remove choices from the menu simply by changing the data definition. Quote Link to comment Share on other sites More sharing options...
devinruark Posted January 16, 2014 Author Share Posted January 16, 2014 I have tried, but it wouldn't work. I'm using Gmail to send the emails, and I'v coded a forgot password page that successfully sends the email so I'm sure it will work. I'm just not sure what I did wrong. Here's the full script with the failed verification script.cf-usersignup.php Quote Link to comment Share on other sites More sharing options...
devinruark Posted January 16, 2014 Author Share Posted January 16, 2014 Thanks for the Advice by the way. Changing it now. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted January 16, 2014 Share Posted January 16, 2014 in order to send an email through a gmail account to an arbitrary destination email address, you will need to use smtp authentication against that gmail account, which the php mail() function does not support. you would need to use one of the php mailer libraries (or write your own smtp command software.) Quote Link to comment Share on other sites More sharing options...
Solution devinruark Posted January 16, 2014 Author Solution Share Posted January 16, 2014 Thank you for your help, but I just got it working. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.