同一页面上的两个表单和php脚本无法正常工作

时间:2015-07-27 09:23:35

标签: php sql

有两种形式,一种是注册形式,另一种是登录形式。当注册表格注册时,其div元素是使用isset功能从php获取消息但是当我做同样的事情时登录它是重定向页面到主页请帮助我该怎么办如果我想匹配数据库如果不匹配它将从PHP获取值并显示在代码中的div

    <?php 
    if (!empty($_POST['finish'])) {
       //do something here;
    include'php/signup.php';
    }

    if (!empty($_POST['go'])) {
       include'php/signin.php';
    }
    ?>      

    <html>
    <head>        
    <link rel="stylesheet" type="text/css" href="css/homepage.css">
    <link rel="stylesheet" type="text/css" href="css/login.css">
    <link rel="stylesheet" type="text/css" href="css/signup.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="js/login.js"></script> 
    <script src="js/signup.js"></script>        
    <script>
    function hideMessage() {
        document.getElementById("message").style.display = "none";
    };
    setTimeout(hideMessage, 5000);
    </script>
    </head>
    <body >
    <!--row starts here -->

    <div class="row">
    <div class="col-1-2">
    </div>
    <div class="col-1-2">
       <div class="container">

      <ul class="tabs">
        <li class="tab-link current" data-tab="tab-1">Sign Up</li>
        <li class="tab-link" data-tab="tab-2">Sign In</li>            
      </ul>        
      <div id="tab-1" class="tab-content current">            
    <div id="message"><?php if(isset($message)) echo $message; ?></div>
    <ul id="registration-step">
    <li id="account" class="highlight">Account</li>
    <li id="password">Password</li>
    <li id="general">Nick Name</li>
    </ul>
    <form name="frmRegistration" id="registration-form" method="post">
    <div id="account-field">
    <span id="email-error" class="registration-error"></span>
    <div><input type="text" name="email" id="email" class="demoInputBox" placeholder="E-mail"/></div>
    </div>        
    <div id="password-field" style="display:none;">
    <span id="password-error" class="registration-error"></span>
    <div><input type="password" name="password" id="user-password" class="demoInputBox" placeholder="Password"required /></div>        
    </div>        
    <div id="general-field" style="display:none;">        
    <div><input type="text" name="nickname" id="display-name" class="demoInputBox" placeholder="Nick Name"/></div>        
    </div>
    <div>
    <input class="btnAction" type="button" name="back" id="back" value="Back" style="display:none;">
    <input class="btnAction" type="button" name="next" id="next" value="Next" >
    <input class="btnAction" type="submit" name="finish" id="finish" value="Finish"  style="display:none;">
    </div>
    </form>        
    </div>     
     <div id="tab-2" class="tab-content">
    <div id="signinmsg"><?php if(isset($msg1)) echo $msg1; ?></div> 
    <form  name="signin"method="post">
        <input type="text" name="signinemail"class="demoInputBox"placeholder="E-mail">
        <br><br>
        <input type="text" class="demoInputBox"name="signinpass"placeholder="Password"><br><br>
    <input class="btnAction" type="submit" name="go" id="go" value="Go.." >     
    </form>
    </div> 
    </div>
    </div>        
    <!--this row ends here -->        
  </body>        
    </html>

1 个答案:

答案 0 :(得分:0)

您应该检查isset而不是!empty

<?php 
    if (isset($_POST['finish'])) {
       //do something here;
    include'php/signup.php';
    }

    if (isset($_POST['go'])) {
       include'php/signin.php';
    }
?>