PHP HTML Passes Value Through URL without submit and form
From w3cyberlearnings
Contents |
PHP process data through URL
Processing form data through URL. It is not using any form to send a data, it uses <a>. See the example.
Example 1
- In this example, you pass the value through URL.
<?php $msg = ""; if (!empty($_GET['option'])) { $msg = 'Option is: ' . $_GET['option'] . ' and Id is: ' . $_GET['id'] . '<br/>'; } else { $msg = 'Please click your option!<br/>'; } ?> <html> <head> <title>Pass value through URL</title> </head> <body> <b><?php echo $msg; ?></b> <table border="0"> <tr> <td>Operation 1:</td> <td><a href="<?php echo $_SERVER['PHP_SELF'] ?>?id=1&option=delete">Delete</a></td> </tr> <tr> <td>Operation 2:</td> <td><a href="<?php echo $_SERVER['PHP_SELF'] ?>?id=2&option=update">Update</a> </tr> <tr> <td>Operation 3:</td> <td><a href="<?php echo $_SERVER['PHP_SELF'] ?>?id=3&option=view">View</a> </tr> <tr> <td>Operation 3:</td> <td><a href="<?php echo $_SERVER['PHP_SELF'] ?>?id=4&option=add">Add</a> </tr> </table> </body> </html>
Output
Related Links
- Drop down list
- Pass value uses URL
- Pass value uses URL 2.
- Multiple Submit Buttons