12c02-3.php
来自「介绍PHP5的给类型函数应用」· PHP 代码 · 共 50 行
PHP
50 行
<?php// The Edit page// First we need to check if they are logged in, and if not, make them:session_start();if (!(isset($_SESSION['valid']) && $_SESSION['valid'])) { // Back to login for you header('Location: login.php'); exit();}// Secondly, see if this was a post, if so, save the data into the session$msg = '';if (count($_POST)) { // Save the data $_SESSION['name'] = $_POST['fname']; $_SESSION['color'] = $_POST['fcolor']; // Prepare a message $msg = 'Your data was saved.';}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Edit</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><style>form { border: 1px solid black; padding: 10px; }#note { color: #00CC00; font-weight: bold; }</style></head><body><?php // If we have a message:if ($msg) { echo "<p id=\"note\">{$msg}</p>\n"; }?><p>Here you can edit data that will remain valid for this browsing session.</p><form action="<?= $_SERVER['PHP_SELF'] ?>" method="post"><p>What is your full name?<input type="text" name="fname" value="<?= @$_SESSION['name'] ?>" /></p><p>What is your favorite color?<input type="text" name="fcolor" value="<?= @$_SESSION['color'] ?>" /></p><p><input type="submit" value="Save my preferences" /></p></form><!--<p>Options: | <a href="view.php">View Data</a> | <a href="login.php?logoff=true">Log Off</a> |</p>--><p>Options: | <a href="12c02-2.php">View Data</a> | <a href="12c02-1.php?logoff=true">Log Off</a> |</p></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?