Jump to content

[SOLVED] user activation via email


runnerjp

Recommended Posts

."$url = 'http://www.runnerselite.com/website/activate.php?hash=".($usename)."$key";    this line is the problem tho as the key is being placed into the table...

 

i need it so that to activate chnageing 0 to 1 the user must click the link  with the key having to match the user id for this to work

and seb hughes show me what you mean by not useing () as i got told they must be in

 

Link to comment
Share on other sites

no i just got arse error: syntax error, unexpected T_VARIABLE in

 

but been thinking i could do it like this   

 

$url = "http://www.runnerselite.com/website/activate.php?hash="&key=$Key";

 

 

$code = $_GET['key'];

$query = "SELECT * FROM users WHERE key = $key";
$result = mysql_query($query) or die ("Error in query" . mysql_query());
$row = mysql_fetch_assoc($result);

if (mysql_num_rows($result) == 1)
{
$id = $row['username'];
$update = "UPDATE users SET status =1 WHERE username = '$username'";
mysql_query($update) or die ("Error in query" . mysql_query());
echo "Your account is now active";
header(location: where you need it to be forwarded to;
exit;
}
else
{
header(location: login page);
} 

 

Link to comment
Share on other sites

  function sendWelcome($user, $email, $pass){

      $from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";

      $subject = "Jpmaster77's Site - Welcome!";

      $body = $user.",\n\n"

            ."Welcome! You've just registered at Jpmaster77's Site "

            ."with the following information:\n\n"

            ."Username: ".$user."\n"

            ."Password: ".$pass."\n\n"           

            $Key = key();

$url = "http://www.runnerselite.com/website/activate.php?hash=".md5($userid)."&key=$Key";

 

      return mail($email,$subject,$body,$from);

  }

 

 

here is the whole email script!

Link to comment
Share on other sites

<?php

   function sendWelcome($user, $email, $pass){
      $from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
      $subject = "Jpmaster77's Site - Welcome!";
      $body = $user.",\n\n";
             ."Welcome! You've just registered at Jpmaster77's Site ";
             ."with the following information:\n\n";
             ."Username: ".$user."\n";
             ."Password: ".$pass."\n\n";           
             $Key = key();
$url = "http://www.runnerselite.com/website/activate.php?hash=".md5($userid)."&key=$Key";

      return mail($email,$subject,$body,$from);
   }

?>

Link to comment
Share on other sites

ok im going to show the WHOLE of the script

 

function randomkeys($length){
$pattern="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
for($i=0; $i<$length; $i++) $key.=$pattern{rand(0,61)};
return $key;
}
function addNewUser($username, $password, $email){
$time=time();
if(strcasecmp($username, ADMIN_NAME) == 0) $ulevel=ADMIN_LEVEL;
else $ulevel=USER_LEVEL;
$key=$this->randomkeys(30);
$status = 0;
$q="INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '0', $ulevel, '$email', $time, $status,'$key')";
$result = mysql_query($q, $this->connection) or die(mysql_error());
return $result;
}

here the random key is made... so surly the function should be key

 

 

then once that is added and email is sent

<?php

   function sendWelcome($user, $email, $pass){
      $from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
      $subject = "Jpmaster77's Site - Welcome!";
      $body = $user.",\n\n";
             ."Welcome! You've just registered at Jpmaster77's Site ";
             ."with the following information:\n\n";
             ."Username: ".$user."\n";
             ."Password: ".$pass."\n\n";           
             $Key = key();
$url = "http://www.runnerselite.com/website/activate.php?hash="&key=$Key";

      return mail($email,$subject,$body,$from);
   }

?>

at the moment this code does not work as i think its because of all the ;

 

 

then once the email has been sent it goes to activiate.php where

$code = $_GET['key'];

 

$query = "SELECT * FROM users WHERE key = $key";

$result = mysql_query($query) or die ("Error in query" . mysql_query());

$row = mysql_fetch_assoc($result);

 

if (mysql_num_rows($result) == 1)

{

$id = $row['username'];

$update = "UPDATE users SET status =1 WHERE username = '$username'";

mysql_query($update) or die ("Error in query" . mysql_query());

echo "Your account is now active";

header(location: where you need it to be forwarded to;

exit;

}

else

{

header(location: login page);

}

 

is done!!

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.