Handling Form किसी भी PHP Developer द्वारा किए गए सबसे सामान्य कार्यों में से एक है. क्योंकि सामान्य रूप से हम Form के द्वारा हमारे Web Application के साथ User Interaction को बनाते है.
PHP मे form-data को Collect करने के लिए Superglobals $_GET और $_POST का उपयोग किया जाता है.
<!DOCTYPE html>
<html>
<head>
<title>Form Handling Example</title>
</head>
<body>
<h2>Form Handling Example</h2>
<p>Please fill in this form and send us.</p>
<form action="process-form.php" method="post">
<p>
<label for="inputName">Name:<sup>*</sup></label>
<input type="text" name="name" id="inputName">
</p>
<p>
<label for="inputEmail">Email:<sup>*</sup></label>
<input type="text" name="email" id="inputEmail">
</p>
<p>
<label for="inputSubject">Subject:</label>
<input type="text" name="subject" id="inputSubject">
</p>
<p>
<label for="inputComment">Message:<sup>*</sup></label>
<textarea name="message" id="inputComment" rows="5" cols="30">
</textarea>
</p>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</body>
</html>
किसी Particular Form Field की Value तक पहुंचने के लिए आप बहुत से Superglobals Variables का उपयोग कर सकते हैं.
Superglobal | Description |
---|---|
$_GET | Get Method यानी (URL Parameters) का उपयोग करके सभी Field Names और Form द्वारा भेजी गई मान की एक सूची है. |
$_POST | Post Method का उपयोग करके सभी Field Names और Form द्वारा भेजी गई मान की एक सूची है. लेकिन इसमे Data URL में दिखाई नहीं देता है. |
$_REQUEST | इसमें $ _GET और $ _POST Variables के मान के साथ-साथ $ _COOKIE Superglobal Variable के मान भी शामिल होते है. |