how to validate user by sending email link or code on email

Started on the old forum in January 2012 · view the original in the archive · old links redirect here

37 replies · 2,127 views · started 14 years ago · 1 min read

TL;DR · summary of 37 replies
  • - The user was asked how to validate a user by sending an email link or code.
  • - A basic solution using PHP and MySQL was proposed, including generating a random string, saving it in a database, and sending an email with a URL containing the key.
  • - The thread participants discussed adding more advanced features like checking if the email is activated, modifying registration and login scripts to integrate this functionality, and handling errors such as missing } o...
  • - The issue of not receiving emails was also addressed by ensuring proper use of mail() function and verifying that the database connection works correctly.

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

6 participants
ewanz Developer · 187 posts #21

Try it br0 and give the feedback until the next step to verify.. I don't check all your code... just continue modified and add some part😁

our lfe is simple words.... 😌 http://mygenkz.net ewanz06@yahoo.com

$output="i am NOoob....";
$newfile="ewanz.txt";
$file = fopen ($newfile, "w");
fwrite($file, $output);
fclose ($file); 
mirror Developer · 108 posts #22

problem with header on this line 90 header("Location: verify.php");

Warning: Cannot modify header information - headers already sent by (output started at /home//public_html/1234/login.php:25) in /home/*****/public_html/1234/login.php on line 90

ohh one more problem using this password:$pwd in email gets blank paswd in email

ozziemale31 Lead · 861 posts #23

usually a error saying unexpected $end is just a missing open or close statement of a function ie: for every { u must have a closing }

Added after 5 minutes:

change your core here in registration $body = "Date: $ddt - Account Detail\n\n Hello $name,\n\nYour new account is setup you can login with login name:$name and password:$epwd\n\nIn case you can validate yourself by this code : ".$vcode[0]."";

and register php change also i have a extra field on users table called pass2 to save the pwd unencrypted

if ($logit) {
 $epwd = md5(strtolower($pwd));
$usid = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE name='".$uid."' AND pass='".$epwd."'"));
mysql_query("INSERT INTO ibwf_users SET name='".getnick_uid($usid[0])."', pass2='".$pwd."'");

echo "<p><b>Registration completed successfully!!</b><br/>";
 echo "<i><b>Username:</b> $uid</i><br/>";
 echo "<i><b>Password:</b> $pwd</i><br/>";
 echo "<i><b>E-Mail:</b> $email</i><br/>";
echo "<br/>You may login now. <a

href=\"login.php?loguid=$uid&logpwd=$pwd\">Click here</a> to login.</p>";

}

External image (may be gone) External image (may be gone)

External image (may be gone)

*****

**Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer.. Want A Profesional Logo or Theme For Your wap site Pm Me.If I Have The Time Ill Make It For Free ***

razzbee Developer · 130 posts #24

mirror wrote: problem with header on this line 90 header("Location: verify.php");

Warning: Cannot modify header information - headers already sent by (output started at /home//public_html/1234/login.php:25) in /home/*****/public_html/1234/login.php on line 90

ohh one more problem using this password:$pwd in email gets blank paswd in email

add this after <?php tag in the script

ob_start();
ozziemale31 Lead · 861 posts #25

or simply just remove the header the error is becus the header has already been declared

i used this and it verifies 😛

<?php

include 'config.php';

$code = $_GET['code'];
if (!$code)
    echo "No code supplied";
else
{
    $check = mysql_query("SELECT * FROM ibwf_users WHERE code='$code' AND active='1'");
    if (mysql_num_rows($check)==1)
        echo "You have already activated your account";
    else
    {
        $activate = mysql_query("UPDATE ibwf_users SET active='1' WHERE code='$code'");
        echo "Your account has been activated!";
    }

}

?>

External image (may be gone) External image (may be gone)

External image (may be gone)

*****

**Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer.. Want A Profesional Logo or Theme For Your wap site Pm Me.If I Have The Time Ill Make It For Free ***

ewanz Developer · 187 posts #26

mirror wrote: problem with header on this line 90 header("Location: verify.php");

Warning: Cannot modify header information - headers already sent by (output started at /home//public_html/1234/login.php:25) in /home/*****/public_html/1234/login.php on line 90

ohh one more problem using this password:$pwd in email gets blank paswd in email

not $pwd, i have post before change to $epwd in your core... verify.php problem header.. do u have include already verify.php in your core.php or config.php? if does, change header("Location: verify.php"); to header("Location: validate.php");

our lfe is simple words.... 😌 http://mygenkz.net ewanz06@yahoo.com

$output="i am NOoob....";
$newfile="ewanz.txt";
$file = fopen ($newfile, "w");
fwrite($file, $output);
fclose ($file); 
mirror Developer · 108 posts #27

ewanz wrote: not $pwd, i have post before change to $epwd in your core... verify.php problem header.. do u have include already verify.php in your core.php or config.php? if does, change header("Location: verify.php"); to header("Location: validate.php");

nope , i had a file named verify.php okay changed to validate.php now , okay changed it to validate.php checking now..................

still same problem

Added after 5 minutes:

ozziemale31 wrote: or simply just remove the header the error is becus the header has already been declared

i used this and it verifies 😛

<?php



include 'config.php';

$code = $_GET['code'];
if (!$code)
    echo "No code supplied";
else
{
    $check = mysql_query("SELECT * FROM ibwf_users WHERE code='$code' AND active='1'");
    if (mysql_num_rows($check)==1)
        echo "You have already activated your account";
    else
    {
        $activate = mysql_query("UPDATE ibwf_users SET active='1' WHERE code='$code'");
        echo "Your account has been activated!";
    }

}


?>

ozzie bro after entering id n paswd in login.php after clicking login i m getting tht header problem

ewanz Developer · 187 posts #28

ohw,,, i see.. now.. i will code other methods for u.. not use header to other page... 🪆🪆🪆🪆

our lfe is simple words.... 😌 http://mygenkz.net ewanz06@yahoo.com

$output="i am NOoob....";
$newfile="ewanz.txt";
$file = fopen ($newfile, "w");
fwrite($file, $output);
fclose ($file); 
mirror Developer · 108 posts #29

ewanz wrote: ohw,,, i see.. now.. i will code other methods for u.. not use header to other page... 🪆🪆🪆🪆

okay bro,the main motive behind all this coding is to check if the user is genuine or not and to stop fake multiple ids.

can we just modify it a little like sending randomly generated paswd , (removing paswd fields while registering ) in email , if email n user is genuine he will surely check email n use tht paswd

secondly or by ur method using verify.php or validate.php entering activation code to actiavte

mirror Developer · 108 posts #30

hey bro i think we can make use of ozzies verify.php by making the link in email clickable like

you can validate yourself by this code Http://******.net/activate.php?vcode=".$vcode[0]."";

here s the verify.php

<?php
include("config.php");
include("core.php");
$bcon = connectdb();
$vcode =($_GET['vcode']);
echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.2//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd\">");
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Activating Acount</title>
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Cache-Control" content="must-revalidate"/>
<?php
echo gettheme($sid);
?>
</head>
<body>
<?php
if (!$bcon){
echo "<p style=\"text-align: center\">";
echo "<img src=\"images/exit.gif\" alt=\"*\"/><br/>";
echo "ERROR! Couldn't connect to database<br/><br/>";
echo "Please try after some time.<br/><br/>";
echo "Thanks!<br/>";
echo "</p>";
echo "</body>";
echo "</html>";
exit();
}

$vcode = $_GET['vcode'];
if (!$vcode)
    echo "No code supplied";
else
{
    $check = mysql_query("SELECT * FROM ibwf_users WHERE vcode='$vcode' AND active='1'");
    if (mysql_num_rows($check)==1)
        echo "You have already activated your account";
    else
    {
        $activate = mysql_query("UPDATE ibwf_users SET validrqd='0' WHERE vcode='$vcode'");
        echo "Your account has been activated!";
    }

}

?>

ITS WORKING but something wrong , but why is it still working , this active field i have in my table is by defaullt 0

ewanz Developer · 187 posts #31

whats u mean? there have many skill u can use my code and ozzie.. just did it and try by try.. i think u had got the chlue 8)

Added after 4 minutes:

$vcode = $_GET['vcode'];
if (!$vcode)
    echo "No code supplied";
else
{
    $check = mysql_query("SELECT * FROM ibwf_users WHERE vcode='$vcode' AND vstatus='1'");
    if (mysql_num_rows($check)==1)
        echo "You have already activated your account";
    else
    {
        $activate = mysql_query("UPDATE ibwf_users SET vstatus='1' WHERE vcode='$vcode'");
        echo "Your account has been activated!";
    }

}

insert the row sql i posted before 0r use your own

Added after 5 minutes:

there have many ideas you can use,, i think the simple one u can use the code above by validate through by link in email ...my suggestion that it is smart after activated/validated users redirect to login than no need to enter password and username... just by link...

What's your sitename mirror?

our lfe is simple words.... 😌 http://mygenkz.net ewanz06@yahoo.com

$output="i am NOoob....";
$newfile="ewanz.txt";
$file = fopen ($newfile, "w");
fwrite($file, $output);
fclose ($file); 
mirror Developer · 108 posts #33

ozziemale31 wrote: what would be kool make it so if a user hasnt logged in for 3 months their activation code expires requiring them to request a new one

hey bro one thing i forgot what abt if the user wants to RESEND THE ACTIVATION EMAIL , blah all this mods will really create a revolution for lavalair

ewanz Developer · 187 posts #34

ozziemale31 wrote: what would be kool make it so if a user hasnt logged in for 3 months their activation code expires requiring them to request a new one

yeah..absolutely cool... it is good idea...

Added after 2 minutes:

mirror wrote: hey bro one thing i forgot what abt if the user wants to RESEND THE ACTIVATION EMAIL , blah all this mods will really create a revolution for lavalair

just use a code like had before, it is simple but good idea too..

our lfe is simple words.... 😌 http://mygenkz.net ewanz06@yahoo.com

$output="i am NOoob....";
$newfile="ewanz.txt";
$file = fopen ($newfile, "w");
fwrite($file, $output);
fclose ($file); 
ozziemale31 Lead · 861 posts #35

i keep getting an encrypted password mate tried different ways

Your new account is setup you can login with login name:rampage and password:d41d8cd98f00b204e9800998ecf8427e

In case you can validate yourself by this code : 65747331

below is my register function in core

function register($name,$pass,$usex,$bday,$uloc,$rname,$ms,$email,$code){
  $execms = mysql_query("SELECT * FROM ibwf_users WHERE name='".$name."';");
  if (mysql_num_rows($execms)>0){ return 1; }else
  { $pass = md5(strtolower($pass));
  $reg = mysql_query("INSERT INTO ibwf_users SET name='".$name."', pass='".$pass."', birthday='".$bday."', sex='".$usex."', location='".$uloc."', regdate='".time()."',  email='".$email."', rname='".$rname."',vcode='".$code."', ms='".$ms."' ");
  } if
  ($reg)
  {
    $pwd = md5(strtolower($pwd));
    $subject = "******";
  $headers = "From:****@gmail.com";
  $time = time();
  $ddt = date("M d y", $time);
  $vcode = mysql_fetch_array(mysql_query("SELECT vcode FROM ibwf_users WHERE name='".$name."'"));

  $epwd = md5(strtolower($pwd));
$uinf = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE name='".$uid."' AND pass='".$epwd."'"));
  $body = "Date: $ddt - Account Detail\n\n Hello $name,\n\nYour new account is setup you can login with login name:$name and password:$pwd\n\nIn case you can validate yourself by this code : ".$vcode[0]."";
  mail($email, $subject, $headers, $body);$uid = mysql_fetch_array(mysql_query("SELECT id FROM ibwf_users WHERE name='".$name."'"));
  $body = "****** welcomes you! We are committed to provide you with unique services, like multimedia messaging, multiplayer online games and lots of other various tools for you to have  fun. We know that you come to WAP after getting time from your busy schedule so we are always ready hear to provide you a friendly and fun filled environment to ease your tensions. For any queries please ask any member of Administration Team. Thanks![br/][small]Note: This is an automatically generated message, please do not reply.[/small]";
  $msg = mysql_escape_string($msg); autopm($msg, $uid[0]); return 0;
   }
   }

External image (may be gone) External image (may be gone)

External image (may be gone)

*****

**Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer.. Want A Profesional Logo or Theme For Your wap site Pm Me.If I Have The Time Ill Make It For Free ***

mirror Developer · 108 posts #36

ozziemale31 wrote: i keep getting an encrypted password mate tried different ways

Your new account is setup you can login with login name:rampage and password:d41d8cd98f00b204e9800998ecf8427e

In case you can validate yourself by this code : 65747331

below is my register function in core

function register($name,$pass,$usex,$bday,$uloc,$rname,$ms,$email,$code){
  $execms = mysql_query("SELECT * FROM ibwf_users WHERE name='".$name."';");
  if (mysql_num_rows($execms)>0){ return 1; }else
  { $pass = md5(strtolower($pass));
  $reg = mysql_query("INSERT INTO ibwf_users SET name='".$name."', pass='".$pass."', birthday='".$bday."', sex='".$usex."', location='".$uloc."', regdate='".time()."',  email='".$email."', rname='".$rname."',vcode='".$code."', ms='".$ms."' ");
  } if
  ($reg)
  {
    $pwd = md5(strtolower($pwd));
    $subject = "******";
  $headers = "From:****@gmail.com";
  $time = time();
  $ddt = date("M d y", $time);
  $vcode = mysql_fetch_array(mysql_query("SELECT vcode FROM ibwf_users WHERE name='".$name."'"));

  $epwd = md5(strtolower($pwd));
$uinf = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users WHERE name='".$uid."' AND pass='".$epwd."'"));
  $body = "Date: $ddt - Account Detail\n\n Hello $name,\n\nYour new account is setup you can login with login name:$name and password:$pwd\n\nIn case you can validate yourself by this code : ".$vcode[0]."";
  mail($email, $subject, $headers, $body);$uid = mysql_fetch_array(mysql_query("SELECT id FROM ibwf_users WHERE name='".$name."'"));
  $body = "****** welcomes you! We are committed to provide you with unique services, like multimedia messaging, multiplayer online games and lots of other various tools for you to have  fun. We know that you come to WAP after getting time from your busy schedule so we are always ready hear to provide you a friendly and fun filled environment to ease your tensions. For any queries please ask any member of Administration Team. Thanks![br/][small]Note: This is an automatically generated message, please do not reply.[/small]";
  $msg = mysql_escape_string($msg); autopm($msg, $uid[0]); return 0;
   }
   }

ya i also faced the same problem so resorted to validation by clicking link using verify.php

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close