$_POST 或$_GET或 $_REQUEST接受表单值


//就这么个问题困扰我好久, 我用$_get, or $_post or $_request, 都接收不到表单传来的值
HTML代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1 align="center"><img src="u=3289850893,3856207640&fm=21&gp=0.jpg">
    Certification<img src="u=3289850893,3856207640&fm=21&gp=0.jpg"></h1>
<p>You too can earn your highly respected PHP certification
    from the world famous Fictional Institute of PHP Certification</p>
<p>Simply answer the questions below:</p>
<form action="score.php" method="post">
    <p>Your Name <input type="text" name="name"></p>
    <p>What does the PHP statement echo do?</p>
    <ul>
        <li><input type="radio" name="q1" value="1"> Outputs strings.</li>
        <li><input type="radio" name="q1" value="2">Adds two numbers together.</li>
        <li><input type="radio" name="q1" value="3">Creates a magical elf to finish writing your code</li>
    </ul>
    <p>What does the PHP function cos()do?</p>
    <ul>
        <li><input type="radio" name="q2" value="1">Calculates a cosine in radians.</li>
        <li><input type="radio" name="q2" value="2">Calculates a tangent in radians.</li>
        <li><input type="radio" name="q2" value="3">It is not a PHP function, It is a lettuce.</li>
    </ul>
    <P>What does the PHP function mail()do?</P>
    <ul>
        <li><input type="radio" name="q3" value="1">Sends a mail message.
        <li><input type="radio" name="q3" value="2">Checks for new mail.
        <li><input type="radio" name="q3" value="3">Toggle PHP between male and female mode.
    </ul>
    <p align="center"><input type="image" src="u=3919487505,3470538747&fm=15&gp=1.jpg" border="0"></p>
</form>
</body>
</html>

//php 代码 

<?php
//create short variable names
$name=$_GET['name'];
var_dump($name);  //返回都是 null, 
$q1=$_GET['q1'];
$q2=$_GET['q2'];
$q3=$_REQUEST['q3'];

//check that all the data was received
if (($q1=='')||($q2=='')||($q3=='')||($name=='')){
    echo "<h1><p align='center'>
            <img src='u=3289850893,3856207640&fm=21&gp=0.jpg' alt=''>
            Sorry:
            <img src='u=3289850893,3856207640&fm=21&gp=0.jpg' alt=''>
          </p></h1>
          <p>You need to fill in your name and answer all questions.</p>";
//最终都是没有接受到,返回You need to fill in your name and answer all questions


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值