Jump to content

Second submit - confirmation on contact form


erme

Recommended Posts

This is a fork off my old post as its now a different problem.

 

I have the below code for a email form that checks what a user enters in the input $Name against a database field 'dbName'. Works fine.

 

I am struggling with the confirm submit button (as commented in the code) to send the email once the user confirms they are not already in the database... struggling is an understatement .. I'm pulling my hair out!

 

<?PHP

require_once ("includes/DB_CONNECT.php");
connectSQL(); // Establish SQL connection.



if (isset($_POST['submit'])) {

$Name = trim(stripslashes($_POST['Name']));
$clientTo="email@whatever.co.uk";
$message_enq="";
$message_enq.="Name: $Name \n";


$query = "SELECT dbName FROM Tablename WHERE dbName='{$_POST['Name']}'";
$resource = mysql_query($query);
  
if (empty($Name)) {
	print "<p>Nothing has been entered!</p>";
}
else {

  		if (mysql_num_rows($resource) == 0){
    			mail($clientTo, $subject, $message.$message_enq.$messagefooter, $emailheaders);
		print "<p>Thank you. Email sent!</p>";
		exit;
	}
	else {

		print "Are you sure you are not already listed?<br /><br />";
		echo "<button type=\"submit\" name=\"submits\" id=\"submits\">No I'm Not Listed. Add Me</button>";


		// I NOW WANT TO SEND THE EMAIL OFF IF THE USER CLICKS THE CONFIRM (SECOND) BUTTON
		exit;
    		}
}

}

?>

<form id="contactBox" method="post" action="phpform.php">
<input type="text" id="Name" name="Name" value="<?=$Name;?>" /><br />
<button type="submit" name="submit" id="submit">Add Me</button>
</form>

 

Thanks everyone

 

Link to comment
Share on other sites

u can do like write a form there and on click of submit button include one more php file by passing the values to that one...

 

u can pass values to other php as file.php?user=$user  and likewise...

at the other file u can use the _GET fucntion to get these values and then redirect to the phpform.php file after successfull completion of sending mail..

 

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.