20c03-2.php

来自「介绍PHP5的给类型函数应用」· PHP 代码 · 共 38 行

PHP
38
字号
<?php// Start the PHP sessionsession_start();// If this page was submitted back to itself:if (count($_POST)) {	// Ensure that a session captcha was set:	if (isset($_SESSION['captcha'])) {		// See if this one matches the submitted value:		if ($_SESSION['captcha'] === strtoupper($_POST['check'])) {			// We have a valid match!  The most important thing to do now 			// is destroy the previous captcha entry so that they can't 			// just resubmit this same form again!			unset($_SESSION['captcha']);						// Now the script should do it's action, redirect, etc.			// For now, we are just going to say congratz			echo "<p>Congratulations, you typed it in correctly!</p>\n";		} else {			// Bad attempt -- Let them know it was wrong, this page will			// then continue and give them a new one anyway.			echo "<p>Sorry, that wasn't it, try again!</p>\n";		}	} else {		// The session captcha variable wasn't set, this means that someone		// submitted successfully once, then tried to spam us with the same		// session information.		echo "<p>Sorry, no spamming aloud!  Go away!  Shoo!</p>\n";	}}?><form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">Please enter the text that you see in the following graphic:<br /><!-- <img src="captcha.php" /><br /> --><img src="20c03-1.php" /><br /><input name="check" type="text"><br /><input name="Submit" type="submit"></form>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?