Jump to content

Feedback form - insert into database & email results


spacepoet

Recommended Posts

Hello:

 

Did my first post last week and am new to PHP. Making the jump from Classic ASP into PHP. I got some good advice last time.

 

I have a feedback form I have been using, and it works fine for sending results to the website owner.

 

How can I add to it so it will first add all the data to mySQL database, and then email the results to the site owner? Also, I hear about SQL injection attacks a lot - is my current code safe from that?

 

This is what I have:

 

contact.php

...

<form method="post" name="myform" action="sendmail.php">


Full Name: <input type="text" name="FullName" />

Address: <input type="text" name="Address" />

City: <input type="text" name="City" />

State: <input type="text" name="State" />

Zip: <input type="text" name="Zip" />

Phone: <input type="text" name="Phone" />

Email: <input type="text" name="Email" />

Website: <input type="text" name="Website" />

Comments: <textarea cols="43" rows="6" name="Comments"></textarea>


<input type="submit" /><br />

</form>

...

 

 

sendmail.php

 

<?php

$FullName = $_REQUEST['FullName'] ;
$Address = $_REQUEST['Address'] ;
$City = $_REQUEST['City'] ;
$State = $_REQUEST['State'] ;
$Zip = $_REQUEST['Zip'] ;
$Phone = $_REQUEST['Phone'] ;
$Email = $_REQUEST['Email'] ;
$Website = $_REQUEST['Website'] ;
$Comments = $_REQUEST['Comments'] ;

mail( "[email protected]", "Contact Request",

"Full Name: $FullName\nAddress: $Address\n City: $City\n State: $State\n Zip: $Zip\n Phone: $Phone\n Email: $Email\n Website: $Website\n Comments: $Comments\n",    
"From: $Email" );

header( "Location: http://www.website.com/thanks.php" );

?>

 

 

Any help or coding examples would be most appreciated!

 

Thanks!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.