forked from bradtraversy/php-crash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10_get_post.php
More file actions
32 lines (26 loc) · 705 Bytes
/
10_get_post.php
File metadata and controls
32 lines (26 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
/* --- $_GET & $_POST Superglobals -- */
/*
We can pass data through urls and forms using the $_GET and $_POST superglobals.
*/
if (isset($_POST['submit'])) {
// echo '<h3>' . $GET['username'] . '</h3>';
echo '<h3>' . $_POST['username'] . '</h3>';
} ?>
<!-- Pass data through a link -->
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?username=Brad">Link</a>
<br><br>
<!-- Pass data through a form -->
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<div>
<label>Name: </label>
<input type="text" name="name">
</div>
<br>
<div>
<label>Password: </label>
<input type="password" name="password">
</div>
<br>
<input type="submit" name="submit" value="Submit">
</form>