hostfreak Posted July 13, 2006 Share Posted July 13, 2006 I was wondering if it is possible to insert data from a form into my database and have the data be sent via email at that same time? I have no trouble doing either on there own, but combining the two is where I'm lost. Link to comment https://forums.phpfreaks.com/topic/14438-form-help/ Share on other sites More sharing options...
hvle Posted July 13, 2006 Share Posted July 13, 2006 well yes,you insert data into database,then after that, compose an email and send. Link to comment https://forums.phpfreaks.com/topic/14438-form-help/#findComment-57097 Share on other sites More sharing options...
gewthen Posted July 13, 2006 Share Posted July 13, 2006 [quote author=hostfreak link=topic=100381.msg396110#msg396110 date=1152761016]I was wondering if it is possible to insert data from a form into my database and have the data be sent via email at that same time? I have no trouble doing either on there own, but combining the two is where I'm lost.[/quote]Yes, it possible to insert data into a database and email what it inserted within the same script. You might have an SQL statement: [code]<?php$sql="INSERT INTO myTable (id, name, address, city, state, zip) VALUES(null, '".$name."', '".$address."', '".$city."', '".$state."', '".$zip."' )";mysql_query($sql);?>[/code]All you need is to send the mail (assuming your PHP has mailing enabled).[code]<?php$to = '[email protected]';$subject = 'the subject';$message = "$name $address $city $state $zip";$headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion();mail($to, $subject, $message, $headers);?> [/code][size=8pt]The above was taken and then edited from [url=http://us3.php.net/manual/en/function.mail.php]php.net[/url][/size].The above should insert the data into the database and send the values to you. Link to comment https://forums.phpfreaks.com/topic/14438-form-help/#findComment-57099 Share on other sites More sharing options...
hostfreak Posted July 13, 2006 Author Share Posted July 13, 2006 That's weird, I had tried that and it didn't work o_O. Works now though, must of been something wrong with my code. Thank you guys for your help. Link to comment https://forums.phpfreaks.com/topic/14438-form-help/#findComment-57111 Share on other sites More sharing options...
hostfreak Posted July 15, 2006 Author Share Posted July 15, 2006 Sorry to bring this thread back up. Got another question. Instead of composing the email on the same page, is there anyway to include it from another file as I would if I were sending it on a contact form? Then reason is, I want it to display a confirmation. I know I could have it display a confirmation on that page but, it would also include the form they just filled out. I just want a confirmation of the information they just filled in for them to print. Link to comment https://forums.phpfreaks.com/topic/14438-form-help/#findComment-58411 Share on other sites More sharing options...
hostfreak Posted July 16, 2006 Author Share Posted July 16, 2006 bump Link to comment https://forums.phpfreaks.com/topic/14438-form-help/#findComment-58749 Share on other sites More sharing options...
hostfreak Posted July 16, 2006 Author Share Posted July 16, 2006 Sorry to keep bumping this, but does anyone have any suggestions? Link to comment https://forums.phpfreaks.com/topic/14438-form-help/#findComment-58928 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.