在PHP中抓取整个表单结果

时间:2016-03-17 12:25:07

标签: php html variables web

我最近一直在做一个HTML测验来评估某个角色的人。 我想要它,所以他们回答问题,然后通过电子邮件向我发送结果,并(可选)根据他们的分数告诉他们一条消息。 测验如下:

<!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 <a href="http://www.phpform.org">pForm</a>
        </div>
    </div>
    <img id="bottom" src="bottom.png" alt="">
    </body>
</html>

所以,如果我是正确的,它应该将表单结果或他们的选项发布到postit.php 这是postit.php的代码

    <?php
    mail('email@example.com', $_POST['form_1114102']
?>
<p>Quiz submitted!.</p>

然而,当我这样做时,页面是空白的! 测验的链接在这里: Click here for quiz

我做错了什么? 很抱歉,如果这个问题很愚蠢,但我一直在浏览互联网,看不到解决方案。

2 个答案:

答案 0 :(得分:0)

写作时

mail('email@example.com', $_POST['form_1114102']);

它无效,因为您正在尝试POST整个表单。执行此操作的方法是保留变量并分配附加到其中的所选元素的值 - 然后通过邮件发送整个字符串。像这样的东西

$mailToBeSent = "First Option Chosen is ".$_POST['element_1'];
$mailToBeSent .= "Second Option Chosen in ".$_POST['element_2'];

等等。然后可以邮寄到

mail('email@abc.com',$mailToBeSent);

答案 1 :(得分:0)

对于其他想知道如何将整个PHP表单变量传递给电子邮件的人来说,这就是我最终做到的。

将操作设置为formspree.io/youremail@example.com 例如:

<form id="form_1114102" class="appnitro"  method="post" action="http://formspree.io/youremail@example.com">

您需要先提交表单来验证您的电子邮件。 然后,它会向您提供的电子邮件发送一封验证邮件,并且您已完成所有设置以接收表单! 可以找到更多的帮助 formspree.io