server request method in php code example
Example 1: php server self
<form action="<?php echo $_SERVER['PHP_SELF']; ?>">
//there is no reason to use this to submit form data to the same page
<form action="">
//will do the same thing
Example 2: php server name
echo $_SERVER['PHP_SELF'];
echo "<br>";
echo $_SERVER['SERVER_NAME'];
echo "<br>";
echo $_SERVER['HTTP_HOST'];
echo "<br>";
echo "<br>";
echo $_SERVER['HTTP_USER_AGENT'];
echo "<br>";
echo $_SERVER['SCRIPT_NAME'];
Example 3: php check request method
$_SERVER['REQUEST_METHOD']
Example 4: what does $request do in php
$message = "";
if($_REQUEST['msg'] == "new"){
$message = "New User has been added successfully";
}else if($_REQUEST['msg'] == 'edit'){
$message = "User has been saved successfully";
}else if($_REQUEST['msg'] == 'update'){
$message = "User(s) has been Updated successfully";
}