Php 为什么不';是否显示我的表单会话消息?(Jquery?)

Php 为什么不';是否显示我的表单会话消息?(Jquery?),php,jquery,Php,Jquery,我在这里有一个页面:没有显示我的会话消息: 我一直在试图找出他们到底出了什么问题,但不知道。他们在其他页面上工作,但这一页不工作 有人能帮我找出我犯的错误吗 根据请求,这里有一些可能相关的代码: schedule-dev.php 您不需要将session_start()添加到php文件中吗?试着这样做,如果有帮助,请告诉我 我不得不在保存方法中使用$this电子邮件 我需要把这个表格做成一个实际的邮寄表格 会话消息没有被输出(?),因为它没有捕获post变量 我会把代码贴在这里,但它很长。我希望

我在这里有一个页面:没有显示我的会话消息:

我一直在试图找出他们到底出了什么问题,但不知道。他们在其他页面上工作,但这一页不工作

有人能帮我找出我犯的错误吗

根据请求,这里有一些可能相关的代码:

schedule-dev.php


您不需要将session_start()添加到php文件中吗?试着这样做,如果有帮助,请告诉我

  • 我不得不在保存方法中使用$this电子邮件
  • 我需要把这个表格做成一个实际的邮寄表格
  • 会话消息没有被输出(?),因为它没有捕获post变量

  • 我会把代码贴在这里,但它很长。我希望这不是坏事Etiquette必须发布您认为相关的代码。Nope=(会话已经从其中一个include开始了
    <?php require_once("../includes/initialize.php"); ?>
    <?php $schedules = Schedule::find_all();?>
    <?php $messages = Messages::find_by_id(1);?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <script src="jquery-1.2.6.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function(){
    
            $("#contactLink").click(function(){
                if ($("#contactForm").is(":hidden")){
                    $("#contactForm").slideDown("slow");
                }else{
                    $("#contactForm").slideUp("slow");
                }
            });
    
        });
    
        function closeForm(){
            $("#messageSent").show("slow");
            setTimeout('$("#messageSent").hide();$("#contactForm").slideUp("slow")', 2000);
        }
    </script>
    
    <?php 
    if(isset($_POST['signupSubmit'])){
        $signup = new Signup();
        $signup->name = $_POST['name'];
        $signup->age = $_POST['email'];
        if($signup->save()) {
            $session->message("We will contact you with details.");
            redirect_to('schedule.php');
        } else {
            $message = join("test", $signup->errors);
        }
    }
    ?>
    <?php echo output_message($message); ?>
        <div id="contactFormContainer">
            <div id="contactLink"></div>
            <div id="contactForm">
                <fieldset>
                    <label for="name">Name *</label>
                    <input id="name" type="text" />
                    <label for="email">Email address *</label>
                    <input id="email" type="text" />
                    <input id="sendMail" type="submit" name="signupSubmit" onclick="closeForm()" />
                    <span id="messageSent"></span>
                </fieldset>     
            </div>
        </div>
    
    <?php
    // If it's going to need the database, then it's 
    // probably smart to require it before we start.
    require_once(LIB_PATH.DS.'database.php');
    
    class Signup extends DatabaseObject {
    
        protected static $table_name="signup";
        protected static $db_fields=array('id', 'name','email');
        public $id;
        public $name;
        public $email;
    
        public $errors=array();
    
        public function save() {
            // A new record won't have an id yet.
            if(isset($this->id)) {
                // Really just to update the name
                $this->update();
                return true;
            } else {
                // Make sure there are no errors
                // Can't save if there are pre-existing errors
                if(!empty($this->errors)) { return false; }
    
                // Make sure the name is not too long for the DB
                if(strlen($this->name) >= 255) {
                    $this->errors[] = "Name must be <= 255 characters long.";
                    return false;
                }
                if(strlen($this->email) >= 255) {
                    $this->errors[] = "Email must be <= 255 characters long.";
                    return false;
                }
                if(empty($email)) {
                    $this->errors[] = "Please enter an email address";
                    return false;
                }
                //Finally add the item to the DB
                if($this->create()) {
                    return true;
                } else {
                    // 
                    $this->errors[] = "Send failed, please contact us";
                    return false;
                }
            }
        }
    
    public function message($msg="") {
      if(!empty($msg)) {
        // then this is "set message"
        // make sure you understand why $this->message=$msg wouldn't work
        $_SESSION['message'] = $msg;
      } else {
        // then this is "get message"
            return $this->message;
      }
    }