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'); ?>


// table name

// Random confirmation code

// values sent from form

// 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);

// if suceesfully inserted data into database, send confirmation link to email

// ---------------- SEND MAIL FORM ----------------

// send e-mail to ...

// 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";

// 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
echo "Your Confirmation link Has Been Sent To Your Email Address.";
else {
echo "Cannot send Confirmation link to your e-mail address";

Attachments temporar_user_db.jpg 61.04 KB
4 Years
Discussion Span
Last Post by sundeep.gurroby

This page is the same page that show the HTML? If so, all this code is being executed before any user interaction...

I suggest that you create an hidden input to know what do to... example:

    if ( $_POST["formAction"] == "insert" ) {
        // Insert code goes here

<input type="hidden" name="formAction" value="none"/>

<button type="submit" onclick="document.form.formAction.value = 'insert'; return true;">Send</button>

Thanks mate! I have found the solution by putting the form and the php process in two different pages and its working as expected...with little issue in database.I will consider it solved. And looking to deal with my next issue.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.