Hello all...I am in a rut, confused.
I have created an html/php web form it works fine, the user enters the info and submits it to a confirmation page and then when the user clicks ok I need for the information to be sent to 2 email address' one it theres and the other is my own. I have read tutorials and I have 2 books, but I am confused. Can any one help me?

This is what I have in the confirmation page for when they click ok so it is sent to the email address...

<form method="POST"
<input type="hidden" name="mailto"

<h4>Please confirm the following information</h4>
Title: <?php echo $_POST["title"]; ?>
First Name: <?php echo $_POST["fname"]; ?>
MI: <?php echo $_POST["mname"]; ?>
Last Name: <?php echo $_POST["lname"]; ?>
...etc etc...

Thanks much!!

The function to email the information is
mail() google it for more..

When you press the confirm button, are you posting the variables again?
Confirm button is on the intermediate page so if you press this the page which actually sends the email do not receive your variables from the form which is the first page.... get my point...?

I have that...

$to = "myemail_address";
$re = "Enquiry Form";
$msg = "Firstname: " $fname,
"MI: " $mname,
"Lastname: " $lname,
"Address: " $address,
"Apt: " $apt,
"City: " $city,
"State: " $state,
"Zip: " $zip,
"Email: "$email,
"Memo: "$memo,

But I am confused on where to put it...the first page is the form, when the user clicks submit the following page shows the output, like a confirmation to check their input...when the user clicks ok I need the info to be sent to the email address(s) and to a db(that I am working on).


1st page is your normal form

2nd page can first display the contents by normal ECHO statement. Then it should also have a form surrounding the CONFIRM BUTTON... Something like this:

<form action="mail.php" action="POST">
<input type="hidden" name="to" value="<?=$_POST?>" >
<input type="hidden" name="msg" value="<?=$_POST?>" >
<input type="submit" value="Confirm" >

3rd Page should just take all the $_POST[] again and send them to mail() function.

Hope that helps?

Thanks for the help. I appreciate it...but now I get this error...

Warning: mail() [ function.mail ]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\PHP\e_mail.php on line 20
Cannot send e-mail.


looks like the php is not configured to send mails
go to ur php.ini
and search for smtp and smtp_port

thank you w_3rabi!!! you were so right...it was def the smtp server!

can anyone help me with inserting info into a db??

what do u want to insert into db ??

Use this:


/* Database Configuration File
/ File name: db.php */

$host='';     //Host address
$user='';      //UserName
$passwd='';   //Password
$dbname='';   //Database Name

$con=mysql_connect($host,$user,$passwd);// or die("Cannot connect to database");



In your page where you put mail() function

include ('db.php');  //Database Config File
$sql = "insert into tablename values('value1','value2','value3') ";
$rs=  mysql_query($sql);

This is my code...I have it emailing the information to me after the hit 'Submit' and then I want it to also go to a db (code at the bottom)...what am I doing wrong?

Also, I have been trying and trying to be able to email to not only my email but to the users email...but how do I email to more than one person?!?


<body bgcolor="#306EFF">
<form method="POST">
<font color="#FFE87C">
<h4>Please confirm the following information</h4>
</font color>
Title: <?php echo $_POST["title"]; ?>
First Name: <?php echo $_POST["fname"]; ?>
MI: <?php echo $_POST["mname"]; ?>
Last Name: <?php echo $_POST["lname"]; ?>
Address:<?php echo $_POST["address"]; ?>
Apt/Unit:<?php echo $_POST["apt"];?>
City:<?php echo $_POST["city"];?>
State:<?php echo $_POST["state"];?>
Zip:<?php echo $_POST["zip"];?>
Email:<?php echo $_POST["email"];?>
Memo:<?php echo $_POST["memo"];?>

<input type="submit" name="ok" value="Ok">
# Create an empty message variable.
# The mail that we want to use to recevie the submitted information.
# The E-Mail subject
$ex[]="submit"; # Where submit is the name of the submit button.
# iterate the $_POST array
foreach ($_POST as $key=>$value) {
if (!in_array($key, $ex)) {
$message.=$key.": " . $value."\n";
# Send message by e-mail.
$sm=mail($to, $subject, $message);
if (!$sm) {
print "Cannot send e-mail.";
print "E-Mail was sent.";

mysql_connect('localhost', 'root', "") or die ('Could not connect ' . mysql_error());
$query = mysql_query("INSERT INTO information VALUES ('title', 'fname', 'mname',
'lname', 'address', 'city', 'state', 'zip', 'email', 'memo')");
if (!$query) {
die('Data error ' . mysql_error());
echo 'Inserted successfully!';

use the mail function two times with different TO email field

Wow....I didn't even think of that! Thanks!!!

I did the mail() function again....but it just keeps sending emails to me and none to the user...

what did i do wrong?