Click to See Complete Forum and Search --> : how to implement sending/receiving email for activating account on a website???


nickDeeSH
08-23-2007, 12:29 PM
Hi everybody,
I have just studied php for one month, so my knowledge of PHP is limited (sorry for my English ability). I hope someone who can help me solve my problem:

I am designing a web site, I allow users to register on my web site. When they register successfully, web site will send them an activation email. But I don't know how to do it. (I use: PHP, APACHE, now I also don't know that I should use which mail server that is good for php??)

flann
08-23-2007, 04:33 PM
The logic that I would use is:

In your users table, create a field called isValid tinyint not null default 0

Get the users information

Validate the user info

Insert into database

Get the ID associated with the user you just inserted (mysql_insert_id())

Encode the user ID using MD5() and put into a variable.

Compose your welcome email how ever you want it. In this email create a link to a page to handle the validating of the user and append the encoded ID in a get. .php?id=$md5var

Create the page to handle the validation of the user and get and sanitize the get variable.

update the isValid field to 1 where MD5(userID) = '$md5var'

Whenever you do a select, make sure you only select valid users.

nickDeeSH
08-24-2007, 02:08 AM
Thanks for your helping. Your writting makes me easy to understand. Thanks alot. Can u show me how to use md5 in php?

ripe
08-24-2007, 04:41 AM
<?php
$tocrypt = $_GET['id'];
if (!isset($tocrypt)){ echo 'no userid filled in link';}
//for above you say if mysql_num_rows(query where md5 userid=md5 $tocrypt) == 0 error msg ;
else { echo 'your crypted ID = '.md5($tocrypt); }
echo '<br />';
echo 'to test just use: http://pathtothis/file.php?id=ripe.ie';
?>
Hope it helps

flann
08-24-2007, 09:08 AM
Thanks for your helping. Your writting makes me easy to understand. Thanks alot. Can u show me how to use md5 in php?

md5 is a function that excepts a string and returns an encrypted version of that string. It is a trap door function, which means that you can't reverse it. When you're learning php, one of the best things you can do is to visit http://www.php.net and search there function list. There are thousands, if not more, functions built into php and knowing what is available will expand your abilities.


$var = "sometext";
$enc = md5($var);
// now $enc has an encrypted version of $var.


The md5 function is available in mysql as well and it use is the same.

nickDeeSH
08-26-2007, 01:27 AM
Yours helping is very useful for me. Thanks.