Login/ Register With Email- Save Database

social media

Save Data Into MySQL Table :

<?php
include("connection.php");

if($_GET['register']=='true'){
if ($_POST["captcha"] != $_SESSION['security_code'] or 
empty($_SESSION['security_code'])) 
{
$str="ERROR: Incorrect verification code!";
header("Location:register.php?msg=$str");
}
else
{
$fname = mysql_real_escape_string($_POST['fname']);
$lname = mysql_real_escape_string($_POST['lname']);
$email = mysql_real_escape_string($_POST['email']);
$password = mysql_real_escape_string(md5($_POST['password']));
$status = 'inactive';

mysql_query("insert into register set fname = '".$fname."',
lname = '".$lname."',
email = '".$email."',
password = '".$password."',
status = '".$status."'");
$iduser = mysql_insert_id();

/* You can write your activation mail program here */
/* Or You can redirect user to My account Page */
$str="Welcome to A2Z webhelp";
header("Location:welcome.php?msg=$str");
}
}

?>

Here we have used MD5 encoding to protect password. You can use any other password encoding options available in PHP.
If you doesn't want user's email verification then you can make $status='active' and send the user to my account page.

Send Activation Mail to User:

$to = $email;
$from = "info@a2zwebhelp.com";
$subject = "Activate your Account";
$message = "<a href='http://www.a2zwebhelp.com/activete.php?email=".$email."'>
Click here</a> to activate your account.";

$headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=utf-8\r\n";
$headers .= "From: \"" . $from . "\" \r\n";
$headers .= "Reply-To: " . $to . "\r\n";
$message = utf8_decode($message);

mail($to, $subject, $message, $headers);

Create your activete.php file:

<?php
include("connection.php");

if($_GET['email']){
$email = mysql_real_escape_string($_GET['email']);
mysql_query("update register set status='active' where 
email='".$email."' and status='inactive'");
$str="Welcome to A2Z webhelp";
header("Location:welcome.php?msg=$str");
}
?>

Now you can create your login.php file.


Comments
14 February
2014
ctel
nice
13 February
2014
Mukesh Kumar
How do i connect the mysql data base connectivity to any php form.
Please i should be code, please urgent sir....
06 February
2014
annie
I was seriously searching in the net on how to create a simple registration form eventhough it seems to be very simple it is definitely a tedious task and you have made me an expert in this filed.Well donehttp://www.powered.com/
23 January
2014
sundari
how do i compare the values in registration table likely username password, to check the login table both of them match and then print the message. please give a coding in php.
05 January
2014
Satyam upadhyay
nice
05 November
2013
James Dean
Where does the code for saving the data into mysql table go. Is it in the registration form?
22 January
2014
Ali
I would like the answer to that question as well--.
comments powered by Disqus