PHP HTML Pass Values Through URL

From CoderLearner
Jump to: navigation, search

PHP process data through URL

Processing form data through URL.

Example 1

  • In this example, you pass the value through URL.
$msg = "";
if (!empty($_GET['option'])) {
   $msg = 'Option is: '
           . $_GET['option']
           . ' and Id is: '
           . $_GET['id'] . '<br/>';
} else {
   $msg = 'Please click your option!<br/>';
      <title>Pass value through URL</title>
      <b><?php echo $msg; ?></b>
      <table border="0">
            <td>Operation 1:</td>
               <a href="<?= $_SERVER['PHP_SELF'] ?>?id=1&option=delete">Delete</a>
            <td>Operation 2:</td>
               <a href="<?= $_SERVER['PHP_SELF'] ?>?id=2&option=update">Update</a>
            <td>Operation 3:</td>
            <td><a href="<?= $_SERVER['PHP_SELF'] ?>?id=3&option=view">View</a>
            <td>Operation 3:</td>
            <td><a href="<?= $_SERVER['PHP_SELF'] ?>?id=4&option=add">Add</a>

Try It