This is Client-Side Validation. Validation is performed on the client machine web browsers.
Forms can be submitted to the web page itself using PHP. The main purpose of submitting forms to self is for data validation. Data validation means checking for the required data to be entered in the form fields.

EXAMPLE

<form action="<?=($_SERVER['PHP_SELF'])?>" method="POST">
<label>insert data</label>
<input type="text" name="somename">
<input type="submit" value="press">
</form>

<?php
$a=$_POST["somename"];
echo $a;
 ?>

result:






$_SERVER["PHP_SELF"] sends the submitted form data to the page itself, no jumping to a different page.
If it is necessary to move to the next page, it is necessary to enter the name of that page (for example: filename.php) instead in "action".






Privacy Policy