duanguai2781 2011-03-29 11:09
浏览 151

这个'isset($ _ POST)'代码在做什么?

Trying to understand what this isset($_POST) code is doing

if (isset($_POST['Submit'])) {
    $title=$_POST['title'];
    $forename = $_POST['forename']; 
    $surname=$_POST['surname'];
    $dob=$_POST['dob'];
    $gender=$_POST['gender'];
    $email=$_POST['email']; 
    $phone=$_POST['phone'];
    $password=$_POST['password'];


    if (authRegister($title, $forename, $surname, $dob, $gender, $email, $phone, $password))
    {
        echo 'Thank you for registering your details, you can now login';           
    } 
    else
    {
        outputErrors();
    }
  • 写回答

4条回答 默认 最新

  • duanbanfei2875 2011-03-29 11:13
    关注

    It checks that there is a field with name 'Submit' (probably submit button) in the form submitted to this php page. In other words it shows that for has been submitted and has to be processed.

    In addition I'll say that whenever you post form to a php page all fields that have name attribute of the form are represented in the $_POST array. There is 2 ways to check if a key exists in an array:

    $array = array('key_name' => 'value');
    isset($array['key_name']);
    array_key_exists('key_name', $array)
    

    isset() also returns false if the 'key_name' exists in $array but value is null. array_key_exists would return true in this key.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度