If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
पिछले Topic में हमने Form को $_GET Super Global Variable के through handle करना सीखा , इस topic में में $_POST Super Global Variable के बारे में detail से पढ़ेंगे।
$_POST Super Global Variable है means $_POST के through form data access करने के लिए हमें इस global variable बनाने की जरूरत नहीं होती , PHP Script में इसे कहीं भी access कर सकते हैं। $_POST का use PHP में Post / post Method के साथ submit किये गए Form को handle ( Extracting Form Input Data) करने के लिए use किये जाता है। Form को Handle करने का यह सबसे reliable और अच्छा method है।
$_GET की तरह ही $_POST भी Submitted Form Data को एक Array में store करता है , जिसे हम input field name के साथ आसानी से access कर सकते हैं।
$_POST और $_GET में सबसे बड़ा difference यही कि $_GET का use हम get / Get method के साथ submit हुए form या किसी URL में query string से data को access करने के लिए किया जाता है , जबकि $_POST का use हम Post / post Method के साथ submit किये गए Form को handle ( Extracting Form Input Data) करने के लिए use किये जाता है।
File : form.html
<!DOCTYPE html>
<html>
<head>
<title>Form Handling Using $_POSt</title>
</head>
<body>
<form action="post.php" method="post">
<p>Full Name : <input type="text" name="full_name" placeholder="Enter Full Name" /></p>
<p>Age : <input type="number" name="age" min="0" max="120" placeholder="Enter Address" /></p>
<p>Address : <input type="text" name="address" placeholder="Enter Address" /></p>
<p><button type="submit">Submit</button></p>
</form>
</body>
</html>
Another File where we will access form data : post.php
<?php
/* here we will handle submitted form*/
echo 'Entered All Values : <pre>';
print_r($_GET);
echo '</pre>';
echo 'Your Full Name : '.$_POST['full_name']."<br>";
echo 'Your Age : '.$_POST['age']."<br>";
echo 'Your Age : '.$_POST['address'];
?>
दूसरी image में आप साफ़ देख सकते हैं कि जिस Form Action में Form को handle करने के लिए जिस file का नाम दिया था , Form Submit होने के बाद Data get / Get method की तरह query string में append नहीं होता है।
Note - $_POST के through हम सिर्फ Post / post method के साथ Submit किये गए Form Data को ही access कर सकते हैं। Get / get method के साथ Submit किये गए Form Data को $_POST के through कभी भी access नहीं कर सकते हैं।
Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.
Get connected with me. :) LinkedIn Twitter Instagram Facebook