Difference between revisions of "PHP 4"
From Ilianko
(→SERVER) |
|||
Line 20: | Line 20: | ||
<input type=submit name=button value="natisni"> | <input type=submit name=button value="natisni"> | ||
</form> | </form> | ||
+ | </pre></code> | ||
+ | |||
+ | |||
+ | == SERVER == | ||
+ | |||
+ | <?php | ||
+ | print_r($_SERVER) | ||
+ | ?> | ||
+ | |||
+ | <?php | ||
+ | if($_SERVER['REQUESTED_METHOD'] == 'POST') | ||
+ | { | ||
+ | echo 'OK'; | ||
+ | } | ||
+ | ?> | ||
+ | |||
+ | == SESSION == | ||
+ | |||
+ | <code><pre> | ||
+ | <?php | ||
+ | |||
+ | echo 'old: '; | ||
+ | print_r($_SESSION); | ||
+ | |||
+ | echo '<br /> new: '; | ||
+ | print_r($_POST); | ||
+ | ?> | ||
+ | |||
+ | <form method=POST> | ||
+ | <input type=text name=user> | ||
+ | <input type=submit name=button value="natisni"> | ||
+ | </form> | ||
+ | |||
+ | |||
+ | <?php | ||
+ | |||
+ | $_SESSION['user'] = $_POST; | ||
+ | ?> | ||
</pre></code> | </pre></code> | ||
Line 46: | Line 84: | ||
?> | ?> | ||
</pre></code> | </pre></code> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 14:30, 20 October 2013
GET
<?php print_r($_GET) ?>
POST
<?
print_r($_POST)
?>
<form method=POST>
<input type=text name=user>
<input type=submit name=button value="natisni">
</form>
SERVER
<?php print_r($_SERVER) ?>
<?php if($_SERVER['REQUESTED_METHOD'] == 'POST') { echo 'OK'; } ?>
SESSION
<?php
echo 'old: ';
print_r($_SESSION);
echo '<br /> new: ';
print_r($_POST);
?>
<form method=POST>
<input type=text name=user>
<input type=submit name=button value="natisni">
</form>
<?php
$_SESSION['user'] = $_POST;
?>
COOKIE
<?php
echo 'old: ';
print_r($_COOKIE['user']);
echo '<br /> new: ';
print_r($_POST['user']);
?>
<form method=POST>
<input type=text name=user>
<input type=submit name=button value="natisni">
</form>
<?php
setcookie("user", $_POST['user']);
?>