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> successfully registered !
</div>";
}
else
{
$msg = "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> error while registering !
</div>";
}
}
else{
$msg = "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> sorry email already taken !
</div>";
}
$MySQLi_CON->close();
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'
the source form might contain something like