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( "info@website.com", "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!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.