mindapolis Posted November 25, 2015 Share Posted November 25, 2015 hi, I'm trying to send a email after filing out a form. I'm not getting any error messages, but I'm not getting any emails either. Any help would be appreciated. <?php //ini_set('display_errors', 'On'); //error_reporting(E_ALL); require_once('functions.php'); function outputErrors($sql_errors) { foreach($sql_errors as $name => $msgs) { echo('<h4 class="error">' . $name . ': ' . $msgs . '</h4>' . PHP_EOL); } } if(isset($_POST['submit'])) { /* Validate_input(); if(count($errors) != 0) { display_form(); } else { display_form(); } function validate_input() { global $errors; if($_POST['fname'] == "") { $errors['fname']="<font color='red'> Please enter your name</font>" } }*/ $sql_errors = array(); $mysqli = databaseConnection(); if(!$stmt = $mysqli->prepare("INSERT INTO clients(fname, lname, orgName, address, city, state, zipcode, phone, fax, email, confirmEmail, projectOptions, projectOverview, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { $sql_errors["Prepare"] = $mysqli->error . PHP_EOL; } else { if(!$stmt->bind_param('ssssssiiissisi', $_POST["fname"], $_POST["lname"], $_POST["orgName"], $_POST["address"], $_POST["city"], $_POST["state"], $_POST["zipcode"], $_POST["phone"], $_POST["fax"], $_POST["email"], $_POST["confirmEmail"], $_POST["projectOptions"], $_POST["projectOverview"], $_POST["year"])) { $sql_errors["bind_param"] = $stmt->error . PHP_EOL; } else { if(!$stmt->execute()) { $sql_errors["execute"] = $stmt->error . PHP_EOL; } $stmt->close(); } } $mysqli->close(); header('contactTest.php'); } if($_POST['submit']){ $admin = "mindiapolis@gmail.com"; $subject = "inquiry about Media Services Unlimited"; //add variables from form //send email mail($admin, $subject, $message); //email response echo "thank you"; } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Untitled Document</title>l <style type="text/css"> .error { color: #FF0000; } </style> </head> <body> <?php if(isset($sql_errors) && sizeof($sql_errors) > 0) outputErrors($sql_errors);?> <form action="thankYou.php" method="post"> <label> <input id="fname" type="text" name="fname" size="15" placeholder="First Name" value ="<?php echo isset($_POST['fname']) ? $_POST['fname'] : '';?>" > <input type="text" name="lname" size="20" placeholder="Last Name"><?php echo !empty($error['lname']) ? $error['lname'] : '';?> <input type="text" name="orgName" placeholder="Organization's Name"maxlength="50"> </label><br /> <label> <!--new row --> <input id="address" type="text" name="address" size="15" placeholder="Street Addresss" maxlength="50"> <input id="city" type="text" name="city" placeholder="City" size="10" maxlength="25"> <select id="state" name="state" placeholder="State" value=""> <option value ="">Please choose a state</option> <?php states($state); ?> </select> <input id = "zipcode" type="number" name="zipcode" placeholder="Zip Code" size="5" maxlength="5"> </label><br /> <label> <!--new row --> <input type="text" name="phone" placeholder="Phone Number:(including area code)" size="10" maxlength="10"> <input type="text" name="fax" size="10" placeholder="Fax Number: (including area code)" maxlength="10"> </label><br /> <label> <!--new row--> <input type="text" id = "email" name="email" placeholder="Email Address" /> <input type="text" id = "confirmEmail" name="confirmEmail" placeholder="Confirm Email Address" /> </label><br /> <label> <!--new row --> What would you like help with? <table id="projectOptions"> <tr span=2> <td><input type="checkbox" name="SocialMedia">Social Media</td> <td><input type="checkbox" name="WebContentManagement">Web Content Management</td> </tr> <tr> <td><input type="checkbox" name="MarketingMaterials">Marketing Material Creation</td> <td><input type="checkbox" name="SEO">SEO (Search Engine Optimization)</td> </tr> <tr> <td><input type="checkbox" name="VideoEditing"> Video Editing</td> <td><input type="checkbox" name="WebDesign">Web Design</td> </tr> </table> </label> Overview about the project:<textarea rows="5" cols="10" placeholder="Overview of Project"></textarea><br /> If you are not a robot, what year is it? <input type="text" name="year" size="4" maxlength="4"><br /> <input type="submit" name="submit" value="Contact Me!"> <input type="reset" name="reset" value="Cancel"> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/ Share on other sites More sharing options...
Cobra23 Posted November 25, 2015 Share Posted November 25, 2015 (edited) $admin = "mindiapolis@gmail.com"; $subject = "inquiry about Media Services Unlimited"; if(mail($admin, $subject, $message)){ echo "thank you"; exit; } else { $error_message = "<h4>Error - Recovery Error</h4> <p>There was an error sending a recovery password. If the problem persists, please contact us directly.</p>"; } As seen above, always add an error message if the mail fails. However, are you sure that the header('contactTest.php') is even gathering the information? It should always be like header('Location: contactTest.php'); Finally, where does the $message data come from? I don't see this anywhere. Is it in the functions.php? As soon as header('contactTest.php') works, the mail message will be skipped as your redirecting the page to that area. Edited November 25, 2015 by Cobra23 Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527142 Share on other sites More sharing options...
mindapolis Posted November 25, 2015 Author Share Posted November 25, 2015 I changed the header temporarily but now I'm getting this error Parse error: syntax error, unexpected $end in /web/html/mediaservicesunlimited.com/test/mailForm.php on line 128 if(mail($admin, $subject, $message)){ echo "thank you"; exit; } else { $error_message = "<h4>Error - Recovery Error</h4> <p>There was an error sending a recovery password. If the problem persists, please contact us directly.</p>"; } Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527145 Share on other sites More sharing options...
Ch0cu3r Posted November 25, 2015 Share Posted November 25, 2015 Nothing wrong with the code Cobra23 has given. It appears you have caused that syntax error when using that code. The usual cause for that type of error is mis-matching curly braces { } . Each opening { brace should pair up with a closing } brace. Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527146 Share on other sites More sharing options...
Cobra23 Posted November 25, 2015 Share Posted November 25, 2015 (edited) Always google the error message if you don't know what it means. That error usually means that you forgot a closing brace } Also, get rid of the following code $error_message = and replace it with echo You should also have your header(Location: ....) below all the code and inside the if($_POST['submit']){ } so everything else works before you are redirected Edited November 25, 2015 by Cobra23 Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527147 Share on other sites More sharing options...
mindapolis Posted November 25, 2015 Author Share Posted November 25, 2015 okay, I have changed those things, but I'm stlil not getting a email after I submit the form. <?php //ini_set('display_errors', 'On'); //error_reporting(E_ALL); require_once('functions.php'); function outputErrors($sql_errors) { foreach($sql_errors as $name => $msgs) { echo('<h4 class="error">' . $name . ': ' . $msgs . '</h4>' . PHP_EOL); } } if(isset($_POST['submit'])) { /* Validate_input(); if(count($errors) != 0) { display_form(); } else { display_form(); } function validate_input() { global $errors; if($_POST['fname'] == "") { $errors['fname']="<font color='red'> Please enter your name</font>" } }*/ $sql_errors = array(); $mysqli = databaseConnection(); if(!$stmt = $mysqli->prepare("INSERT INTO clients(fname, lname, orgName, address, city, state, zipcode, phone, fax, email, confirmEmail, projectOptions, projectOverview, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { $sql_errors["Prepare"] = $mysqli->error . PHP_EOL; } else { if(!$stmt->bind_param('ssssssiiissisi', $_POST["fname"], $_POST["lname"], $_POST["orgName"], $_POST["address"], $_POST["city"], $_POST["state"], $_POST["zipcode"], $_POST["phone"], $_POST["fax"], $_POST["email"], $_POST["confirmEmail"], $_POST["projectOptions"], $_POST["projectOverview"], $_POST["year"])) { $sql_errors["bind_param"] = $stmt->error . PHP_EOL; } else { if(!$stmt->execute()) { $sql_errors["execute"] = $stmt->error . PHP_EOL; } $stmt->close(); } } $mysqli->close(); } if($_POST['submit']){ $admin = "mindiapolis@gmail.com"; $subject = "inquiry about Media Services Unlimited"; //add variables from form if(mail($admin, $subject)){ echo "thank you"; exit; } else { echo "<h4>Error - Recovery Error</h4> <p>There was an error sending a recovery password. If the problem persists, please contact us directly.</p>"; header('mailForm.php');//change to contactUs.php when testing is done } } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Untitled Document</title>l <style type="text/css"> .error { color: #FF0000; } </style> </head> <body> <?php if(isset($sql_errors) && sizeof($sql_errors) > 0) outputErrors($sql_errors);?> <form action="thankYou.php" method="post"> <label> <input id="fname" type="text" name="fname" size="15" placeholder="First Name" value ="<?php echo isset($_POST['fname']) ? $_POST['fname'] : '';?>" > <input type="text" name="lname" size="20" placeholder="Last Name"><?php echo !empty($error['lname']) ? $error['lname'] : '';?> <input type="text" name="orgName" placeholder="Organization's Name"maxlength="50"> </label><br /> <label> <!--new row --> <input id="address" type="text" name="address" size="15" placeholder="Street Addresss" maxlength="50"> <input id="city" type="text" name="city" placeholder="City" size="10" maxlength="25"> <select id="state" name="state" placeholder="State" value=""> <option value ="">Please choose a state</option> <?php states($state); ?> </select> <input id = "zipcode" type="number" name="zipcode" placeholder="Zip Code" size="5" maxlength="5"> </label><br /> <label> <!--new row --> <input type="text" name="phone" placeholder="Phone Number:(including area code)" size="10" maxlength="10"> <input type="text" name="fax" size="10" placeholder="Fax Number: (including area code)" maxlength="10"> </label><br /> <label> <!--new row--> <input type="text" id = "email" name="email" placeholder="Email Address" /> <input type="text" id = "confirmEmail" name="confirmEmail" placeholder="Confirm Email Address" /> </label><br /> <label> <!--new row --> What would you like help with? <table id="projectOptions"> <tr span=2> <td><input type="checkbox" name="SocialMedia">Social Media</td> <td><input type="checkbox" name="WebContentManagement">Web Content Management</td> </tr> <tr> <td><input type="checkbox" name="MarketingMaterials">Marketing Material Creation</td> <td><input type="checkbox" name="SEO">SEO (Search Engine Optimization)</td> </tr> <tr> <td><input type="checkbox" name="VideoEditing"> Video Editing</td> <td><input type="checkbox" name="WebDesign">Web Design</td> </tr> </table> </label> Overview about the project:<textarea rows="5" cols="10" placeholder="Overview of Project"></textarea><br /> If you are not a robot, what year is it? <input type="text" name="year" size="4" maxlength="4"><br /> <input type="submit" name="submit" value="Contact Me!"> <input type="reset" name="reset" value="Cancel"> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527152 Share on other sites More sharing options...
Barand Posted November 25, 2015 Share Posted November 25, 2015 //ini_set('display_errors', 'On'); //error_reporting(E_ALL); You are having problems yet you comment out those lines. Unbelievable!. Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527158 Share on other sites More sharing options...
mindapolis Posted November 25, 2015 Author Share Posted November 25, 2015 OK! I'm sorry, it has been a long day! i'm now getting this error. Notice: Undefined index: submit in /web/html/mediaservicesunlimited.com/test/mailForm.php on line 52 Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527162 Share on other sites More sharing options...
Barand Posted November 25, 2015 Share Posted November 25, 2015 You check if $_POST{'submit'] is set but that that check ends at line 51. All the code that is dependent on it being set needs to be inside the {..} Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527163 Share on other sites More sharing options...
mindapolis Posted November 25, 2015 Author Share Posted November 25, 2015 So, the closing brace should go at the bottom of the form, right? Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527165 Share on other sites More sharing options...
Barand Posted November 25, 2015 Share Posted November 25, 2015 No. If you do that then the form will not be displayed. It should extend to the end of that PHP code that should be processed only if data is posted. Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527166 Share on other sites More sharing options...
Cobra23 Posted November 25, 2015 Share Posted November 25, 2015 I understand you don't have much knowledge of php programming. When you get an error in php it always means that the error has happened anywhere ahead of that line number ... never below it. I would recommend you to delete the following code } if($_POST['submit']){ normally if(isset($_POST['submit'] is the correct code but you don't need to do it twice in your case. Also: } else { echo "<h4>Error - Recovery Error</h4> <p>There was an error sending a recovery password. If the problem persists, please contact us directly.</p>"; } header(Location: 'mailForm.php');//change to contactUs.php when testing is done } Is the correct order due to that mailForm.php being redirected after the validation is done. But i'm getting the feeling that the mailForm.php code is something else and shouldn't be there at all. Maybe it's supposed to be an include file but i can't say. Can you post the mailForm.php code? Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527167 Share on other sites More sharing options...
Barand Posted November 25, 2015 Share Posted November 25, 2015 When you get an error in php it always means that the error has happened anywhere ahead of that line number ... never below it. Or, as in this case, on the actual line number stated in the message Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527168 Share on other sites More sharing options...
Cobra23 Posted November 25, 2015 Share Posted November 25, 2015 My mistake. cheers for correcting it Barand Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527169 Share on other sites More sharing options...
mindapolis Posted November 25, 2015 Author Share Posted November 25, 2015 first, thank you so much for telling me that php errors happens before the line number. That's something I never knew. also, I apologize if I was snippy. I'm really hoping I can get this part done tonight. here's the code in its entirety <?php ini_set('display_errors', 'On'); error_reporting(E_ALL); require_once('functions.php'); function outputErrors($sql_errors) { foreach($sql_errors as $name => $msgs) { echo('<h4 class="error">' . $name . ': ' . $msgs . '</h4>' . PHP_EOL); } } if(isset($_POST['submit'])) { /* Validate_input(); if(count($errors) != 0) { display_form(); } else { display_form(); } function validate_input() { global $errors; if($_POST['fname'] == "") { $errors['fname']="<font color='red'> Please enter your name</font>" } }*/ $sql_errors = array(); $mysqli = databaseConnection(); if(!$stmt = $mysqli->prepare("INSERT INTO clients(fname, lname, orgName, address, city, state, zipcode, phone, fax, email, confirmEmail, projectOptions, projectOverview, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { $sql_errors["Prepare"] = $mysqli->error . PHP_EOL; } else { if(!$stmt->bind_param('ssssssiiissisi', $_POST["fname"], $_POST["lname"], $_POST["orgName"], $_POST["address"], $_POST["city"], $_POST["state"], $_POST["zipcode"], $_POST["phone"], $_POST["fax"], $_POST["email"], $_POST["confirmEmail"], $_POST["projectOptions"], $_POST["projectOverview"], $_POST["year"])) { $sql_errors["bind_param"] = $stmt->error . PHP_EOL; } else { if(!$stmt->execute()) { $sql_errors["execute"] = $stmt->error . PHP_EOL; } $stmt->close(); } } $mysqli->close(); } $admin = "mindiapolis@gmail.com"; $subject = "inquiry about Media Services Unlimited"; //add variables from form if(mail($admin, $subject)){ echo "thank you"; exit; } else { echo "<h4>Error - Recovery Error</h4> <p>There was an error sending a recovery password. If the problem persists, please contact us directly.</p>"; header('mailForm.php');//change to contactUs.php when testing is done } } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Untitled Document</title>l <style type="text/css"> .error { color: #FF0000; } </style> </head> <body> <?php if(isset($sql_errors) && sizeof($sql_errors) > 0) outputErrors($sql_errors);?> <form action="thankYou.php" method="post"> <label> <input id="fname" type="text" name="fname" size="15" placeholder="First Name" value ="<?php echo isset($_POST['fname']) ? $_POST['fname'] : '';?>" > <input type="text" name="lname" size="20" placeholder="Last Name"><?php echo !empty($error['lname']) ? $error['lname'] : '';?> <input type="text" name="orgName" placeholder="Organization's Name"maxlength="50"> </label><br /> <label> <!--new row --> <input id="address" type="text" name="address" size="15" placeholder="Street Addresss" maxlength="50"> <input id="city" type="text" name="city" placeholder="City" size="10" maxlength="25"> <select id="state" name="state" placeholder="State" value=""> <option value ="">Please choose a state</option> <?php states($state); ?> </select> <input id = "zipcode" type="number" name="zipcode" placeholder="Zip Code" size="5" maxlength="5"> </label><br /> <label> <!--new row --> <input type="text" name="phone" placeholder="Phone Number:(including area code)" size="10" maxlength="10"> <input type="text" name="fax" size="10" placeholder="Fax Number: (including area code)" maxlength="10"> </label><br /> <label> <!--new row--> <input type="text" id = "email" name="email" placeholder="Email Address" /> <input type="text" id = "confirmEmail" name="confirmEmail" placeholder="Confirm Email Address" /> </label><br /> <label> <!--new row --> What would you like help with? <table id="projectOptions"> <tr span=2> <td><input type="checkbox" name="SocialMedia">Social Media</td> <td><input type="checkbox" name="WebContentManagement">Web Content Management</td> </tr> <tr> <td><input type="checkbox" name="MarketingMaterials">Marketing Material Creation</td> <td><input type="checkbox" name="SEO">SEO (Search Engine Optimization)</td> </tr> <tr> <td><input type="checkbox" name="VideoEditing"> Video Editing</td> <td><input type="checkbox" name="WebDesign">Web Design</td> </tr> </table> </label> Overview about the project:<textarea rows="5" cols="10" placeholder="Overview of Project"></textarea><br /> If you are not a robot, what year is it? <input type="text" name="year" size="4" maxlength="4"><br /> <input type="submit" name="submit" value="Contact Me!"> <input type="reset" name="reset" value="Cancel"> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527170 Share on other sites More sharing options...
Barand Posted November 25, 2015 Share Posted November 25, 2015 So, is it working? You need to tell us something. Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527171 Share on other sites More sharing options...
mindapolis Posted November 26, 2015 Author Share Posted November 26, 2015 Not just yet. I corrected that error and now it 's saying Warning: mail() expects at least 3 parameters, 2 given in /web/html/mediaservicesunlimited.com/test/mailForm.php on line 43 Error - Recovery ErrorThere was an error sending a recovery password. If the problem persists, please contact us directly. Warning: Cannot modify header information - headers already sent by (output started at /web/html/mediaservicesunlimited.com/test/mailForm.php:1) in /web/html/mediaservicesunlimited.com/test/mailForm.php on line 50l Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527173 Share on other sites More sharing options...
mindapolis Posted November 26, 2015 Author Share Posted November 26, 2015 I'm making some progress! I added the $from argument and I got an email when I clicked contact me, but after click contact me I got this error. Notice: Undefined index: email in /web/html/mediaservicesunlimited.com/test/mailForm.php on line 39 $admin = "mindiapolis@gmail.com"; $from = $_POST['email']; $subject = "inquiry about Media Services Unlimited"; //add variables from form if(mail($admin, $from, $subject)){ echo "thank you"; exit; } else { echo "<h4>Error - Recovery Error</h4> <p>There was an error sending a recovery password. If the problem persists, please contact us directly.</p>"; header('mailForm.php');//change to contactUs.php when testing is done } Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527174 Share on other sites More sharing options...
Cobra23 Posted November 26, 2015 Share Posted November 26, 2015 (edited) The first error message, the mail() function expects 3 parameters $message = 'My message'; mail($admin, $subject, $message); I've no idea why you got rid of $message previously. I asked where it was defined. 2nd error. I notice from the error address that mailForm.php is in fact THAT PAGE. If you delete header('mailForm.php'); you'll solve that error. Also, what I'm trying to figure out is why you have "thankYou.php" in the forms action when you want to submit this page to mailForm.php (which is the same page you are submitting it from) I think I understand what you did with the form action there. With the code you showed you, you merged the two pages together into one ... Just to show us. Edited November 26, 2015 by Cobra23 Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527175 Share on other sites More sharing options...
Cobra23 Posted November 26, 2015 Share Posted November 26, 2015 (edited) Just saw your last message. Try and change that form action to mailForm.php ;-) . The reason you got that error is because you have thankYou.php in the forms action while the $email is not even defined on the thankYou.php page. Edited November 26, 2015 by Cobra23 Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527176 Share on other sites More sharing options...
mindapolis Posted November 26, 2015 Author Share Posted November 26, 2015 i got rid of $message because I realized it was art of an example I was following but i didn't have a $message variable. Also I deleted the header line, but now the form won't display and it sends an email when I refresh the page, After refreshing the page, lit just showsNotice: Undefined index: email in /web/html/mediaservicesunlimited.com/test/mailForm.php on line 39 $admin = "mindiapolis@gmail.com"; $from = $_POST['email']; $subject = "inquiry about Media Services Unlimited"; //add variables from form if(mail($admin, $from, $subject)){ echo "thank you"; exit; } else { echo "<h4>Error - Recovery Error</h4> <p>There was an error sending a recovery password. If the problem persists, please contact us directly.</p>"; } Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527177 Share on other sites More sharing options...
mindapolis Posted November 26, 2015 Author Share Posted November 26, 2015 oops just saw your last post Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527178 Share on other sites More sharing options...
mindapolis Posted November 26, 2015 Author Share Posted November 26, 2015 still doing the same thing <?php ini_set('display_errors', 'On'); error_reporting(E_ALL); require_once('functions.php'); function outputErrors($sql_errors) { foreach($sql_errors as $name => $msgs) { echo('<h4 class="error">' . $name . ': ' . $msgs . '</h4>' . PHP_EOL); } } if(isset($_POST['submit'])) { $sql_errors = array(); $mysqli = databaseConnection(); if(!$stmt = $mysqli->prepare("INSERT INTO clients(fname, lname, orgName, address, city, state, zipcode, phone, fax, email, confirmEmail, projectOptions, projectOverview, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { $sql_errors["Prepare"] = $mysqli->error . PHP_EOL; } else { if(!$stmt->bind_param('ssssssiiissisi', $_POST["fname"], $_POST["lname"], $_POST["orgName"], $_POST["address"], $_POST["city"], $_POST["state"], $_POST["zipcode"], $_POST["phone"], $_POST["fax"], $_POST["email"], $_POST["confirmEmail"], $_POST["projectOptions"], $_POST["projectOverview"], $_POST["year"])) { $sql_errors["bind_param"] = $stmt->error . PHP_EOL; } else { if(!$stmt->execute()) { $sql_errors["execute"] = $stmt->error . PHP_EOL; } $stmt->close(); } } $mysqli->close(); } $admin = "mindiapolis@gmail.com"; $from = $_POST['email']; $subject = "inquiry about Media Services Unlimited"; //add variables from form if(mail($admin, $from, $subject)){ echo "thank you"; exit; } else { echo "<h4>Error - Recovery Error</h4> <p>There was an error sending a recovery password. If the problem persists, please contact us directly.</p>"; } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Untitled Document</title> <style type="text/css"> .error { color: #FF0000; } </style> </head> <body> <?php if(isset($sql_errors) && sizeof($sql_errors) > 0) outputErrors($sql_errors);?> <form action="mailForm.php" method="post"> <label> <input id="fname" type="text" name="fname" size="15" placeholder="First Name" value ="<?php echo isset($_POST['fname']) ? $_POST['fname'] : '';?>" > <input type="text" name="lname" size="20" placeholder="Last Name"><?php echo !empty($error['lname']) ? $error['lname'] : '';?> <input type="text" name="orgName" placeholder="Organization's Name"maxlength="50"> </label><br /> <label> <!--new row --> <input id="address" type="text" name="address" size="15" placeholder="Street Addresss" maxlength="50"> <input id="city" type="text" name="city" placeholder="City" size="10" maxlength="25"> <select id="state" name="state" placeholder="State" value=""> <option value ="">Please choose a state</option> <?php states($state); ?> </select> <input id = "zipcode" type="number" name="zipcode" placeholder="Zip Code" size="5" maxlength="5"> </label><br /> <label> <!--new row --> <input type="text" name="phone" placeholder="Phone Number:(including area code)" size="10" maxlength="10"> <input type="text" name="fax" size="10" placeholder="Fax Number: (including area code)" maxlength="10"> </label><br /> <label> <!--new row--> <input type="text" id = "email" name="email" placeholder="Email Address" /> <input type="text" id = "confirmEmail" name="confirmEmail" placeholder="Confirm Email Address" /> </label><br /> <label> <!--new row --> What would you like help with? <table id="projectOptions"> <tr span=2> <td><input type="checkbox" name="SocialMedia">Social Media</td> <td><input type="checkbox" name="WebContentManagement">Web Content Management</td> </tr> <tr> <td><input type="checkbox" name="MarketingMaterials">Marketing Material Creation</td> <td><input type="checkbox" name="SEO">SEO (Search Engine Optimization)</td> </tr> <tr> <td><input type="checkbox" name="VideoEditing"> Video Editing</td> <td><input type="checkbox" name="WebDesign">Web Design</td> </tr> </table> </label> Overview about the project:<textarea rows="5" cols="10" placeholder="Overview of Project"></textarea><br /> If you are not a robot, what year is it? <input type="text" name="year" size="4" maxlength="4"><br /> <input type="submit" name="submit" value="Contact Me!"> <input type="reset" name="reset" value="Cancel"> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/299580-sending-email-from-form/#findComment-1527179 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.