찾다

 >  Q&A  >  본문

PHP 양식을 확인할 때 21행의 F:\apache\Apache24\htdocs\chap01\form1.php에 있는 주의 사항: 정의되지 않은 색인: 이메일이 나타나면 어떻게 해야 합니까?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

< ;html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>表单验证</title>

<meta http-equiv=" Content-Type" content="text/html; charset=utf-8" />

<meta name="description" content="" />

<meta name="keywords" content=" " />

<script type="text/javascript">


</script>


<style type="text/css">

</ style>

</head>

    <body>

    <?php

$name = $email =$gender =$comment = $website ="";


if($_SERVER ["REQUEST_METHOD"] == "POST"){

    $name = test_input($_POST["name"]);

    $email = test_input($_POST["email"]);

    $website = test_input ($_POST["웹사이트"]);

    $comment = test_input($_POST["comment"]);

    $gender = test_input($_POST["gender"]);

}

function test_input( $data){

    $data = Trim($data);

    $data = 스트립슬래시($data);

    $data = htmlspecialchars($data);

    return $data;

}

?> ;


<h2> php 验证实列</h2>

<form method="post" action ="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">

姓명:< input type="text" name ="name">

<br><br>

电邮:<input type="text" email ="email">

<br>< br>

网址:<input type="text" website ="website">

<br><br>

评论:<input type="text" comment = "comment">

<br><br>

性别:

<input type="radio" name ="gender" vlaue ="female">女性

<input type="radio" name =" 성별" vlaue ="남성">男性

<br><br>

<input type="submit" name="submit" value = "提交">

</form>


<?php

echo "<h2>您的输入为:</h2>";

echo "<br>";

echo $name;

echo "< br>";

echo $email;

echo "<br>";

echo $website;

echo "<br>";

echo $comment;

echo "<br>";

echo $gender;

? >

    </body>

</html>


WW2553일 전1438

모든 응답(2)나는 대답할 것이다

  • 乘易网络

    乘易网络2017-11-17 16:37:28

    입력 이메일에 이름 속성이 없습니다. 서버는 어떻게 이를 얻나요?

    회신하다
    0
  • phpcn_u61612

    phpcn_u616122017-11-17 14:34:41

    QQ截图20171117142103.png

    QQ截图20171117142130.png

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>表单验证</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <script type="text/javascript">
    </script>
    <style type="text/css">
    </style>
    </head>
    <body>
    <?php
    $name = $email = $gender =$comment = $website ="";
    if($_SERVER["REQUEST_METHOD"] == "POST"){
        $name = test_input($_POST["name"]);
        $email = test_input($_POST["email"]);
        $website = test_input($_POST["website"]);
        $comment = test_input($_POST["comment"]);
        $gender = test_input($_POST["gender"]);
    }
    function test_input($data){
        $data = trim($data);
        $data = stripslashes($data);
        $data = htmlspecialchars($data);
        return $data;
    }
    ?>
    <h2> php 验证实列</h2>
    <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
    姓名:<input type="text" name="name">
    <br><br>
    电邮:<input type="text" name="email">
    <br><br>
    网址:<input type="text" name="website">
    <br><br>
    评论:<input type="text" name="comment">
    <br><br>
    性别:
    <input type="radio" name="gender" vlaue ="female">女性
    <input type="radio" name="gender" vlaue ="male">男性
    <br><br>
    <input type="submit" name="submit" value = "提交">
    </form>
    <?php
    echo "<h2>您的输入为:</h2>";
    echo "<br>";
    echo $name;
    echo "<br>";
    echo $email;
    echo "<br>";
    echo $website;
    echo "<br>";
    echo $comment;
    echo "<br>";
    echo $gender;
    ?>
    </body>
    </html>


    회신하다
    1
  • 취소회신하다