Note that there are some explanatory texts on larger screens.

plurals
  1. POEmail Form Data
    primarykey
    data
    text
    <p>I have a large form that I want to collect data from and enter it into a MySQL database and email the results to myself. The code I have so far enters the data just fine. I also am uploading multiple file with the form and that is working just fine. It's the email part I have no idea why it is not working. I'm very new to php coding so I don't know if it is my code for the email or where I have the email code placed within my php code. Any suggestions or help?</p> <p>Here is all of my php code:</p> <pre><code>&lt;?php require_once('Connections/ms_orders.php'); ?&gt; &lt;?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION &lt; 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["notsure_insert"])) &amp;&amp; ($_POST["notsure_insert"] == "notSureForm")) { $insertSQL = sprintf("INSERT INTO `order` (firstName, lastName, division, phone, email, quantity, dateNeeded, itemType, jobDescription) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['firstName'], "text"), GetSQLValueString($_POST['lastName'], "text"), GetSQLValueString($_POST['division'], "text"), GetSQLValueString($_POST['phone'], "text"), GetSQLValueString($_POST['email'], "text"), GetSQLValueString($_POST['quantity'], "text"), GetSQLValueString($_POST['dateNeeded'], "text"), GetSQLValueString($_POST['itemType'], "text"), GetSQLValueString($_POST['jobDescription'], "text")); mysql_select_db($database_ms_orders, $ms_orders); $Result1 = mysql_query($insertSQL, $ms_orders) or die(mysql_error()); $insertGoTo = "_finished/notsure_finish.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&amp;" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); /* FILE UPLOAD CODE */ { $number_of_file_fields = 0; $number_of_uploaded_files = 0; $number_of_moved_files = 0; $uploaded_files = array(); $upload_directory = dirname(__file__) . '/uploads/'; //set upload directory /** * we get a $_FILES['images'] array , * we procee this array while iterating with simple for loop * you can check this array by print_r($_FILES['images']); */ for ($i = 0; $i &lt; count($_FILES['file']['name']); $i++) { $number_of_file_fields++; if ($_FILES['file']['name'][$i] != '') { //check if file field empty or not $number_of_uploaded_files++; $uploaded_files[] = $_FILES['file']['name'][$i]; if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $upload_directory . $_FILES['file']['name'][$i])) { $number_of_moved_files++; } } } } /* END FILE UPLOAD CODE */ /* EMAIL CODE */ { $to = 'mjc7475@gmail.com'; $subject = 'Not Sure Where to Begin'; $firstNameField = $_POST['firstName']; $lasttNameField = $_POST['lastName']; $divisionField = $_POST['division']; $phoneField = $_POST['phone']; $emailField = $_POST['email']; $itemTypeField = $_POST['itemType']; $jobDescriptionField = $_POST['jobDescription']; $fileField = $_POST['file']; $dateNeededField = $_POST['dateNeeded']; $quantityField = $_POST['quantity']; $body = &lt;&lt;&lt;EOD &lt;strong&gt;Name:&lt;/strong&gt; &lt;br&gt; $firstName $lasttName &lt;br&gt; &lt;strong&gt;Division:&lt;/strong&gt; &lt;br&gt; $division &lt;br&gt; &lt;strong&gt;Phone:&lt;/strong&gt; &lt;br&gt; $phone &lt;br&gt; &lt;strong&gt;Email:&lt;/strong&gt; &lt;br&gt; $email &lt;br&gt; &lt;strong&gt;Item Type:&lt;/strong&gt; &lt;br&gt; $itemType &lt;br&gt; &lt;strong&gt;Job Description:&lt;/strong&gt;&lt;br&gt; $jobDescription &lt;br&gt; &lt;strong&gt;File(s) Uploaded:&lt;/strong&gt; &lt;br&gt; $file &lt;br&gt; &lt;strong&gt;Date Needed:&lt;/strong&gt; &lt;br&gt; $dateNeeded &lt;br&gt; &lt;strong&gt;Quantity Nedded:&lt;/strong&gt; &lt;br&gt; $quantity &lt;br&gt; EOD; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $headers .= "Reply-To: $email\r\n"; mail($to, $subject, $body, $headers); } /* END EMAIL CODE */ } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload