简单的验证会话问题

时间:2011-08-03 22:50:38

标签: php session captcha session-variables

我遇到了一个非常荒谬的验证码图像和会话变量问题。

http://paholo.com/npdev/tests/contact_us2.php?add=1&confirm=new#contact

我曾多次使用同样的“联系我们”脚本,但显然现在有些东西已经关闭了。当我在脚本中运行$_session['captchacode']时,它不会存储make_captcha.php 但是当我在脚本之外运行它时,它可以正常工作。

我在session_start()make_captcha.php脚本上都有contact_us2.php

我知道这里有一个简单的答案,但我看不到它。

<?php session_start(); ?>

<!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" lang="en" xml:lang="en">
<head>

<title>Lotus Properties - a Los Angeles Apartment Property Management & Real Estate Company</title>

<?php include_once('includes/functions-nomysql.php'); ?>

</head>

<body>
    <h2>Contact Us</h2>

    <div id="contactform">
<?php
$add = $_GET['add'];
$confirm = $_GET['confirm'];

if (($add == "1") AND ($confirm == "new"))
{
echo $_POST["contact_captcha"];
echo $_SESSION["session_captchaText"];

if (($_POST["contact_captcha"] == $_SESSION["session_captchaText"]) AND ($_POST["contact_captcha"] != "" ))
    {
    if ($_SERVER["REQUEST_METHOD"] <> "POST")
        { // check for a true message post
        die("You can only reach this page by posting from the html form");
        }
    }
else
    {
    $error = "yes";
    $message .= ('<span class="red">Please Enter the Confirmation Code</span><br />');
    }   

if ($error == "yes")
    {       
?>

    <p>Please Make Corrections to the Contact Us Form</p>
    <p><?php echo $message; ?></p>
    <form action="contact_us2.php?add=1&confirm=new#contact" method="POST">
<p>Please Confirm this Code <br /><img src="http://www.paholo.com/npdev/tests/includes/make_captcha.php" /> <br /><input type="text" name="contact_captcha" value="enter code" size="10" width="220" height="50" /></p>
        <p><input type="submit" name="submit" value="Send" /></p>
    </form>
<?php
    }
else
    {

    $mailuser = "$contact_email";

    $header = "Return-Path: mail@lotusproperties.com\r\n"; 
    $header .= "From: Lotus Properties Contact Us <mail@lotusproperties.com>\r\n"; 
    $header .= "Content-Type: text/html;"; 

    $mail_body = ('Thank you for sending in your Contact Us request to <a href="http://www.lotusproperties.com">Lotus Properties</a>. We will respond to your message as soon as possible. Thank you.');    

    if (mail ($mailuser, 'Contact Us', $mail_body, $header))
        {
        echo ('<p>Your Message has been Sent</p>');
        }
    else
        {
        echo ('<p>Problem sending message. <a href="contact_us.php">Try again</a></p>');
        }       

    }
}
else
{
?>
    <form action="contact_us2.php?add=1&confirm=new#contact" method="post" >
<p>Please Confirm this Code <br /><img src="http://www.paholo.com/npdev/tests/includes/make_captcha.php" /> <br /><input type="text" name="contact_captcha" value="enter code" size="10" width="220" height="50" /></p>
        <p><input type="submit" name="submit" value="Send" /></p>
    </form>

<?php
}
?>  
    </div><!-- end of contact form -->
</body>
</html>

0 个答案:

没有答案