Hi, PHP Freaks,
I have two questions for you:
Based on the code below, I am trying to get the form, when it is emailed to me, to be from the email address in field_5. I know it has something to do with headers, but what would that code look like?
Second, if there is a captcha error, the PHP code takes you to a blank page to display the message "Invalid Captcha Please press the back button on your browser and try again". Is there a way to have that code appear in a dialog box on the same page as the form? If so, what would that code look like?
Thanks so much! Here is the code below:
<?php
session_start();
if( ($_SESSION['security_code']==$_POST['security_code']) && (!empty($_POST['security_code'])) ) {
// File upload handling
if($_FILES['field_9']['name']!=''){
$field_9_filename = "file_9_".date("sihdmY").substr($_FILES['field_9']['name'],strlen($_FILES['field_9']['name'])-4);
if(!move_uploaded_file($_FILES['field_9']['tmp_name'], "./upload/".$field_9_filename)){
die("File " . $_FILES['field_9']['name'] . " was not uploaded.");
}
}
mail("example@example.com","Form submission email","Form data
First Name: " . $_POST['field_1'] . "
Last Name: " . $_POST['field_2'] . "
Organization: " . $_POST['field_3'] . "
Website: " . $_POST['field_4'] . "
Email: " . $_POST['field_5'] . "
Phone: " . $_POST['field_7'] . "
Description: " . $_POST['field_8'] . "
File: ".$where_form_is."upload/".$field_9_filename." (original file name: " . $_FILES['field_9']['name'] . ")
");
include("form_completed.html");
}
else {
echo "Invalid Captcha Please press the back button on your browser and try again";
}
?>