Jump to content
MakeWebGames

Email activation.


DAMINK

Recommended Posts

I setup email activation on my game. Mostly works hahaha. Anyway my problem is this.....

My activation email sends just fine but does not show the from address properly. It shows www-data as the From address.

I can change that to show my from address but when i do that my email gets sent without html.

Like this will not show the from address but the html works fine.

           $emailSubject = "BLAH";
           $headers = "MIME-Version: 1.0";
           $headers = "Content-Type: text/html; charset=ISO-8859-1";
    $from = "From: MY EMAIL";
           $emailBody = "<html><body><h2>BLAH</h2></body></html>";

mail($registerEmail, $emailSubject, $emailBody, $headers, $from);

 

Reading up there is a order i believe i am supposed to do this. From being the 4th? So i tried this.

 

           $emailSubject = "BLAH";
           $headers = "MIME-Version: 1.0";
           $headers = "Content-Type: text/html; charset=ISO-8859-1";
    $from = "From: MY EMAIL";
           $emailBody = "<html><body><h2>BLAH</h2></body></html>";

mail($registerEmail, $emailSubject, $emailBody, $from, $headers);

 

I also tried addind another header like $header = "From: MY EMAIL" and still no joy hahahaah.

So if anyone knows what i am doing wrong here i would appreciate the help.

While i am at it :) Might ask another question sort of related to the email activation.

Here is the important code that relates to activating the account.

   $activateCode = $_GET["activateCode"];
   $user = $_GET["user"];
$activate = mysql_query("UPDATE `grpgusers` SET `verified` = `1` WHERE `activateCode` = '$activateCode' AND `user` = 'user_class->username'");

Here is a link example supplied in email.

http://www.domain.com/activate.php?activateCode=81966357&user=test

I can confirm the code is accurate as is the user however it does not set verified to 1?

Edited by DAMINK
Link to comment
Share on other sites

While i am at it :) Might ask another question sort of related to the email activation.

Here is the important code that relates to activating the account.

   $activateCode = $_GET["activateCode"];
   $user = $_GET["user"];
$activate = mysql_query("UPDATE `grpgusers` SET `verified` = `1` WHERE `activateCode` = '$activateCode' AND `user` = 'user_class->username'");

Here is a link example supplied in email.

http://www.domain.com/activate.php?activateCode=81966357&user=test

I can confirm the code is accurate as is the user however it does not set verified to 1?

   $activateCode = $_GET["activateCode"];
   $user = $_GET["user"];
$activate = mysql_query("UPDATE `grpgusers` SET `verified` = `1` WHERE `activateCode` = '$activateCode' AND `username` = 'user_class->username'");

are you sure that the Colum name is user within the database? On my copy of GRPG it uses username instead of user

Link to comment
Share on other sites

Your correct Adamhull. The column is username not user however it still fails sadly.

Not sure why i had that set to user to be honest. Must have been the point i was at screwing around with it at that point.

However i was able to get the activation to work. Here is the modified code i used to get it to work.

$activate = mysql_query("UPDATE `grpgusers` SET `verified` = '1' WHERE `activateCode` = '$activateCode' AND `username` = '$user'");

 

Now for me to get the actual email to send properly and this is all done.

Edited by DAMINK
Link to comment
Share on other sites

$registerEmail

 

where is this variable? in mine its called $email and up in the code i have this

 

$email = $_POST['email'];

 

EDIT:

there is also a few edits i would make

1. if your activation code is just numbers then change

$activateCode = $_GET["activateCode"];

to

$activateCode = isset($_GET["activateCode"]) && ctype_digit($_GET["activateCode"]) ? abs(intval($_GET["activateCode"])) : null;
if(empty($_GET['activateCode'])) {
  echo "Invalid code";
  exit;
}

 

2. Change

$user = $_GET["user"];

to

$user = isset($_GET["user"]) && ctype_digit($_GET["user"]) ? abs(intval($_GET["user"])) : null;
if(empty($_GET["user"])) {
  echo "Invalid User";
  exit;
}

 

3. also this to validate the email address (if your using a different email variable then change $email to your email var)

if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
   echo "The e-mail address you entered was invalid.";
}

 

also i noticed that you used $user = $_GET['user']; but never actually used it

Edited by NonStopCoding
Link to comment
Share on other sites

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.   Paste as plain text instead

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