Step 1: Create post_form.php file under apache DocumentRoot location. In my case, I configured it to the location /usr/local/var/www.
post_form.php
<form method = "POST">
    <label for = "name">Enter your name:</label>
    <input type = "text" name = "name"/><br />
    <button type="submit">Submit</button>
</form>
<?php
    if(isset($_POST['name'])){
        $my_name = $_POST['name'];
        echo "Hello $my_name, very good morning!!!!!";
    }
   
?>
Step 2: Restart httpd server by executing below command.
apachectl restart
Step 3: Open the url ‘http://localhost:8080/post_form.php’ in browser, you will see a form page.
Enter your name and click on Submit button, you will see a welcome message.
 
  


No comments:
Post a Comment