Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jdl8422

macrumors 6502
Original poster
Jul 5, 2006
491
0
Louisiana
well I have an online survey I am doing for my company. Currently the page is in html/css and the form is in php. I have it to where it sends the data to an email. I would also like for it to go to a MySQL database as well as the email. Other than setting the database up on the server, what code would I need to get it to go to both. Also, I am not here looking for someone to do it for me:D. I just need some direction. Thanks in advance.
 

Me1000

macrumors 68000
Jul 15, 2006
1,794
4
Code:
$tableName = formData; //this is the name of the table in the DB

//your post data...
$name = $_POST['NAME'];
$phone = $_POST['PHONE'];
$addy = $_POST['ADDY'];

//the actual SQL
$sql = "INSERT INTO $TableName (NAME,PHONE, ADDY) VALUES ('$name', '$phone', '$addy')";

$result = mysql_query($sql); //define a var for the query for simplicity sake
$response = ($result) ?  'Entry Added' : 'Entry FAILED!'; //test to see if the query was successful to replay a message back to the user... 
echo $response; // print the message back to the user, this is also required to execute the query...

I haven't tested any of that, I just wrote it off the top of my head, but that should work...
 

jdl8422

macrumors 6502
Original poster
Jul 5, 2006
491
0
Louisiana
Once I have the database set up and the emails go to it, can I input my current emails to it?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.