In: Computer Science
1) (chapter 3)What is a sticky form?
2)What is the purpose of using the following statements:
if ($_SERVER['REQUEST_METHOD'] = = 'POST') {
// Handle the form.
} else {
// Display the form.
}
3) (PHP Chapter 2) PHP programming: POST and GET methods of a form, how to retrieve the input in the submission php code. $_POST, $_GET(), which way is more secure than the other? Why?
4) You can find how many records get affected in php Which
function to use?
Ans-1) Sticky form in PHP is a standard HTML form that saves that data have been entered in a form. It’s really helpful for end-user because they don’t need to re-type data into the form if there’s an error while submitting.
Ans-2)if ($_SERVER['REQUEST_METHOD'] = = 'POST')
statement is used to check whether the request was done via
$_POST
or $_GET
. $_POST
are
almost always done in some kind of form whether it’d be through
Javascript
or HTML
, you’re still
submitting the form. $_GET
is usually through the
URL
or link. $_GET
can also be passed
through Javascript
using a GET
declaration.
and on basis of this condition, it will display the form if the request was not done via 'POST' else execute the code written in if block.
Ans-3)POST is more secure than GET for a couple of reasons :
GET parameters are passed via URL. This means that parameters are stored in server logs and browser history. When using GET, it makes it very easy to alter the data being submitted the server as well, as it is right there in the address bar to play with.
The problem when comparing security between the two is that POST may deter the casual user, but will do nothing to stop someone with malicious intent. It is very easy to fake POST requests, and shouldn't be trusted outright.
The biggest security issue with GET is not malicious intent of the end-user, but by a third party sending a link to the end-user. I cannot email you a link that will force a POST request, but I most certainly can send you a link with a malicious GET request.
Ans-4)The affected_rows / mysqli_affected_rows() function returns the number of affected rows in the previous SELECT, INSERT, UPDATE, REPLACE, or DELETE query.