I don't know why it is not working.I want to send contact form to email but when I submit it shows me blank page and no email is send.Here I added the html part too for you to understandable.I hope that I will get a good solution from all experts.Thanks in advance.
<?php
if (isset($_POST['send'])) {
# code...
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$ques_type = $_POST['ques_type'];
$message = $_POST['message'];
$formcontent=" From: $name \n Email: $email \n Phone: $phone \n Question Type: $ques_type \n Message: $message";
$recipient = "backoffice#simarketconsultants.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
}
?>
<form methos="POST" action="includes/send-form.php">
<fieldset>
<div class="input-group">
<label for="name">Full Name: <sup class="red">*</sup></label>
<input type="text" class="" name="name" placeholder="Full Name" required>
</div>
<div class="input-group">
<label for="email">E-mail Address: <sup class="red">*</sup></label>
<input type="email" class="" name="email" placeholder="example#yourdomain.com" required>
</div>
<div class="input-group">
<label for="phone">Phone Number: </label>
<input type="tel" class="" name="phone" placeholder="+445678946343">
</div>
<div class="input-group">
<label for="ques_type">Question Type: <sup class="red">*</sup></label>
<select name="ques_type" class="">
<option for="" id="" class="" selected>Please Select Question Type</option>
<option for="" name="customers" class="">Customer Sevice</option>
<option for="" name="new" class="">New Accounts</option>
<option for="" name="payments" class="">Payments</option>
<option for="" name="marketing" class="">Marketing</option>
<option for="" name="partners" class="">Partners</option>
<option for="" name="technical" class="">Technical Support</option>
</select>
</div>
<div class="input-group">
<label for="message" class="adjust">Qusetions or Comments: <sup class="red">*</sup></label>
<textarea name="message" placeholder="Your questions/comments will be written here....." required></textarea>
</div>
<div class="input-group">
<input class="btn btn-danger" name="send" value="Send" type="submit">
</div>
</fieldset>
</form>
First of all, your form should say method='post' not methos='post'.
Secondly, mail() doesn't work on localhost. Consider using PHPMailer or testing on a live server.
Thirdly (is that a word?), make sure that the file that holds the php is in the includes/send-form.php file, relative to the file that has the form in.
Last of all, the select tags hold the name attribute, not the option.
Example:
<select name='car'>
<option value='Audi'>Audi</option>
<option value='Ford'>Ford</option>
<option value='Skoda' selected>Skoda</option>
</select>
<?php
echo $_POST['car']; //Skoda
In your case, that would need to read as:
<select name="ques_type" class="">
<option value="none_selected" class="" selected>Please Select Question Type</option>
<option value="customers" class="">Customer Sevice</option>
<option value="new" class="">New Accounts</option>
<option value="payments" class="">Payments</option>
<option value="marketing" class="">Marketing</option>
<option value="partners" class="">Partners</option>
<option value="technical" class="">Technical Support</option>
</select>
You shouldn't close the <?php tag. Leave it open, there is no need to close it and e.g. when you include a file and want to send headers after the include whitespaces behind closing tag would cause an error.
Try to debug like this:
test1:
if (isset($_POST['send'])) {
echo 'test';
exit;
Does it output "test"?
Do you have a mailserver installed?
Related
Hello my favorite people!
I am trying to send an email after submitting a form, with the AUTO INCREMENT number attached to the email because the AUTO INCREMENT number is the clients Job Card Reference Number. So far i have successfully created the insert script which inserts the data into the database perfectly, and also sends the email too. But does not attach the AUTO INCREMENT number into the email. The INT(11) AUTO INCREMENT primary key is "job_number" in my MySQL database.
Here is my insert page:
<form action="addnewrepairprocess.php" method="POST">
<div class="form-group">
<label for="date">Date</label>
<input type="date" name="date" id="date" class="form-control" placeholder="Job Card Date">
</div>
<div class="form-group">
<label for="client_full_name">Client Full Name</label>
<input type="text" name="client_full_name" class="form-control" id="client_full_name" placeholder="Mr. Laptop Man">
</div>
<div class="form-group">
<label for="client_email">Client Email Address</label>
<input type="email" name="client_email" class="form-control" id="client_email" placeholder="example#live.co.za">
</div>
<div class="form-group">
<label for="client_phone">Client Phone Number</label>
<input type="text" name="client_phone" class="form-control" id="client_phone" placeholder="071 984 5522">
</div>
<div class="form-group">
<label for="item_for_repair">Item For Repair</label>
<select name="item_for_repair" id="item_for_repair">
<option value="Laptop">Laptop</option>
<option value="Desktop">Desktop</option>
<option value="Television">Television</option>
<option value="Washing Machine">Washing Machine</option>
<option value="Tumble Dryer">Tumble Dryer</option>
<option value="Dishwasher">Dishwasher</option>
<option value="Microwave">Microwave</option>
<option value="Fridge">Fridge</option>
<option value="Printer">Printer</option>
<option value="Other">Other</option>
</select>
</div>
<div class="form-group">
<label for="repair_description">Repair Description</label>
<input type="text" name="repair_description" class="form-control" id="repair_description" placeholder="Laptop is dead...">
</div>
<div class="form-group">
<label for="hardware_details">Hardware Details</label>
<input type="text" name="hardware_details" class="form-control" id="hardware_details" placeholder="Black Lenovo Laptop with Charger">
</div>
<div class="form-group">
<label for="diagnostic_fee">Diagnostic Fee</label>
<input type="text" name="diagnostic_fee" class="form-control" id="diagnostic_fee">
</div>
<div class="form-group">
<label for="tech_assigned">Technician Assigned</label>
<select name="tech_assigned" id="tech_assigned">
<option value="Not Assigned Yet">Not Assigned Yet</option>
<option value="Brendon">Brendon</option>
<option value="Gabriel">Gabriel</option>
<option value="Tapiwa">Tapiwa</option>
<option value="Conrad">Conrad</option>
</select>
</div>
<div class="form-group">
<label for="current_status">Current Status</label>
<select name="current_status" id="current_status">
<option value="Pending">Pending</option>
<option value="In Progress">In Progress</option>
<option value="On Hold Spares Required">On Hold Spares Required</option>
<option value="On Hold Other Fault">On Hold Other Fault</option>
<option value="Repair Completed">Repair Completed</option>
</select>
</div>
<div class="form-group">
<label for="technician_notes">Technician Notes</label>
<input type="text" name="technician_notes" class="form-control" id="technician_notes">
</div>
<div class="form-group">
<label for="admin_notes">Admin Notes</label>
<input type="text" name="admin_notes" class="form-control" id="admin_notes">
</div>
<div class="form-group">
<label for="invoice_status">Invoice Status</label>
<select name="invoice_status" id="invoice_status">
<option value="Client Not Yet Invoiced">Client Not Yet Invoiced</option>
<option value="Client Invoiced">Client Invoiced</option>
</select>
</div>
<div class="form-group">
<label for="invoice_number">Invoice Number</label>
<input type="text" name="invoice_number" class="form-control" id="invoice_number">
</div>
<input type="submit" id="btn_create" name="btn_create" class="btn btn-primary" value="Create Job Card">
</form>
My Form Action Page:
<?php
require_once "connection.php";
if(isset($_REQUEST['btn_create']))
{
$job_number = $_REQUEST['job_number'];
$date = $_REQUEST['date'];
$client_full_name = $_REQUEST['client_full_name'];
$client_email = $_REQUEST['client_email'];
$client_phone = $_REQUEST['client_phone'];
$item_for_repair = $_REQUEST['item_for_repair'];
$repair_description = $_REQUEST['repair_description'];
$hardware_details = $_REQUEST['hardware_details'];
$diagnostic_fee = $_REQUEST['diagnostic_fee'];
$tech_assigned = $_REQUEST['tech_assigned'];
$current_status = $_REQUEST['current_status'];
$technician_notes = $_REQUEST['technician_notes'];
$admin_notes = $_REQUEST['admin_notes'];
$invoice_status = $_REQUEST['invoice_status'];
$invoice_number = $_REQUEST['invoice_number'];
if(empty($date)){
$errorMsg="Please Enter date";
}
else if(empty($client_email)){
$errorMsg="Please Enter Email Address";
}
else
{
try
{
if(!isset($errorMsg))
{
$insert_stmt=$db->prepare('INSERT INTO repairs(job_number,date,client_full_name,client_email,client_phone,item_for_repair,repair_description,hardware_details,diagnostic_fee,tech_assigned,current_status,technician_notes,admin_notes,invoice_status,invoice_number) VALUES(:job_number,:date,:client_full_name,:client_email,:client_phone,:item_for_repair,:repair_description,:hardware_details,:diagnostic_fee,:tech_assigned,:current_status,:technician_notes,:admin_notes,:invoice_status,:invoice_number)');
$insert_stmt->bindParam(':job_number', $job_number);
$insert_stmt->bindParam(':date', $date);
$insert_stmt->bindParam(':client_full_name', $client_full_name);
$insert_stmt->bindParam(':client_email', $client_email);
$insert_stmt->bindParam(':client_phone', $client_phone);
$insert_stmt->bindParam(':item_for_repair', $item_for_repair);
$insert_stmt->bindParam(':repair_description',$repair_description);
$insert_stmt->bindParam(':hardware_details', $hardware_details);
$insert_stmt->bindParam(':diagnostic_fee', $diagnostic_fee);
$insert_stmt->bindParam(':tech_assigned', $tech_assigned);
$insert_stmt->bindParam(':current_status', $current_status);
$insert_stmt->bindParam(':technician_notes', $technician_notes);
$insert_stmt->bindParam(':admin_notes', $admin_notes);
$insert_stmt->bindParam(':invoice_status', $invoice_status);
$insert_stmt->bindParam(':invoice_number', $invoice_number);
if($insert_stmt->execute())
{
$insertMsg="Created Successfully........sending email now";
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
}
?>
<?php
if(isset($_POST['btn_create'])){
$to = "EMAIL_ADDRESS"; // this is your Email address
$from = "EMAIL_ADDRESS"; // this is the sender's Email address
$job_number = $_POST['job_number'];
$date = $_POST['date'];
$client_full_name = $_POST['client_full_name'];
$item_for_repair = $_POST['item_for_repair'];
$subject = "JC$job_number has been added to ECEMS";
$message = "Hi Admin. A new job card has been added to ECEMS on the $date for $client_full_name. The item for repair is a $item_for_repair. Please start diagnostics immediately for this item.";
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
header("refresh:1;repairs.php");
}
?>
I tried to follow this tut: Send email with PHP from html form on submit with the same script
I have also tried activating errors on this page with no results:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
I am new and have NEVER done a code like this where the AUTO INCREMENT number needs to be sent in an email. Please can someone assist me. I can edit my question if more clarification is needed.
EDIT: Ive done some research and found i can use the lastInsertID (https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_last-insert-id function. Some help implementing this would be so appreciated.
$insertId = false;
if($insert_stmt->execute())
{
$insertId = $insert_stmt->insert_id;
$insertMsg="Created Successfully........sending email now";
}
if($insertId){
// do stuff with the insert id
}
Ok so i used the MAX method to solve this issue. i added the following to the top of my createnewrepairs.php page:
$stmt = $db->prepare("SELECT MAX(job_number) AS max_id FROM repairs"); $stmt -> execute(); $job_number = $stmt -> fetch(PDO::FETCH_ASSOC); $max_id = $job_number['max_id'];
Then on the same page, i added the following form field
<div class="form-group">
<label for="job_number">Job Number</label>
<input type="job_number" name="job_number" id="job_number" class="form-control" value="<?php echo $max_id+1;?>" readonly>
</div>
Then on the form processing page (processnewrepair.php) my code in my original post worked and generated the AUTO INCREMENT NUMBER to send in an email.
I hosted my website through Hostinger. I inserted a PHP form on my website to send an email using my mail id. But when I am testing this feature on domainname.com/contactform.php, system show blank screen instead of running the code. I tried to solve my issue but I can not find my mistake. Please Help!
<div class="col-md-6 padding">
<!-- banner form -->
<form action="contactform.php" method="post">
<h5 class="mb-3">Register Here</h5>
<div class="form-style-w3ls">
<input placeholder="Your Name" name="name" type="text" required="">
<input placeholder="Your Email Id" name="email" type="email" required="">
<input placeholder="Contact Number" name="number" type="text" required="">
<select>
<option value="0">Business Type</option>
<option value="1">Corporate</option>
<option value="1">Partnership</option>
<option value="1">Other</option>
</select>
<!--<input placeholder="Password" name="password" type="password" required=""> -->
<button Class="btn" name="submit"> Submit</button>
<span>By Registering, You agree to Our Terms & Conditions.</span>
</div>
</form>
PHP Form
<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$MailFrom = $_POST['email'];
$contactnumber = $_POST['number'];
$Businesstype = $_POST['type'];
$mailTo = "care#thecraftedu.com";
$headers = "From: ".$MailFrom;
$txt = "You have received an Email from ".$name.".\n\n".$contactnumber;
mail($mailTo, $txt, $headers);
header("Location: index.php?mailsend");
}
?>
I have an HTML / PHP form built. It is working and submits successfully on the page stating the form has been submitted.
It emails me some information but I need to include Last Name and the options selected in two drop down menus Program and Start Term.
Any help appreciated. Thanks.
Here's the HTML:
<form class="form" role="form" method="POST" id="phpcontactform">
<div class="form-group col-md-6" style="padding-left: 0px; padding-right:15px;">
<input class="form-control input-lg" name="name" id="name" type="text" placeholder="First Name" required>
</div>
<div class="form-group col-md-6" style="padding-left: 0px; padding-right:0px;">
<input class="form-control input-lg" name="lname" id="lname" type="text" placeholder="Last Name" required>
</div>
<div class="form-group">
<input class="form-control input-lg" name="email" id="email" type="email" placeholder="Email" required>
</div>
<div class="form-group">
<input class="form-control input-lg" name="mobile" id="mobile" type="text" placeholder="Phone">
</div>
<div class="form-group col-md-6" style="padding-left: 0px; padding-right:15px;">
<select class="form-control input-lg" id="program" name="program" type="text">
<option value="" selected="selected">Program</option>
<option value="1" >One Year MBA</option>
<option value="2" >Part-Time MBA</option>
</select>
</div>
<div class="form-group col-md-6" style="padding-left: 0px; padding-right:0px;">
<select class="form-control input-lg" id="startterm" name="startterm" type="text">
<option value="" selected="selected">Start Term</option>
<option value="1" >Fall 2016</option>
<option value="2" >Spring 2017</option>
<option value="3" >Summer 2017</option>
<option value="4" >Fall 2017</option>
</select>
</div>
<div class="form-group col-md-6" style="padding-left: 0px; padding-right:15px;">
Apply Now
</div>
<div class="form-group col-md-6 last" style="padding-left: 0px; padding-right:0px;">
<input type="submit" class="btn btn-warning btn-block btn-lg" value="Submit">
</div>
</form>
Then the PHP:
<?
$name = $_REQUEST["name"];
$lname = $_REQUEST["lname"];
$email = $_REQUEST["email"];
$mobile = $_REQUEST["mobile"];
$program = $_REQUEST["program"];
$startterm = $_REQUEST["startterm"];
//$msg = $_REQUEST["msg"];
$to = "XXXXX#gmail.com"; // <--- Change email ID here
if (isset($email) && isset($name)) {
$subject = "$name sent you a message";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: ".$name." <".$email.">\r\n"."Reply-To: ".$email."\r\n" ;
$msg = "From: $name <br /> Last Name: $lname <br/> Email: $email <br/>
Phone: $mobile <br /> Program: $program <br /> Start Term: $startterm";
//<br/>Message: $msg
$mail = mail($to, $subject, $msg, $headers);
if ($mail) {
echo 'success';
} else {
echo 'failed';
}
}
?>
Here is an example of collecting data from a select list:
<?php
$choices = array(
'foo' => 'big',
'bar' => 'fat',
'baz' => 'mamma'
);
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$choice = isset($_POST['choice']) ? $_POST['choice'] : null;
$email = isset($_POST['email']) ? $_POST['email'] : null;
if(! array_key_exists($choice, $choices) || filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
throw new Exception ("Invalid Choice or email");
}
$message = sprintf("User with email: %s, selected: %s.", $email, $choices[$choice]);
echo $message;
die;
}
?>
<form method="POST">
Email:
<input type="text" name="email">
Choose:
<select name='choice'>
<?php foreach($choices as $k => $v) { ?>
<option value="<?php echo $k; ?>">
<?php echo $v ?>
</option>
<?php } ?>
</select>
<input type="submit">
</form>
first of all, change the html coding for the drop down menu as below
<div class="form-group col-md-6" style="padding-left: 0px; padding-right:15px;">
<select class="form-control input-lg" id="program" name="program" type="text">
<option value="" selected="selected">Program</option>
<option value="OneYearMBA" >OneYearMBA</option>
<option value="Part-TimeMBA" >Part-TimeMBA</option>
</select>
</div>
<div class="form-group col-md-6" style="padding-left: 0px; padding-right:0px;">
<select class="form-control input-lg" id="startterm" name="startterm" type="text">
<option value="" selected="selected">Start Term</option>
<option value="Fall2016" >Fall2016</option>
<option value="Spring2017" >Spring2017</option>
<option value="Summer2017" >Summer2017</option>
<option value="Fall2017" >Fall2017</option>
</select>
</div>
I guess you want program and start term to be text values instead of numbers. Then it is not advised to leave spaces in the options(the value to be printed on page). Then one more thing in your html put action="phppage.php". then retrieve the values in your php page as $_POST['fieldname'].
I am working on a PHP form for bootstrap my site. (http://camp.impactak.com/signup.html) This form works perfectly in every browser EXCEPT internet explorer. It comes up with and error:
"Please correct the following error:
YOUR NAME
Hit back button and try again."
I put code in the PHP that should have eliminated an error message if some of the blanks are not filled. However, it still sends an error (only in IE)
PHP:
<?php
/* Set e-mail recipient */
$myemail = "erinpavek#gmail.com";
/* Check all form inputs using check_input function */
$name = check_input($_POST['inputName'], "Your Name");
$address = check_input($_POST['inputAddress'], "Street, PO Box, company");
$address2 = check_input($_POST['inputAddress2'], "Apt, Unit, Suite");
$village = check_input($_POST['inputVillage'], "Your Village");
$state = check_input($_POST['inputState'], "State, Providence, Region");
$zip = check_input($_POST['inputZip'], "Your Zip");
$tel = check_input($_POST['inputTel'], "Your Phone");
$email = check_input($_POST['inputEmail'], "Your E-mail Address");
$pname = check_input($_POST['inputParent'], "Parent/Guardian Name");
$subject = check_input($_POST['inputSubject'], "Message Subject");
$message = check_input($_POST['inputMessage'], "Your Message");
$select = check_input($_POST['inputSelect'], "Certified");
$select2 = check_input($_POST['inputSelect2'], "NonCertified");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\#[\w\-]+\.[\w\-]+)/", $email))
{
show_error("Invalid e-mail address");
}
/* Let's prepare the message for the e-mail */
$subject = "Someone has sent you a message";
$message = "
Someone has sent you a message using your contac form:
Name: $name
Address: $address
Address2: $address2
Village: $village
State: $state
Zip: $zip
Cell: $tel
Email: $email
Parent/Guardian: $pname
Certified: $select
NonCertified: $select2
Subject: $subject
Message:
$message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header('Location: http://www.camp.impactak.com');
exit();
/* Functions we used */
function check_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
HTML:
<form name="contactform" method="post" action="mailer.php" class="form-horizontal" role="form">
<div class="panel-body">
<form name="contactform" method="post" action="http://wedding-space.net/01_admin_resources/blog/contact_form/mailer.php" class="form-horizontal" role="form">
<div class="form-group">
<label for="inputName" class="col-lg-3 control-label">Full Name</label>
<div class="col-lg-9">
<input type="text" class="form-control" id="inputName" name="inputName" placeholder="First and Last Name">
</div>
</div>
<div class="form-group">
<label for="inputAddress" class="col-lg-3 control-label">Address1</label>
<div class="col-lg-9">
<input type="text" class="form-control" id="inputAddress" name="inputAddress" placeholder="Street">
</div>
</div>
<div class="form-group">
<label for="inputAddress2" class="col-lg-3 control-label">Address2</label>
<div class="col-lg-9">
<input type="text" class="form-control" id="inputAddress2" name="inputAddress2" placeholder="Apt, Unit, Building">
</div>
</div>
<div class="form-group">
<label for="inputVillage" class="col-lg-4 control-label">Village</label>
<div class="col-lg-8">
<input type="text" class="form-control" id="inputVillage" name="inputVillage" placeholder="Village">
</div>
</div>
<div class="form-group">
<label for="inputState" class="col-lg-4 control-label">State</label>
<div class="col-lg-8">
<input type="text" class="form-control" id="inputState" name="inputState" placeholder="State">
</div>
</div>
<div class="form-group">
<label for="inputZip" class="col-lg-4 control-label">Zip Code</label>
<div class="col-lg-8">
<input type="text" class="form-control" id="inputZip" name="inputZip" placeholder="Zip">
</div>
</div>
<div class="form-group">
<label for="inputEmail" class="col-lg-3 control-label">Email</label>
<div class="col-lg-9">
<input type="text" class="form-control" id="inputEmail" name="inputEmail" placeholder="Your Email">
</div>
</div>
<div class="form-group">
<label for="inputParent" class="col-lg-3 control-label">Parent/Guardian</label>
<div class="col-lg-9">
<input type="text" class="form-control" id="inputParent" name="inputParent" placeholder="Parent/Guardian Name">
</div>
</div>
<h5>Each student much choose one class from the either the Certified or Non-Certified class list: </h5>
<select class="form-control" id="inputSelect" name="inputSelect">
<option value="none">Certified Classes</option>
<option value="DriversEd">Drivers Ed. (get license, village youth only)</option>
<option value="NSTC">NSTC- (Seniors or 2014 graduates)</option>
<option value="LifeGuard">Life Guard Training</option>
<option value="ArcticSurvival">Arctic Survival Certification</option>
</select>
<br>
<select class="form-control" id="inputSelect2" name="inputSelect2">
<option value="none">Non-Certified Classes</option>
<option value="cook">Cooking</option>
<option value="Art">Arts from the Earth/Crafts</option>
<option value="poetry">Creative Writing/Poetry</option>
<option value="guitar">Guitar Lessons</option>
<option value="engineering">Science and Engineering</option>
<option value="drama">Drama/Acting</option>
<option value="taeKwonDo">Tae Kwon Do</option>
<option value="sodHouse">Sod House Design</option>
<option value="SkinSewing">Skin Sewing</option>
<option value="DrumDance">Drum Dancing</option>
<option value="Aviation">Aviation</option>
<option value="Rap">Rap/Hip-Hop Class</option>
</select>
<br>
</form>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button type="submit" class="btn btn-default">
Sign Up
</button>
</div>
</div>
</form>
</div>
</div>
The answer was staring us in the face.
You put a form in a form.
That is not allowed.
you cant have forms submit forms.
Please readjust your markup accordingly to not have forms in Forms, they can be siblings though. Problem solved.
You have:
<form><form></form></form>
You need to either remove the inner form, or separate it out:
<form></form>
or
<form></form>
<form></form>
I am attempting to send an email by filling out a contact form. Both my html form and php file are included below. Once I fill out the form, it notifies me that the email has been sent. However, I never receive an email; I cannot figure out what i am doing wrong.
This is my html form:
<div class="row" style="padding-top:27px">
<div class="large-6 column">
<form action="mail.php" method="POST" data-abide>
<div class="name-field">
<label>Your name*</label>
<input type="text" required pattern="[a-zA-Z]+">
<small class="error">Name is required and must be a string.</small>
</div>
<div class="email-field">
<label>Email*</label>
<input type="email" required>
<small class="error">An email address is required.</small>
</div>
<div>
<label> Subject* </label>
<!--<input class="error" type="subject" name="subject" value="" size="40" required>
<small class="error">Invalid entry</small>-->
<select id="customDropdown1" class="medium error" required="" data-invalid="">
<option value="">Select an option...</option>
<option value="first">Green Chilies</option>
<option value="second">Raisins</option>
<option value="third">Panko bread crumbs</option>
<option value="fourth">Assistance</option>
</select>
<small class="error">Invalid entry</small>
</div>
</div>
<div class="large-6 column">
<!-- <label> Message </label>
<textarea class="error" placeholder="Message..." id="info" class="message" name="message" cols="70" rows="60" size="90" requi></textarea><br>-->
<label> Message </label>
<textarea class="error" placeholder="Message..." ></textarea>
<small class="error">Invalid entry</small>
<div>
<input style="float:right;" type="submit" value="Submit">
<img style="visibility: hidden;">
</div>
</form>
This is my php file:
<?php
$to = "education#arcdna.com";
$subject = $_POST['subject'];
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
mail($to , $subject, $message, $email);
echo "Thank you for using our mail form";
?>
UPDATED FILES:
HTML:
<div class="name-field">
<label>Your name*</label>
<input type="text" name="name" required pattern="[a-zA-Z]+">
<small class="error">Name is required and must be a string.</small>
</div>
<div class="email-field">
<label>Email*</label>
<input type="email" name="email" required>
<small class="error">An email address is required.</small>
</div>
<div>
<label> Subject* </label>
<!--<input class="error" type="subject" name="subject" value="" size="40" required>
<small class="error">Invalid entry</small>-->
<select id="customDropdown1" class="medium error" name="subject" required="" data-invalid="">
<option value="">Select an option...</option>
<option value="first">Green Chilies</option>
<option value="second">Raisins</option>
<option value="third">Panko bread crumbs</option>
<option value="fourth">Assistance</option>
</select>
<small class="error">Invalid entry</small>
</div>
<!-- End Contact Form -->
</div>
PHP:
<?php
$to = "education#arcdna.com";
$subject = $_POST['subject'];
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
mail($to , $subject, $message, $email);
echo "Thank you for using our mail form";
?>
None of your input fields have a name associated with them, so you're likely getting empty data in your POST. The 'email' value within $_POST['email'] refers to an input field's name.
Specifically, you're not getting an email address from your form, so the email is not sending to anyone.
For instance, you'll need:
<input type="email" name="email" required>
The fourth parameter of mail() is additional headers. Which is where your "FROM" information should go.
Refer here:
http://php.net/manual/en/function.mail.php
for what should go there.
here's one example
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();