I have recently been making a HTML quiz to assess people for a certain role.
I want it so they answer the questions and it emails me the results and (optional) tells them a message based on their score.
The quiz is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CED Invigilator Quiz</title>
<link rel="stylesheet" type="text/css" href="view.css" media="all">
<script type="text/javascript" src="view.js"></script>
</head>
<body id="main_body" >
<img id="top" src="top.png" alt="">
<div id="form_container">
<h1><a>CED Invigilator Quiz</a></h1>
<form id="form_1114102" class="appnitro" method="post" action="postit.php">
<div class="form_description">
<h2>CED Invigilator Quiz</h2>
<p></p>
</div>
<ul >
<li id="li_25" >
<label class="description" for="element_25">Name </label>
<span>
<input id="element_25_1" name= "element_25_1" class="element text" maxlength="255" size="8" value=""/>
<label>First</label>
</span>
<span>
<input id="element_25_2" name= "element_25_2" class="element text" maxlength="255" size="14" value=""/>
<label>Last</label>
</span>
</li> <li id="li_1" >
<label class="description" for="element_1">You have a Cambridge International IGCSE English exam that is 1 hour 45 minutes long. It's scheduled to be held in the afternoon. You plan to start it at 2 : 30 PM . Your key time is 2 : 00 PM . Which of the statements apply? </label>
<span>
<input id="element_1_1" name="element_1" class="element radio" type="radio" value="1" />
<label class="choice" for="element_1_1">At the Key Time , candidates are taking their exam. They can leave the room at the end of the exam. They do not need further supervision</label>
<input id="element_1_2" name="element_1" class="element radio" type="radio" value="2" />
<label class="choice" for="element_1_2">The Key Time falls before the start of the exam. Keep the candidates under Full Center Supervision from the Key Time until the start of the exam. They can leave the room at the end of the exam , they do not need any further supervision.</label>
<input id="element_1_3" name="element_1" class="element radio" type="radio" value="3" />
<label class="choice" for="element_1_3">The exam finishes before the Key Time. Supervise candidates as they leave the exam room and keep them under full center supervision until the Key Time passes.</label>
</span>
</li> <li id="li_2" >
<label class="description" for="element_2">You have a Cambridge International A-level Literature exam. That is two hours long and is scheduled to be held in the morning you want it to start at 09.00. Your Key Time is 10.00 . Which of the statements apply? </label>
<span>
<input id="element_2_1" name="element_2" class="element radio" type="radio" value="1" />
<label class="choice" for="element_2_1">At the Key Time , candidates are taking their exam. They can leave the room at the end of the exam. They do not need further supervision</label>
<input id="element_2_2" name="element_2" class="element radio" type="radio" value="2" />
<label class="choice" for="element_2_2">The Key Time falls before the start of the exam. Keep the candidates under Full Center Supervision from the Key Time until the start of the exam. They can leave the room at the end of the exam , they do not need any further supervision.</label>
<input id="element_2_3" name="element_2" class="element radio" type="radio" value="3" />
<label class="choice" for="element_2_3">The exam finishes before the Key Time. Supervise candidates as they leave the exam room and keep them under full center supervision until the Key Time passes.</label>
</span>
</li> <li id="li_3" >
<label class="description" for="element_3">What's the correct minimum distance between desks in the examining room? </label>
<span>
<input id="element_3_1" name="element_3" class="element radio" type="radio" value="1" />
<label class="choice" for="element_3_1">1.25 Meters in each direction from the center of the desk of one candidates chair to another. A greater distance may be needed for multiple choice examinations (Candidates must not be able to see the work of others.)</label>
<input id="element_3_2" name="element_3" class="element radio" type="radio" value="2" />
<label class="choice" for="element_3_2">3 Meters in each direction from the center of the desk of one candidates chair to another. A greater distance may be needed for multiple choice examinations (Candidates must not be able to see the work of others.)</label>
<input id="element_3_3" name="element_3" class="element radio" type="radio" value="3" />
<label class="choice" for="element_3_3">2 Meters in each direction from the center of the desk of one candidates chair to another. A greater distance may be needed for multiple choice examinations (Candidates must not be able to see the work of others.)</label>
</span>
</li> <li id="li_4" >
<label class="description" for="element_4">What's the correct ratio of Invigilator to candidates in a written exam? </label>
<span>
<input id="element_4_1" name="element_4" class="element radio" type="radio" value="1" />
<label class="choice" for="element_4_1">1 Invigilator to 30 candidates</label>
<input id="element_4_2" name="element_4" class="element radio" type="radio" value="2" />
<label class="choice" for="element_4_2">2 Invigilator to 30 candidates</label>
<input id="element_4_3" name="element_4" class="element radio" type="radio" value="3" />
<label class="choice" for="element_4_3">1 Invigilator to 20 candidates</label>
</span>
</li> <li id="li_5" >
<label class="description" for="element_5">What's the correct ratio of Supervisor/Invigilator to candidates in a written exam? </label>
<span>
<input id="element_5_1" name="element_5" class="element radio" type="radio" value="1" />
<label class="choice" for="element_5_1">1 Supervisor to 20 candidates</label>
<input id="element_5_2" name="element_5" class="element radio" type="radio" value="2" />
<label class="choice" for="element_5_2">2 Supervisor to 30 candidates</label>
<input id="element_5_3" name="element_5" class="element radio" type="radio" value="3" />
<label class="choice" for="element_5_3">1 Supervisor to 30 candidates</label>
</span>
</li> <li id="li_6" >
<label class="description" for="element_6">In full center supervision which of the following are not allowed? </label>
<span>
<input id="element_6_1" name="element_6" class="element radio" type="radio" value="1" />
<label class="choice" for="element_6_1">You can go on a website as long as it is not on the exam subject .No phones , no external contact , no disturbance to examinations in progress.</label>
<input id="element_6_2" name="element_6" class="element radio" type="radio" value="2" />
<label class="choice" for="element_6_2">No Internet access , No Phones/Smart Watch , No Computer , No external contact and no disturbance to examinations in progress.</label>
<input id="element_6_3" name="element_6" class="element radio" type="radio" value="3" />
<label class="choice" for="element_6_3">You can go on a website as long as it is not on the exam subject .You can use your phone as long as it is not to talk or research about examination details, no external contact , no disturbance to examinations in progress.</label>
</span>
</li> <li id="li_7" >
<label class="description" for="element_7">What should you do if you suspect that a candidate is committing malpractice? </label>
<span>
<input id="element_7_1" name="element_7" class="element radio" type="radio" value="1" />
<label class="choice" for="element_7_1">Tell them to quit shouting and get out of the room. Then file a report to parents.</label>
<input id="element_7_2" name="element_7" class="element radio" type="radio" value="2" />
<label class="choice" for="element_7_2">Photograph the scene of malpractice attach the photograph to your instant report to Cambridge and inform parents.</label>
<input id="element_7_3" name="element_7" class="element radio" type="radio" value="3" />
<label class="choice" for="element_7_3">Warn them that they may be excluded from the exam , record what has happened and keep the evidence. Call for help if necessary , inform the Exam Security Office so they can report the incident to Cambridge using 'Exam Day - Form 9' .</label>
</span>
</li> <li id="li_8" >
<label class="description" for="element_8">Which of the following are ALL authorized materials in an exam? </label>
<span>
<input id="element_8_1" name="element_8" class="element radio" type="radio" value="1" />
<label class="choice" for="element_8_1">Fluffy toy mascot , calculator case</label>
<input id="element_8_2" name="element_8" class="element radio" type="radio" value="2" />
<label class="choice" for="element_8_2">Transparent Pencil Case , Clear bottle of water</label>
<input id="element_8_3" name="element_8" class="element radio" type="radio" value="3" />
<label class="choice" for="element_8_3">Ruler , Black Bag</label>
</span>
</li> <li id="li_9" >
<label class="description" for="element_9">Multiple Choice </label>
<span>
<input id="element_9_1" name="element_9" class="element radio" type="radio" value="1" />
<label class="choice" for="element_9_1">First option</label>
<input id="element_9_2" name="element_9" class="element radio" type="radio" value="2" />
<label class="choice" for="element_9_2">Second option</label>
<input id="element_9_3" name="element_9" class="element radio" type="radio" value="3" />
<label class="choice" for="element_9_3">Third option</label>
</span>
</li> <li id="li_10" >
<label class="description" for="element_10">If there is an emergency (ie. A fire alarm.)
What should you do? (Tick all applicable) </label>
<span>
<input id="element_10_1" name="element_10_1" class="element checkbox" type="checkbox" value="1" />
<label class="choice" for="element_10_1">Evacuate the room. Leaving the exam papers in the room</label>
<input id="element_10_2" name="element_10_2" class="element checkbox" type="checkbox" value="1" />
<label class="choice" for="element_10_2">Continue the exam ensuring the fire door is shut while ensuring you have hold of a fire extinguisher.</label>
<input id="element_10_3" name="element_10_3" class="element checkbox" type="checkbox" value="1" />
<label class="choice" for="element_10_3">Tell the candidates to get out of the room with their own exam papers.</label>
<input id="element_10_4" name="element_10_4" class="element checkbox" type="checkbox" value="1" />
<label class="choice" for="element_10_4">Allow candidates full time for the exam</label>
<input id="element_10_5" name="element_10_5" class="element checkbox" type="checkbox" value="1" />
<label class="choice" for="element_10_5">On the return into the room (If possible) indicate on the scripts the point where the emergency occurred and length of the interruption.</label>
<input id="element_10_6" name="element_10_6" class="element checkbox" type="checkbox" value="1" />
<label class="choice" for="element_10_6">Keep candidates in exam conditions throughout emergency.</label>
</span>
</li> <li id="li_11" >
<label class="description" for="element_11">Can an invigilator take the new exam scripts out of the locked cabinet by themselves? </label>
<span>
<input id="element_11_1" name="element_11" class="element radio" type="radio" value="1" />
<label class="choice" for="element_11_1">Yes, one invigilator can do it alone.</label>
<input id="element_11_2" name="element_11" class="element radio" type="radio" value="2" />
<label class="choice" for="element_11_2">No , taking the exam scripts out of the locked cabinet requires two invigilators.</label>
<input id="element_11_3" name="element_11" class="element radio" type="radio" value="3" />
<label class="choice" for="element_11_3">No , taking the exam scripts out of the locked cabinet requires a exam security officer to be in attendance</label>
</span>
</li> <li id="li_12" >
<label class="description" for="element_12">What is the first thing you will when you arrive at the center as an invigilator? </label>
<span>
<input id="element_12_1" name="element_12" class="element radio" type="radio" value="1" />
<label class="choice" for="element_12_1">Go with the security officer and get out materials needed for the exam session , including exam scripts.</label>
<input id="element_12_2" name="element_12" class="element radio" type="radio" value="2" />
<label class="choice" for="element_12_2">Go with the security officer and get out materials needed for the exam session , NOT including the scripts.</label>
<input id="element_12_3" name="element_12" class="element radio" type="radio" value="3" />
<label class="choice" for="element_12_3">Go with the other invigilator and get out all the materials needed for the exam session including the scripts.</label>
</span>
</li> <li id="li_13" >
<label class="description" for="element_13">What is the minimum number of Notice to Candidates that should be displayed? </label>
<span>
<input id="element_13_1" name="element_13" class="element radio" type="radio" value="1" />
<label class="choice" for="element_13_1">4</label>
<input id="element_13_2" name="element_13" class="element radio" type="radio" value="2" />
<label class="choice" for="element_13_2">1</label>
<input id="element_13_3" name="element_13" class="element radio" type="radio" value="3" />
<label class="choice" for="element_13_3">2</label>
</span>
</li> <li id="li_14" >
<label class="description" for="element_14">When do you read through the whole invigilation script? </label>
<span>
<input id="element_14_1" name="element_14" class="element radio" type="radio" value="1" />
<label class="choice" for="element_14_1">Whilst preparing room , prior to exam.</label>
<input id="element_14_2" name="element_14" class="element radio" type="radio" value="2" />
<label class="choice" for="element_14_2">During the exam , as you go along.</label>
<input id="element_14_3" name="element_14" class="element radio" type="radio" value="3" />
<label class="choice" for="element_14_3">Only consult it if there is a problem.</label>
</span>
</li> <li id="li_15" >
<label class="description" for="element_15">How do you know what extra materials a candidate will need for the exam session taking place? </label>
<span>
<input id="element_15_1" name="element_15" class="element radio" type="radio" value="1" />
<label class="choice" for="element_15_1">Look on the front of the exam script</label>
<input id="element_15_2" name="element_15" class="element radio" type="radio" value="2" />
<label class="choice" for="element_15_2">Look in the additional materials sheet in the black folder with the attendance registers.</label>
<input id="element_15_3" name="element_15" class="element radio" type="radio" value="3" />
<label class="choice" for="element_15_3">Look in the Cambridge Examination Handbook which is in the invigilators box.</label>
</span>
</li> <li id="li_16" >
<label class="description" for="element_16">A candidate is having difficulty reading the question , can you read it out for him/her as an invigilator ? </label>
<span>
<input id="element_16_1" name="element_16" class="element radio" type="radio" value="1" />
<label class="choice" for="element_16_1">No</label>
<input id="element_16_2" name="element_16" class="element radio" type="radio" value="2" />
<label class="choice" for="element_16_2">Yes</label>
<input id="element_16_3" name="element_16" class="element radio" type="radio" value="3" />
<label class="choice" for="element_16_3">Yes , but ensuring other candidates don't overhear</label>
</span>
</li> <li id="li_17" >
<label class="description" for="element_17">If a candidate requires the toilet , what do you do? </label>
<span>
<input id="element_17_1" name="element_17" class="element radio" type="radio" value="1" />
<label class="choice" for="element_17_1">Escort them to the door of the toilet.</label>
<input id="element_17_2" name="element_17" class="element radio" type="radio" value="2" />
<label class="choice" for="element_17_2">Escort them to the disabled toilets , checking with the door open (before the candidate enters) that there is nothing that contravenes with exam regulations</label>
<input id="element_17_3" name="element_17" class="element radio" type="radio" value="3" />
<label class="choice" for="element_17_3">Inform the candidate that they will be permitted to use 'the facilities' once the exam is over.</label>
</span>
</li> <li id="li_18" >
<label class="description" for="element_18">The exam has finished , can the candidate do the following :
A) Talk to friends sat next to them.
B) Take rough workings out with them.
C) Remove rubbish out of the exam room to put in the bin.
D)Put rough work in the exam room bin on their way out. </label>
<span>
<input id="element_18_1" name="element_18" class="element radio" type="radio" value="1" />
<label class="choice" for="element_18_1">All of the above</label>
<input id="element_18_2" name="element_18" class="element radio" type="radio" value="2" />
<label class="choice" for="element_18_2">None of the above</label>
<input id="element_18_3" name="element_18" class="element radio" type="radio" value="3" />
<label class="choice" for="element_18_3">A and D</label>
</span>
</li> <li id="li_19" >
<label class="description" for="element_19">You are collecting up the answer scripts
Do you : </label>
<span>
<input id="element_19_1" name="element_19" class="element radio" type="radio" value="1" />
<label class="choice" for="element_19_1">Collect up the answer scripts and examination papers in exam tier and candidate order.</label>
<input id="element_19_2" name="element_19" class="element radio" type="radio" value="2" />
<label class="choice" for="element_19_2">Collect up answer scripts in candidate order.</label>
<input id="element_19_3" name="element_19" class="element radio" type="radio" value="3" />
<label class="choice" for="element_19_3">Collect up examination papers in tier order.</label>
</span>
</li> <li id="li_20" >
<label class="description" for="element_20">How should the examination answer scripts be sent off? </label>
<span>
<input id="element_20_1" name="element_20" class="element radio" type="radio" value="1" />
<label class="choice" for="element_20_1">Examination Answer Scripts with varying syllabus codes can go in the same script envelope.</label>
<input id="element_20_2" name="element_20" class="element radio" type="radio" value="2" />
<label class="choice" for="element_20_2">Examination Answer Scripts with the same syllabus code but different component code go in different script envelopes.</label>
<input id="element_20_3" name="element_20" class="element radio" type="radio" value="3" />
<label class="choice" for="element_20_3">Examination Answer Scripts of the same syllabus code go in together.</label>
</span>
</li> <li id="li_21" >
<label class="description" for="element_21">Examination Script envelopes are what colour? </label>
<span>
<input id="element_21_1" name="element_21" class="element radio" type="radio" value="1" />
<label class="choice" for="element_21_1">White</label>
<input id="element_21_2" name="element_21" class="element radio" type="radio" value="2" />
<label class="choice" for="element_21_2">Grey</label>
<input id="element_21_3" name="element_21" class="element radio" type="radio" value="3" />
<label class="choice" for="element_21_3">Brown</label>
</span>
</li> <li id="li_22" >
<label class="description" for="element_22">There is a Chemistry multiple-choice exam to be held on Tuesday and a Biology multiple-choice to be held on Wednesday .
When do you send off the papers? </label>
<span>
<input id="element_22_1" name="element_22" class="element radio" type="radio" value="1" />
<label class="choice" for="element_22_1">All multiple-choice examinations are sent at the same time at the finish of the last multiple-choice exam.</label>
<input id="element_22_2" name="element_22" class="element radio" type="radio" value="2" />
<label class="choice" for="element_22_2">All multiple-choice examinations are sent at the same time at the end of the week.</label>
<input id="element_22_3" name="element_22" class="element radio" type="radio" value="3" />
<label class="choice" for="element_22_3">All multiple-choice examinations are sent on the day they are sat.</label>
</span>
</li> <li id="li_23" >
<label class="description" for="element_23">How are scripts sent? </label>
<span>
<input id="element_23_1" name="element_23" class="element radio" type="radio" value="1" />
<label class="choice" for="element_23_1">Scripts must be sent as 'Signed for ' with a tracking number.</label>
<input id="element_23_2" name="element_23" class="element radio" type="radio" value="2" />
<label class="choice" for="element_23_2">Sent via Courier which is organized by Exam Security Officer.</label>
<input id="element_23_3" name="element_23" class="element radio" type="radio" value="3" />
<label class="choice" for="element_23_3">Scripts must be sent as 'Special Delivery ' with tracking number.</label>
</span>
</li> <li id="li_24" >
<label class="description" for="element_24">Can a past question paper from June 2016 series be released for people to look at and take home once... </label>
<span>
<input id="element_24_1" name="element_24" class="element radio" type="radio" value="1" />
<label class="choice" for="element_24_1">Once 24 hours have passed.</label>
<input id="element_24_2" name="element_24" class="element radio" type="radio" value="2" />
<label class="choice" for="element_24_2">Once 48 hours have passed.</label>
<input id="element_24_3" name="element_24" class="element radio" type="radio" value="3" />
<label class="choice" for="element_24_3">Once the exam certificates have been released.</label>
</span>
</li> <li id="li_26" >
<label class="description" for="element_26">Email </label>
<div>
<input id="element_26" name="element_26" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li>
<li class="buttons">
<input type="hidden" name="form_id" value="1114102" />
<input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
</li>
</ul>
</form>
<div id="footer">
Generated by pForm
</div>
</div>
<img id="bottom" src="bottom.png" alt="">
</body>
</html>
So if I am correct it should post the form results or their options to postit.php
Here is the code for postit.php
<?php
mail('email#example.com', $_POST['form_1114102']
?>
<p>Quiz submitted!.</p>
However when I do this the page is blank!
The link to the quiz is here:
Click here for quiz
What am I doing wrong?
Sorry if this question is stupid but I'm have been looking over the internet and cannot see the solution.
When you write
mail('email#example.com', $_POST['form_1114102']);
It won't work because you are trying to POST the entire form. The way to do this would be to keep a variable and assign the value of the chosen elements appended to it - and then send the entire string in a mail. Something like this
$mailToBeSent = "First Option Chosen is ".$_POST['element_1'];
$mailToBeSent .= "Second Option Chosen in ".$_POST['element_2'];
and so on. This can be then mailed to
mail('email#abc.com',$mailToBeSent);
For anyone else wondering how to pass entire PHP form variables to an email this is how I finally did it.
Set the action to formspree.io/youremail#example.com
Example:
<form id="form_1114102" class="appnitro" method="post" action="http://formspree.io/youremail#example.com">
You need to verify your email first by submitting your form.
It will then send a verification email to your given email and you're all set up to receive forms!
More help can be found at
formspree.io
Related
I have a form to determine the user's personality. So each question (there are 25) has 4 possible answers to choose from:
<form method="post">
<div>
<label for="name"></label>
<input name="name" id="name" placeholder="Name">
</div>
<div>
<label for="surname"></label>
<input name="surname" id="surname" placeholder="Surname">
</div>
<br>
<div>
<label for="q1">Question 1</label><br>
<input type="radio" name="q1" id="q1" value="S"> q1c1 <br>
<input type="radio" name="q1" id="q1" value="D"> q1c2 <br>
<input type="radio" name="q1" id="q1" value="K"> q1c3 <br>
<input type="radio" name="q1" id="q1" value="I"> q1c4 <br>
</div>
<br>
<div>
<label for="q2">Question 2</label><br>
<input type="radio" name="q2" id="q2" value="D"> q2c1 <br>
<input type="radio" name="q2" id="q2" value="K"> q2c2 <br>
<input type="radio" name="q2" id="q2" value="I"> q2c3 <br>
<input type="radio" name="q2" id="q2" value="S"> q2c4 <br>
</div>
<br>
<div>
<label for="q3">Question 3</label><br>
<input type="radio" name="q3" id="q3" value="S"> q3c1 <br>
<input type="radio" name="q3" id="q3" value="I"> q3c2 <br>
<input type="radio" name="q3" id="q3" value="D"> q3c3 <br>
<input type="radio" name="q3" id="q3" value="K"> q3c4 <br>
</div>
<br><br>
<button>Submit</button>
</form>
I need to insert the name, surname, and the selection of the question in one line. The next row in the database should also contain the name, surname, and then the next question's selection for all 25 questions.
My table users in the database only has 3 columns namely: name, surname, q
I am very new to PHP and tried some previous questions but none worked for my particular scenario.
I assume you are working fully with PHP, so no JavaScript or Ajax involved.
first of all you need to specify where your request should send:
<form method="post" action="https://example.org/target.php">
in target.php, you need to read data out of $_POST. In your case, it must be something like $_POST['name'].
From there on, you can do whatever you want with the data.
Please consider this answer as a minimal question as you need to do further checks, such as security checks, prevent SQL injections and overall data validation.
I created a form using phpform.org And with some help from Mohamed Athif have now got a partially working mail.php , I am now receiving emails but I cant get the user input into the email. I Understand That I have to add the elements in for each field in the .php file. If someone can give some guidance to getting these few element working withing the email so I can then apply them to the all the other elements myself here is the html code.
For Element 1,8,6 in the email I want it to be as follows or similar to this
What alias do you want to use - (User Input)
Is this about - (whatever the user clicked either good Job or bad Job)
What is the name of the workplace.. (user Input)
Currently in the email Im getting this
From: alias
Message: Is this about a , Where is this Business Located? element6,
so you can see that the user input is missing.
<form method="post" action="mail.php">
<div class="form_description">
<h2>GoodJob - BadJob</h2>
<p>some text here</p>
</div>
<ul >
<li id="li_1" >
<label class="description" for="element_1">What is the Alias you want to use </label>
<div>
<input id="element_1" name="element_1" class="element text medium" type="text" maxlength="255" value=""/>
</div><p class="guidelines" id="guide_1"><small>You don't have to use your real name - Just remember your Alias for Comments</small></p>
</li> <li id="li_8" >
<label class="description" for="element_8">Is this about a ...... </label>
<span>
<input id="element_8_1" name="element_8" class="element radio" type="radio" value="1" />
<label class="choice" for="element_8_1">Bad job</label>
<input id="element_8_2" name="element_8" class="element radio" type="radio" value="2" />
<label class="choice" for="element_8_2">Good Job</label>
</span>
</li> <li id="li_6" >
<label class="description" for="element_6">What is the name of the workplace you want to tell us about? </label>
<div>
<input id="element_6" name="element_6" class="element text medium" type="text" maxlength="255" value=""/>
</div><p class="guidelines" id="guide_6"><small>Type in the Name of the Business</small></p>
</li> <li id="li_16" >
<label class="description" for="element_16">Where is this Business Located? </label>
<div>
<input id="element_16" name="element_16" class="element text medium" type="text" maxlength="255" value=""/>
</div><p class="guidelines" id="guide_16"><small>Type in the town, or you can find the business on google maps and click on share and copy the link and paste it here.</small></p>
</li> <li id="li_7" >
<label class="description" for="element_7">If you want to mention the bosses name, Put it here. </label>
<div>
<input id="element_7" name="element_7" class="element text medium" type="text" maxlength="255" value=""/>
</div><p class="guidelines" id="guide_7"><small>Type in the Name of the Boss</small></p>
</li> <li id="li_15" >
<label class="description" for="element_15">If you know the personal page you can copy and paste it in here </label>
<div>
<input id="element_15" name="element_15" class="element text large" type="text" maxlength="255" value=""/>
</div><p class="guidelines" id="guide_15"><small>Go to the top address bar of the boss/owner you want to tag for this post. Select all the text and paste it in the box.</small></p>
</li> <li id="li_9" >
<label class="description" for="element_9">How many hours a week do you work? </label>
<span>
<input id="element_9_1" name="element_9" class="element radio" type="radio" value="1" />
1 to 10
10 to 20
20 to 30
30 to 40
40 to 50
50 hours Plus
</span><p class="guidelines" id="guide_9"><small>Keep it REAL. </small></p>
</li> <li id="li_18" >
<label class="description" for="element_18">Exactly how many hours do you work? </label>
<div>
<input id="element_18" name="element_18" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li> <li id="li_11" >
<label class="description" for="element_11">Does your Job Pay Extra Hours? </label>
<span>
<input id="element_11_1" name="element_11" class="element radio" type="radio" value="1" />
Yes
No
</span>
</li> <li id="li_10" >
<label class="description" for="element_10">What type of contract do you have? </label>
<span>
<input id="element_10_1" name="element_10" class="element radio" type="radio" value="1" />
Part Time
Full Time
Hourly per week
Dont know
</span><p class="guidelines" id="guide_10"><small>DON'T GUESS..This is crucial. Every worker MUST have a copy of their contract. If you don't have one ask your boss or go to the Employment office with ALL your credentials and they will tell you there what contract you have.</small></p>
</li> <li id="li_12" >
<label class="description" for="element_12">Did you get Holiday pay? </label>
<span>
<input id="element_12_1" name="element_12" class="element radio" type="radio" value="1" />
Yes
No
</span>
</li> <li id="li_17" >
<label class="description" for="element_17">How much holiday pay did you get? </label>
<div>
<input id="element_17" name="element_17" class="element text medium" type="text" maxlength="255" value=""/>
</div><p class="guidelines" id="guide_17"><small>A NUMBER ONLY no symbols or text</small></p>
</li> <li id="li_13" >
<label class="description" for="element_13">Did you know That </label>
<span>
<input id="element_13_1" name="element_13" class="element radio" type="radio" value="1" />
Yes
No
</span><p class="guidelines" id="guide_13"><small>Its true, In Spain ins a 14 month pay scheme, where you get a double pay in summer and another Christmas. Most employers will actually incorporate these two payments within your monthly wage</small></p>
</li> <li id="li_14" >
<label class="description" for="element_14">Got a story to tell about this Job? Bad or good - let it rip here!</label>
<div>
<textarea id="element_14" name="element_14" class="element textarea large"></textarea>
</div>
</li>
<li class="buttons">
<input type="hidden" name="form_id" value="1136056" />
<input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
</li>
</ul>
</form>
and the PHP is as follows
<?php
$element1 = $_POST['element_1'];
$element8 = $_POST['element_8'];
$element6 = $_POST['element_6'];
$formcontent="From: $element1 \n Message: Is this about a $element81, Where is this Business Located? element6, blah blah blah";
$recipient = "me#gmail.com";
$subject = "Contact Form";
$mailheader = "From: $element1 \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "<script type='text/javascript'>alert('Mail sent successfully!')</script>";
?>
In your original code, you
1) called an non-existing variable $element81
2) there is a $ sign missing before element6
that's why you didn't get the required content.
The code below will give you the following content in your email (as per your request)
What alias do you want to use - (User Input)
Is this about - (whatever the user clicked either good Job or bad Job)
What is the name of the workplace.. (user Input)
replace
$formcontent="From: $element1 \n Message: Is this about a $element81, Where is this Business Located? element6, blah blah blah";
with
$formcontent="What alias do you want to use - $element1\n";
$formcontent.="Is this about - $element8\n";
$formcontent.="Where is this Business Located? - $element6\n";
I have a form that has check boxes and if the selection was not there, they can add text in into a text field other:.
To make it easier to find the other: I am trying to concatenate it with the text input.
$torsList = array('Bi-monthly','Quarterly','Monthly','Seasonal (Mosquito)','One Time ($1 6 month)','Specialty','Free inspection');
function addOther($input)
{
if(in_array($input, $torsList)) {
return $input;
} else {
return 'Other:'.$input;
}
};
I believe the spaces are what are making a false statement when they select an item from the array.
if agent selects seasonal (mosutio) then database column 1 will show seasonal (mosquito)
if agent inputs text then database column 1 will display Other:what ever
Ps: new to php
Edit
<label class="description" for="element_15" >Type of Recurring Service:</label>
<span>
<input id="element_15_1" name="element_15" class="element radio" type="checkbox" value="Bi-monthly" />
<label class="choice" for="element_15_1">Bi-monthly</label>
<input id="element_15_2" name="element_15" class="element radio" type="checkbox" value="Quarterly" />
<label class="choice" for="element_15_2">Quarterly</label>
<input id="element_15_3" name="element_15" class="element radio" type="checkbox" value="Monthly" />
<label class="choice" for="element_15_3">Monthly</label>
<input id="element_15_4" name="element_15" class="element radio" type="checkbox" value="Seasonal (Mosquito)" />
<label class="choice" for="element_15_4">Seasonal (Mosquito)</label>
<input id="element_15_5" name="element_15" class="element radio" type="checkbox" value="One Time ($1 6 month)" />
<label class="choice" for="element_15_5">One Time ($1 6 month)</label>
<input id="element_15_6" name="element_15" class="element radio" type="checkbox" value="Specialty" />
<label class="choice" for="element_15_6">Specialty</label>
<input id="element_15_7" name="element_15" class="element radio" type="checkbox" value="Free inspection" />
<label class="choice" for="element_15_7">Free inspection</label>
Other:<input id="element_15_8" name="element_15_1" class="element text"
type="text" />
</span>
This is how I'm using the function $TypeOfRecurringService = addOther($_POST['element_15']);
You have a variable scope problem. You defined the variable $torsList outside the function, but you're using it inside the function. If you turn on error_reporting(E_ALL), you'll see that you're getting a warning about an undefined variable.
You need to put the $torsList variable inside the addOther function.
I have a HTML form within one of my webpages, and i am now having trouble configuring it to the sendmail.php. When I fill in the form, and click submit, its asking me to save the file 'sendmail.php' but I want it to send to the email specified in the 'sendmail.php' file.
in my 'sendmail.php' file I currently have:
<?php
$element_1_1 = $_POST['element_1_1'];
$element_1_2 = $_POST['element_1_2'];
if(isset($_POST['submit'])){
$to = "sales#atechdigital.co.uk"; // this is your Email address
$from = $_POST['element_4']; // this is the sender's Email address
$first_name = $_POST['element_1_1'];
$last_name = $_POST['element_1_2'];
$subject = "Form submission";
$message = $element_1_1 . " " . $element_1_2 . " Has Sent A Quote Request";
$element_2 = $_POST['element_2'];
$element_3 = $_POST['element_3'];
$element_4 = $_POST['element_4'];
$element_5_1 = $_POST['element_5_1'];
$element_5_2 = $_POST['element_5_2'];
$element_5_3 = $_POST['element_5_3'];
$element_5_4 = $_POST['element_5_4'];
$element_5_5 = $_POST['element_5_5'];
$element_5_6 = $_POST['element_5_6'];
mail ($to,$element_4,$element_2,$element_3,$element_4,$element_5,$element_5_1,$element_5_2,$element_5_3,$element_5_4,$element_5_5,$element_5_6);
echo " Thank you " . $first_name . ", One of our sales team is dealing with you're request! We will contact you shortly.";
}
?>
and the html form is as follows:
<form id="form_824601" class="appnitro" method="post" action="sendmail.php">
<ul >
<li id="li_1" >
<label class="description" for="element_1">Name </label>
<span>
<input id="element_1_1" name= "element_1_1" class="element text" maxlength="255" size="8" value=""/>
<label>First</label>
</span>
<span>
<input id="element_1_2" name= "element_1_2" class="element text" maxlength="255" size="14" value=""/>
<label>Last</label>
</span>
</li>
<li id="li_2" >
<label class="description" for="element_2">Company Name </label>
<div>
<input id="element_2" name="element_2" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li>
<li id="li_3" >
<label class="description" for="element_3">Enter Contact Telephone Number </label>
<div>
<input id="element_3" name="element_3" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li>
<li id="li_4" >
<label class="description" for="element_4">Enter Email Address </label>
<div>
<input id="element_4" name="element_4" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li>
<li id="li_5" >
<label class="description" for="element_5">Request A Quote For ... </label>
<span>
<input id="element_5_1" name="element_5" class="element radio" type="radio" value="1" />
<label class="choice" for="element_5_1">Web Design</label>
<input id="element_5_2" name="element_5" class="element radio" type="radio" value="2" />
<label class="choice" for="element_5_2">SEO</label>
<input id="element_5_3" name="element_5" class="element radio" type="radio" value="3" />
<label class="choice" for="element_5_3">Social Media</label>
<input id="element_5_4" name="element_5" class="element radio" type="radio" value="4" />
<label class="choice" for="element_5_4">Graphic Design</label>
<input id="element_5_5" name="element_5" class="element radio" type="radio" value="5" />
<label class="choice" for="element_5_5">Video Marketing</label>
<input id="element_5_6" name="element_5" class="element radio" type="radio" value="6" />
<label class="choice" for="element_5_6">Maintenance</label>
</span>
</li>
<li class="buttons">
<input type="hidden" name="form_id" value="824601" />
<input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
</li>
</ul>
</form>
I Hope someone can shed light on the issue I'm having!!
This will never work while you are running the script locally. You need to run it on a server that can handle PHP. The only way you could run it locally and that is if you have a local web server set up.
I hope this helps!
You can't run .php files just from the folder, you will need a web server to handle it for you. if you are running windows or mac , you can set one up using software like XAMPP (win + osx) , WAMP (win) , MAMP (osx).
If you happen you run a linux distribution, you can set up a LAMP server.
Here are some links:
https://www.apachefriends.org/index.html
http://www.wampserver.com/en/
http://www.mamp.info/en/
From the links above, xampp has always worked out the best for me performance wise. parsing a huge xml feed and putting it into a mysql database takes like half the time on xampp compared to wamp.
I've got a simple one-page form, the kind I've written dozens of times, but this behavior is totally new to me. At first, it was submitting on page-load, thus redirecting automatically to the next page in the series. I'm still not sure how I got that to stop, but now it's not doing anything at all when you hit "submit". The page simply sits there.
I've tried stripping out the error-checking scripts, the show/hide script, even jquery itself, then taking the form down to just one input. I tried getting rid of the redirect and just having it output a simple line, then vardump, and still nothing. I hit submit, and no matter what I do, the page just sits there. I've never run into behavior like this before, and firebug et al give me no errors or leads.
If anyone has any ideas at all, no matter how crazy, I'm willing to try. I'm at a loss. Thanks in advance!
<?php
session_start();
include('functions.php');
if ($_POST['submit']) {
$company = $_POST['company'];
$taxid = $_POST['taxid'];
header("location:step2.php");
}
include('head.php'); ?>
<form method="post" name="basic" action="step1.php">
<div class="col70">
<label for="company">Organization/Business name <img src="img/req.jpg" alt="required"></label>
<input type="text" name="company" id="company" value="" />
</div>
<div class="col30">
<label for="taxid">Taxpayer ID# (IEN or SS#) <img src="img/req.jpg" alt="required"></label>
<input type="text" name="taxid" id="taxid" value="" />
</div>
<div class="newcol">
<label for="address">Mailing Address <img src="img/req.jpg" alt="required"></label>
<input type="text" name="address" id="address" value="" />
</div>
<div class="col30 newcol">
<label for="city">City <img src="img/req.jpg" alt="required"></label>
<input type="text" name="city" id="city" value="" />
</div>
<div class="col30">
<label for="state">State <img src="img/req.jpg" alt="required"></label>
<select name="state" id="state" tabindex="<?php echo $tabin; $tabin++; ?>">
<option value="0"></option>
<option value="1">Alabama</option>
</select>
</div>
<div class="col25">
<label for="zipcode">Zip Code <img src="img/req.jpg" alt="required"></label>
<input type="text" name="zipcode" id="zipcode" value="" />
</div>
<fieldset><legend>1. What kind of group/company do you have? <img src="img/req.jpg" alt="required"></legend>
<span id="nfpfp" class="InputGroup">
<label><input name="nfpfp" id="nfpfp_1" type="radio" value="1" />For-profit business.</label>
<label><input name="nfpfp" id="nfpfp_2" type="radio" value="2" />Non-profit 501(c)3 organization.</label>
</span>
</fieldset>
<fieldset><legend>2. How will you use the booth space? Select all that apply. <img src="img/req.jpg" alt="required"></legend>
<span id="type" class="InputGroup">
<label><input name="food" id="type_1" type="checkbox" value="1" />Food sales</label>
<label><input name="retail" id="type_2" type="checkbox" value="2" />Retail sales</label>
<label><input name="activity" id="type_3" type="checkbox" value="3" />Activity</label>
<label><input name="display" id="type_4" type="checkbox" value="4" />Display</label>
<label><input name="other" id="type_5" type="checkbox" value="5" />Other</label>
</span>
</fieldset>
<label for="otherdetails" class="newcol offsides">Enter a short description of your use. (Ex: "BBQ sandwiches", "kite kits", "face painting".) <img src="img/req.jpg" alt="required"></label>
<input type="text" name="otherdetails" id="otherdetails" value="" />
<fieldset><legend>3. Select any/all that apply. Additional questions may appear, if further information is required.</legend>
<span id="additional" class="InputGroup">
<label><input name="raffle" id="raffle_1" type="checkbox" class="switchcheck1" value="1" />I'll be selling raffle tickets and/or holding a raffle at the festival.</label>
<div class="newcol offstate1">
<label for="raffledetails">You'll need written permission from the Exchange Club. Please enter details about the raffle. <img src="img/req.jpg" alt="required"></label>
<textarea name="raffledetails" id="raffledetails" tabindex="<?php echo $tabin; $tabin++; ?>"></textarea>
</div>
<label><input name="trailer" type="checkbox" id="trailer_1" value="1">I'll be bringing a trailer.</label>
<label><input name="outlets" type="checkbox" id="outlets_1" class="switchcheck2" value="1" />I'll require electrical outlets.</label>
<div class="newcol offstate2">
<label for="outletsdetails">How many outlets will you require? <img src="img/req.jpg" alt="required"></label>
<input type="text" name="outletsdetails" id="outletsdetails" />
</div>
</span>
</fieldset>
<input type="button" name="submit" class="a_button" value="submit" />
</form>
The element with name="submit" is of type button and not submit, so it renders a plain button that does nothing (with the intention that you bind some JavaScript to it).
Use type="submit" instead.
Try
<input type="submit" name="submit" class="a_button" value="submit" />
for your submit button.