Jump to content

adding a email verification to my register script


chris_s_22

Recommended Posts

im at the point of creating a email confirmation that when a person recieves the email and clicks on the link it directs them to conformationcheck.php

 

<?
include('config.php');

// Passkey that got from link 
$passkey=$_GET['passkey'];

// Retrieve data from table where row that match this passkey 
$sql1="SELECT * FROM user WHERE confirm_code ='$passkey'";
$result1=mysql_query($sql1);

// If successfully queried 
if($result1){

// Count how many row has this passkey
$count=mysql_num_rows($result1);

// if found this passkey in our database
if($count==1){
????

// Insert data  
$sql2="INSERT INTO user(registered)VALUES('$registered')";
$result2=mysql_query($sql2);
}

// if not found passkey, display message "Wrong Confirmation code" 
else {
header('Location: http://www.pinkangel4u.com/truthdare/conformation.php');
}

// if successfully inserted 
if($result2){

header('Location: http://www.pinkangel4u.com/truthdare/loginregister.php');

// Delete information in the confirmcode feild
$sql3="DELETE FROM user WHERE confirm_code = '$passkey'";
$result3=mysql_query($sql3);
}
}
?>

 

not sure want to add after if($count==1){

want i want this script to do firstly to get passkey from email then check it against my database, if found then insert "activated" into the registered feild in my database table.

i then want it to only delete and clear the confirmcode feild in my database feild think at the moment if deletes the whole record or that person registered

Link to comment
Share on other sites

You would want to run an UPDATE not an insert:

 

// Insert data 
$sql2="UPDATE user SET registered = '1'";
$result2=mysql_query($sql2)

 

Make sure the register column is an int and if it is 0 the user is not registered if it is 1 the user is valid and allowed.

Link to comment
Share on other sites

As an aside, if you just want to ascertain whether or not the value exists in the database, it is far more efficient to perform a query that selects a count, rather than returning all rows and using the php mysql_num_rows() function. For example:

 

$sql = "SELECT COUNT(*) FROM user WHERE confirm_code ='$passkey'";
$result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR);
if(mysql_result($result,0) == 1){
    //code found
}

 

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.