关于Firefox问题的PHP表格(这个地址不被理解)

时间:2017-02-16 01:36:32

标签: php html firefox

-HTML代码 -

<html lang="en">
<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>
<body>
<div class="container text-justify">
<h1>Fill this form pliz</h1>
<div class="form-group">
<form name="myform" method="post" action="formdb.php">
First name:<br> <input type="text" name="fname" placeholder=" First-name" required>
<br>
Second name:<br><input type="text" name="fname" placeholder=" Second-name" required>
<br>
Age:<br><input type="number" name="age" min="15" max="100" placeholder=" Age">
<br>
Email:<br><input type="email" name="email" placeholder=" E-mail">
<br><br>
Gender:<br>
<input type="radio" name="gender" value="Male"> Male<br>
<input type="radio" name="gender" value="Female"> Female <br>
<input type="radio" name="gender" value="Other"> Other <br>

Password:<br><input type="password" name="password" placeholder=" Password">
<br><br>
<input type="submit">
</form>
</div>
</div>
</body>
</html>

-PHP代码 -

<?php

echo "Values recieved"."<br>";

$fname=$lname=$age=$email=$sex=$pass="";

function test_input($data){
    $data=trim($data);
    $data=stripslashes($data);
    $data=htmlspecialchars($data);
    return $data;
}

if($_SERVER["REQUEST_METHOD"]=="POST")
{
    echo"bitch";
    $fname=test_input($_POST['fname']);
    $lname=test_input($_POST['lname']);
    $age=test_input($_POST['age']);
    $sex=test_input($_POST['gender']);
    $email=test_input($_POST['email']);
    $pass=test_input($_POST['password']);
}

echo "First name is ".$fname;

?>

当我提交表单时,我收到来自Firefox的错误说&#34;此地址无法理解&#34;。 PHP和HTML都位于同一目录中。这是由Firefox引起的问题还是我的错误?

1 个答案:

答案 0 :(得分:0)

仔细检查: Php文件的名称是formdb.php,它是否与表单位于同一文件夹中? 如果您运行echo basename(__DIR__);formdb.php位于同一文件夹中的表单?

您还可以检查错误:将其放入您的Html文件

<?PHP
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>