View Full Version : PHP Script to MySQL?
I'm currently using a PHP Form Mail Script to have fields in a form on a website to be sent to an email address.
In addition to sending it to the email address, I would like to send the data to a remote mySQL database also ....
The database will be named "agregardie" and there will be one table, with all the fields [same as in the form] in that table.
Is there a simple way to add some code to the script so it will bring the fields into the database?
I'm new to mySQL so any help would be MUCH APPRECIATED! :)
Here's a link to the PHP Script in question :
http://www.agregardie.com/form/php.txt
Thanks for any help!!! :)
Jeff321
10-21-03, 05:14 PM
Heh.. probably nobody is replying because they don't know of an easy way to do this, and neither do I. Unless there is a script out there which already does what you want to do (if one exists I do not know about it), it would require writing some custom PHP and take a bit of work.
Is there any reason you have to use that specific mail script? Will you be using attachments? Because if the mail form is simple I may write a script to do what you want... send an email and add to the database at the same time, since I could use such a script myself. But that depends on how much free time I have. Could we maybe see the HTML for your form?
mysql_connect (localhost, username, password);
mysql_select_db (dbname);
mysql_query ("INSERT INTO tablename (first_name, last_name)
VALUES ('$first_name', '$last_name')
");
print ($first_name);
print (" ");
print ($last_name);
print ("<p>");
print ("Thanks for submitting your name.");
Would I be able to add these lines into my PHP script for it to output to mysql also?
The form is just your very basic form, on some of the forms it has an option to send in an attachment (that's primarily why I'm using that script). The script just validates to make sure the form fields are valid, and then it emails me the results [along with attachments, if there are any].
I could also send the html of the form also, but it's your very basic form :)
Jeff321
10-21-03, 05:56 PM
Yeah, for something simple you should be able to do it like that, the code should work right before or after the script sends the message. Good luck :)
P.S. Do you have a script to display the contents of the table?
vBulletin v3.6.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.