11Tami Posted January 16, 2007 Share Posted January 16, 2007 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:<?phpIf 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. Quote Link to comment Share on other sites More sharing options...
sanguinious Posted January 16, 2007 Share Posted January 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
11Tami Posted January 16, 2007 Author Share Posted January 16, 2007 I can't believe it I fixed it all by myself before I got your post, you were right as well, thanks. Quote Link to comment Share on other sites More sharing options...
sanguinious Posted January 16, 2007 Share Posted January 16, 2007 no problem. :)[br/] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.