[英]POST and GET are unable to display user input values from HTML form
I have just started to learn HTML and PHP, but have run into a road block while following beginner tutorials. 我刚刚开始学习HTML和PHP,但是在学习初学者教程时遇到了障碍。 I am attempting to have the user input numbers into a form on the HTML page, then press submit to redirect to a PHP page that displays the values.
我试图让用户在HTML页面上的表单中输入数字,然后按Submit重定向到显示值的PHP页面。 The PHP page shows up and successfully displays prepared text but displays nothing for the values.
PHP页面显示并成功显示准备好的文本,但不显示任何值。
HTML code: HTML代码:
<html> <body> <head> <title>Practice Page</title> </head> <h1>Numbers</h1> <p>Put numbers in the boxes</p> <form action="welcome.php" method="post"> NumOne: <input type="text" name="oynumone"><br> NumTwo: <input type="text" name="oynumtwo"><br> <input type="submit" value="Submit" id="SubmitRegister" name="submit" /> </form> </body> <html>
PHP code: PHP代码:
<html> <body> Number one is <?php echo $_POST["oynumone"]; ?><br> Number two is <?php echo $_POST["oynumtwo"]; ?> </body> </html>
Both of the files are simply in the same folder in my documents. 这两个文件都只是在我文档的同一文件夹中。 I understand that I need a server to host PHP content;
我知道我需要一个服务器来托管PHP内容; I have downloaded MAMP for this, but I don't yet understand how to use it.
我已经为此下载了MAMP,但是我还不了解如何使用它。
Any help would be most appreciated. 非常感激任何的帮助。
Store both file name with .php
extension AND/OR update Welcome.php like below - 将两个文件名都以
.php
扩展名存储和/或更新Welcome.php,如下所示-
Welcome.php Welcome.php
<?php
if isset($_POST['submit'])
{
$oynumone = $_POST['oynumone'];
$oynumtwo = $_POST['oynumtwo'];
echo "Number one is ".$oynumone;
echo "Number two is ".$oynumtwo;
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.