Jump to content

How to add an email to this.


11Tami

Recommended Posts

Hi, I have a form that goes to mysql when a submit button is pushed. How to make some of the form fields go to an email at the same time. For example an easy summary of it:

<?php
If post then {
?>
form fields
<form action="<?php $_SERVER['PHP_SELF'] ;?>" method='post'>
<input fields here>
type='submit' name='Submit' value='Submit'>
</form>
<?php
}
else {
$con = mysql_connect("mysql","databasename","password");
$sql="INSERT INTO etc.
if (!mysql_query($sql,$con))
{die('Error: ' . mysql_error());}

This is where I get stuck. Where to add the email fields. So that some of the above form fields will send to the email as well. I tried......
else {
$mailto = etc. and so on here.
echo "form fields sent";}}
?>

But it says unexpected Telse on the last else. Thank you very much.
Link to comment
Share on other sites

hey,

the problem you have there is that you have two else parts to your if statement.
you can put the email code in the same part as the mysql insert.

im not quite sure about the if statement you are using i would use something like this:

[code]
<?php
if (isset($_POST['Submit'])) {

$con = mysql_connect("mysql","databasename","password");
$sql="INSERT INTO etc.
if (!mysql_query($sql,$con))
{die('Error: ' . mysql_error());

//insert email code here

} else {

<form action="<?php $_SERVER['PHP_SELF'] ;?>" method='post'>
<input fields here>
<input type='submit' name='Submit' value='Submit'>
</form>
}
?>[/code]

With the else this would not display the form again, if you want to show the form then remove the else part of the if statment.
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.