if(isset($ _ POST ['btn-signup']))会做什么? [英] What does if(isset($_POST['btn-signup'])) do?

查看:99
本文介绍了if(isset($ _ POST ['btn-signup']))会做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

if(isset($ _ POST ['btn-signup']))行有什么作用?我正在学习PHP.我已经完成了一些基础知识课程,现在可以通过示例程序进行即时学习.这是登录表单的php部分.它显然工作正常,但我仍然不太了解$ _POST的用法.

What does the if(isset($_POST['btn-signup']))line do? Im learning php. I have completed a few courses on the basics and now im learning through sample programs. This is the php section of a login form. Its obviously working fine but i still dont understand the use of $_POST very well.

<?php
session_start();
if(isset($_SESSION['userSession'])!="")
{
 header("Location: home.php");
}
include_once 'dbconnect.php';

if(isset($_POST['btn-signup']))
{
 $uname = $MySQLi_CON->real_escape_string(trim($_POST['user_name']));
 $email = $MySQLi_CON->real_escape_string(trim($_POST['user_email']));
 $upass = $MySQLi_CON->real_escape_string(trim($_POST['password']));

 $new_password = password_hash($upass, PASSWORD_DEFAULT);

 $check_email = $MySQLi_CON->query("SELECT email FROM users WHERE email='$email'");
 $count=$check_email->num_rows;

 if($count==0){


  $query = "INSERT INTO users(username,email,password) VALUES('$uname','$email','$new_password')";


  if($MySQLi_CON->query($query))
  {
   $msg = "<div class='alert alert-success'>
      <span class='glyphicon glyphicon-info-sign'></span> &nbsp; successfully registered !
     </div>";
  }
  else
  {
   $msg = "<div class='alert alert-danger'>
      <span class='glyphicon glyphicon-info-sign'></span> &nbsp; error while registering !
     </div>";
  }
 }
 else{


  $msg = "<div class='alert alert-danger'>
     <span class='glyphicon glyphicon-info-sign'></span> &nbsp; sorry email already taken !
    </div>";

 }

 $MySQLi_CON->close();

推荐答案

if(isset($_POST['btn-signup']))

通过http'post'方法将表单提交到php url时 ,该格式中的命名值将以其各自的名称作为键添加到$ _POST中.此行检查php文档是否接收到名为"btn-signup"的值

when a form is submitted to a php url via the http 'post' method , the named values in that form are added to $_POST with their respective names as keys. this line checks if the php document received a value named 'btn-signup'

源表单可能包含类似

<input type="text" name="btn-signup" />

这篇关于if(isset($ _ POST ['btn-signup']))会做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆