allybally85 Posted June 5, 2009 Share Posted June 5, 2009 hi i was wondering how i could go about sending a copy of a form i have on my website to my email address? the form goes straight to a client database when the user clicks "submit", but i would like to know what keyword the user found the page with and what their ipaddress is etc. could i use the submit button to do a 2 in 1, and send the info to the database, then send a copy of the contents of the form plus the additional info (ipaddress etc) to my email address? thanks Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted June 5, 2009 Share Posted June 5, 2009 You dont need to submit twice just add an email function after the database insert Quote Link to comment Share on other sites More sharing options...
ldougherty Posted June 5, 2009 Share Posted June 5, 2009 Where does the form submit to? Say the form action is do.php and currently inside of do.php there are queries being run to update your clients database. Simply add an email script in the do.php sending you the form data before the queries are run. $to = 'user@domain.com'; $subject = 'the subject'; $from = 'email@domain.com'; $message = 'hello'; mail($to, $subject, $message, "From: $from"); Quote Link to comment Share on other sites More sharing options...
allybally85 Posted June 5, 2009 Author Share Posted June 5, 2009 THANKS! i added it to the mailform and i managed to get the ipaddress added to the email how would i add the keyword the user entered and the page they filled the form out at? so far i have: //index.php <input type="hidden" name="IPAddress" value="<?php echo $_SERVER['REMOTE_ADDR'];?>"> <input type="hidden" name="httpref" value="<?php echo $_GET['httpref'];?>" /> <input type="hidden" name="kw" value="<?php echo $_GET['kw'];?>" /> <input type="submit" id="btn_submit" name="submit" value="Get Your Quote"/> //send_email.php </tr> <tr> <td>Keyword</td> <td>$kw</td> </tr> <tr> <td>Page</td> <td>$httpref</td> </tr> <tr> <td>IPAddress</td> <td>$IPAddress</td> </tr> </table> Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted June 5, 2009 Share Posted June 5, 2009 You send the email AFTER the form has been submitted, not within the form. If you don't and the user keeps refreshing the page you will get multiple emails. The keyword will be contained in $_POST['kw']; 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.