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>
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.
New to PHP. Im working on a contact from that needs to allow users to select who they want their message to go to based on options from a drop down list. The form i currently have works to send to one user, however I am having trouble getting it to work with the list. I have tried using if else, but no luck. Where and how do I insert the list in the PHP code?
Here is the HTML part of my code:
<select id="topic" name="Topic">
<option value="billing">Billing</option>
<option value="careers">Careers</option>
<option value="pickup">Pick up</option>
<option value="sales">Sales</option>
<option value="other">Tracing</option>
</select>
<form id="reused_form">
<div class="form-group">
<label >Name</label>
<input type="text" name="name" required class="form-control" placeholder="Enter Name">
</div>
<div class="form-group">
<label >Email</label>
<input type="email" name="email" required class="form-control" placeholder="Enter Email">
</div>
<div class="form-group">
<label >Phone Number</label>
<input type="number" name="number" required class="form-control" placeholder="Enter Phone Number">
</div>
<div class="form-group">
<label >Message</label>
<textarea rows="3" name="message" class="form-control" placeholder="Type Your Message"> </textarea>
</div>
<div class="form-group">
<button class="btn btn-raised btn-lg btn-warning w3-theme" type="submit">Send</button>
</div>
</form>
<div id="error_message" style="width:100%; height:100%; display:none; ">
<h4> Error </h4> Sorry there was an error sending your form.
</div>
<div id="success_message" style="width:100%; height:100%; display:none; ">
<h2 style="color:blue;">Success! Your Message was Sent Successfully.</h2>
</div>
This is the PHP code:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once './vendor/autoload.php';
use FormGuide\Handlx\FormHandler;
$pp = new FormHandler();
$validator = $pp->getValidator();
$validator->fields(['name','email','number'])->areRequired()->maxLength(50);
$validator->field('email')->isEmail();
$validator->field('comments')->maxLength(6000);
if($topic == 'billing') { /if billing was selected
$to = 'email#gmail.com';
}
else if($topic == 'pickup') /other options
$to = 'email#gmail.com';
}
else if($topic == 'sales') /other options
$to = 'email#gmail.com';
$pp->sendEmailTo('email#gmail.com'); // ← Your email here*/
echo $pp->process($_POST);
I am doing a contact us form into my website, and i am now stuck.
Here's the PHP code:
#Receive user input
$Name = $_POST['Name'];
$Email = $_POST['Email'];
$Message = $_POST['Message'];
$palvelu = $_POST['palvelu'];
#Filter user input
function filter_email_header($form_field) {
return preg_replace('/[nr|!/<>^$%*&]+/','',$form_field);
}
$Email = filter_email_header($Email);
#Send email
$headers = "From: $Email\r\n";
$sent = mail('user#example.com', 'Yhteydenotto Pyyntö: ', $Message, $headers);
#Thank user or notify them of a problem
if ($sent) {
?><html>
<head>
<title>Kiitos yhteydenotosta!</title>
</head>
<body>
<h1>Kiitos yhteydenotosta!</h1>
<p>Olemme sinuun yhteydessä mahdollisimman nopeasti!</p>
</body>
</html>
<?php
} else {
?><html>
<head>
<title>Jokin meni vikaan!</title>
</head>
<body>
<h1>Jokin meni vikaan!</h1>
<p>Emme pystyneet lähettämään viestiä?</p>
</body>
</html>
<?php
}
?>
And here's the html code of the form:
<div class="col-lg-5 d-flex align-items-stretch">
<div class="bg-white">
<div class="w-100 heading-title bg-primary text-center">
<h2 class="mb-0">Ota meihin yhteyttä!</h2>
</div>
<form action="email.php" method="post" class="appointment bg-white p-4 p-md-5">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<div class="form-field">
<div class="select-wrap">
<div class="icon"><span class="fa fa-chevron-down"></span></div>
<select name="palvelu" id="" class="form-control">
<option value="">Valitse palvelu</option>
<option value="">Sammaleen poisto</option>
<option value="">Katon pinnoitus</option>
<option value="">Tiilikaton huolto</option>
<option value="">Vuosihuolto</option>
</select>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input type="text" id="Name" name="Name" placeholder="Nimi" class="form-control">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input type="Email" id="Email" name="Email" placeholder="Sähköposti" class="form-control">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="input-wrap">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="input-wrap">
</div>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<textarea id="Message" name="Message" class="form-control" placeholder="Viesti" rows="6" maxlength="3000"></textarea>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<input type="submit" value="Lähetä viesti" class="btn btn-primary py-3 px-4">
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
So that's in finnish but i have this list where you can select what job you want to discuss "palvelut" and then the basic form. What it should do is to send an email with "who sent it" "the job they want" and the basic form stuff "name" "email" and the "message". But now it only seems to send an blank email with only the "yhteydenotto pyyntö" it means like "a new question". Could someone help me? What am i doing wrong...
Solution Here!!!
* Your filter_email_header is contain Problem so we use Default FILTER_SANITIZE_EMAIL filter.
Remove code
#Filter user input
function filter_email_header($form_field) {
return preg_replace('/[nr|!/<>^$%*&]+/','',$form_field);
}
$Email = filter_email_header($Email);
Replace the Fix
// Remove all illegal characters from email
$email = filter_var($email, FILTER_SANITIZE_EMAIL);
*Your Form select option not present value so whatare the value select empty value to shown email form
<select name="palvelu" id="palvelu" class="form-control">
<option value="Valitse palvelu">Valitse palvelu</option>
<option value="Sammaleen poisto">Sammaleen poisto</option>
<option value="Katon pinnoitus">Katon pinnoitus</option>
<option value="Tiilikaton huolto">Tiilikaton huolto</option>
<option value="Vuosihuolto">Vuosihuolto</option>
</select>
Hey I am trying to get this code running for the past few days now. I do not know what is the problem. Whenever I run the code I can see it running but an empty row gets inserted. Basically I ave tried to hard code the data and the data gets inserted. Here is the HTML form:
<form action="register.php" id="contactForm" type="post">
<div class="row">
<div class="form-group">
<div class="col-md-6">
<label>First name *</label>
<input type="text" class="form-control" name="fname" >
</div>
<div class="col-md-6">
<label>Last name *</label>
<input type="text" class="form-control" name="lname" >
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-6">
<label>Gender *</label><br>
<select name="gender">
<option> Male </option>
<option> Female </option>
</select>
</div>
<div class="col-md-6">
<label>Stream *</label><br>
<select name="stream">
<option> B-Tech </option>
<option> M-Tech </option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-6">
<label>Email *</label>
<input type="text" class="form-control" name="email" >
</div>
<div class="col-md-6">
<label>Mobile *</label>
<input type="text" class="form-control" name="mobile">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-6">
<label>College *</label>
<input type="text" class="form-control" name="college" >
</div>
<div class="col-md-6">
<label>Job Kind *</label>
<input type="text" class="form-control" name="job" >
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
    
<input type="submit" value="Register" class="btn btn-primary btn-lg"
data-loading-text="Loading..." name="submit">
</div>
</div>
</form>
Here is the registration.php
<?php
$connection = mysql_connect("EDITED by billy, was an I.P and port number", "user", "password"); // Establishing Connection with Server
$db = mysql_select_db("Registrations_connect", $connection); // Selecting Database from Server
$first_name = $_POST["fname"];
$last_name = $_POST["lname"];
$sex = $_POST["gender"];
$field = $_POST["stream"];
$contact = $_POST["mobile"];
$eaddress = $_POST["email"];
$institute = $_POST["college"];
$naukri = $_POST["job"];
$query = mysql_query("insert into students(fname, lname, gender, stream, mobile, email, college, job)
values ('$name', '$last_name', '$sex', '$field','$contact', '$eaddress', '$intitute', '$naukri')");
echo "<br/><br/><span>Data Inserted successfully...!!</span>";
mysql_close($connection); // Closing Connection with Server
?>
After running; In the inspect element I checked the response:- It shows Data Inserted successfully but actually an empty row is getting inserted. Basically what i think I am not able to correctly grab the data properly from form. Can somebody please check what is the problem. It will be a great help.
The attribute is method, not type. This typo is causing your form to process a GET rather than a POST. So all your variable assignments are wrong.
$first_name = $_POST["fname"];
would be
$first_name = $_GET["fname"];
or you could use the $_REQUEST; or you can just correct the attribute,
<form action="register.php" id="contactForm" method="post">
Your code also is wide open to SQL injections and is using the deprecated mysql_ functions. You should update to mysqli or pdo and be using prepared statements with parameterized queries.
More on SQL injections:
http://php.net/manual/en/security.database.sql-injection.phpHow can I prevent SQL injection in PHP?https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet#Defense_Option_1:_Prepared_Statements_.28Parameterized_Queries.29
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?