Jump to content

Adding email confirmation to my php script


devinruark
Go to solution Solved by devinruark,

Recommended Posts

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 IP
if ($_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 & hairfile
switch ($hairid) {
//MALE HAIR
case 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 HAIR
case 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 Armor
switch ($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());

//SUCCESS
echo "status=Success";
}

?> 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.