Jump to: navigation, search

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

Php form pass url 1.png


Related Links


  1. HTML POST
  2. HTML GET
  3. HTML Textarea
  1. HTML Hidden Field
  2. HiddenField Multiple Pages
  3. HTML Password
  1. HTML Textbox
  2. HTML Checkbox
  3. HTML Radio
  1. Drop down list
  2. Pass value uses URL
  3. Pass value uses URL 2.
  4. Multiple Submit Buttons
Navigation
Web
SQL
MISC
References