带有输入和设置答案的PHP文本框,当提交正确答案时转到页面,当显示错误时显示错误

时间:2017-04-30 00:51:38

标签: php html forms

使用输入字段创建表单,将答案设置为特定字符串“London”。如果在“伦敦”之外的任何答案提交,则在同一页面中显示代码错误(没有更改框。如果输入正确的答案,请将加载提交到另一页。

使用php的语言。

请帮助新的php

1 个答案:

答案 0 :(得分:0)

创建两个文件,一个是trial.php,另一个是newFile.php(你可以给任何名字); 请遵循以下代码

<强> trial.php

<form method="post">
   <input name="location" />
<input name='submit' type="submit">
</form>

<?php
if(!empty($_POST['submit'])){
    $location=$_POST['location'];
    if($location=='London'){
        header('location:newFile.php');
    }else echo 'Locations is not correct';
}
?>

<强> newFile.php

<?php

echo 'Location is london, that\'s why you are here';