HTML5& PHP联系表格

时间:2014-04-27 00:05:23

标签: php html html5

我被分配了创建一个HTML页面,该页面接受用户输入,然后在php脚本上验证用户输入(点击HTML页面上的提交)。到目前为止,我只是试图在PHP页面上验证HTML页面的名字变量。

我的问题是PHP页面没有显示HTML变量,' fname'我已经四处寻找一个好的解决方案但是我找不到任何东西

我正在使用Aptana Studio 3,我正在运行XAMPP。我在下面发布了我的HTML和PHP代码供您查看。任何帮助将不胜感激:)

<!DOCTYPE html>
<html>
<head>
    <title>
        Assignment Four, HMTL/PHP Form
    </title>
    <meta charset = "UTF-8">
</head>
<body>
    <!--Begin the body code-->
    <h1>Assignment Four: HTML/PHP Form</h1>
    <p>Watch the following video, write a brief review and then click submit!</p>
    <!--Post the Scholartica Video-->
    <iframe width="560" height="315" src="//www.youtube.com/embed/d_2_8n86jA8" frameborder="0"
     allowfullscreen></iframe>

     <h3>Complete the following information:</h3>
     <form method = "post" action = "form.php">

        <p><label>First Name</label>
            <input type = "text" name = "fname"></p>

        <p><label>Last Name</label>
            <input type = "text" name = "lname"></p>

        <p><label>Email:</label>
            <input type = "text" name = "email"></p>

        <p><label>Phone:</label>
            <input type = "text" name = "phone"
            placeholder = "(123) 456-7890"></p>
        <h3>Write a brief review about the video here</h3>
        <p><textarea rows = "4" cols="50" name = "review">What did you think?
        </textarea></p>

        <h3>Rate the quality of the video</h3>
        <select name = "Rating">
            <option>Poor</option>
            <option>Average</option>
            <option>Good</option>
            <option>Excellent</option>
        </select>

        <p><input type = "submit" name ="submit" value ="Register"></p>
     </form>

</body>
</html>

我的PHP表单看起来像这样

<!DOCTYPE html>
<html>
<body>
    Hi <?php echo $_POST["fname"];?>
    Thank you for finishing the survey
    Your responses have been recorded.
</body>
</html>

1 个答案:

答案 0 :(得分:0)

我运行代码,它似乎工作。 输入姓名=&#34; Bob&#34;然后单击“提交”返回页面

  

Hi Bob感谢您完成调查您的回复已被记录。

确保:

  1. 显示结果的第二页名为&#34; form.php&#34;
  2. 同时将两个文件放在同一目录中