Jump to content

my first form to email script


chiprivers

Recommended Posts

I am creating my first PHP form to email script and I have the main processing script so far below:

 

<?php

// has form been submitted?
if (isset($_POST['send'])) {

// get values sent
$frm_name = $_POST['frm_name'];
$frm_co = $_POST['frm_co'];
$frm_web = $_POST['frm_web'];
$frm_email = $_POST['frm_email'];
$offer = $_POST['offer'];

$subject = "My Offer for ".$image_alt;
$body = "<b>Sender</b>: $frm_name \n<b>Company</b>: $frm_co \n<b>Website<b>: $frm_web \n<b>Email</b>: $frm_email \n \n<b>My offer for your $image_alt</b> \n \n<i>$offer</i>";

// define from email address
ini_set("sendmail_from", $frm_email);

// send mail
$sent = mail("[email protected]", $subject , $body, "From: $frm_email", "[email protected]" );

if ($sent) {
echo "<h4>Mail Sent!</h4>";
}

} // end if form submitted

?>

 

This works fine but I want to add any additional code to ensure that submitted values are in the correct format and prevent code injection.  Can anybody guide me?

Link to comment
https://forums.phpfreaks.com/topic/84668-my-first-form-to-email-script/
Share on other sites

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.