Trying to create a registration page...but i notice that Data is being sent to database on page load. I would like this to happen when the user click on Register button. What am i doing wrong...any solotion please?
My database is below and code is also below:
<?php require_once('Connections/bankusers.php'); ?>
<?php
// table name
$tbl_name=temp_users_db;
// Random confirmation code
$confirm_code=md5(uniqid(rand()));
// values sent from form
$Address=$_POST['Address'];
$FirstName=$_POST['FirstName'];
$LastName=$_POST['LastName'];
$Email=$_POST['Email'];
$UserName=$_POST['UserName'];
// Insert data into database
$sql="INSERT INTO $tbl_name(confirm_code,Address, FirstName,LastName,Email,UserName,Password)VALUES('$confirm_code','$Address','$FirstName','$LastName','$Email', '$UserName', '$Password')";
mysql_select_db($database_bankusers, $bankusers);
$result=mysql_query($sql);
// if suceesfully inserted data into database, send confirmation link to email
if($result){
// ---------------- SEND MAIL FORM ----------------
// send e-mail to ...
$to=$Email;
// Your subject
$subject="Your confirmation link here";
// From
$header="from: Administrator <admin@modelonlinebank.com>";
// Your message
$message="Your Comfirmation link \r\n";
$message.="Click on this link to activate your account \r\n";
$message.="http://www.modelonlinebank.com/confirmation.php?passkey=$confirm_code";
// send email
$sentmail = mail($to,$subject,$message,$header);
}
// if not found
else {
echo "Not found your email in our database";
}
// if your email succesfully sent
if($sentmail){
echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send Confirmation link to your e-mail address";
}
?>