douxiuar885064 2015-07-27 09:23
浏览 54

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

there are two forms one is registration form and another is sign in form .When am registring with registration form its div element is fetching message from php using isset funtion but when i am doing same thing with sign in it is redirecting page to homepage please help what can i do if am trying to match database if not matched it will fetch value from php and show in the div as in the code

    <?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条回答 默认 最新

  • dongpu2727 2015-07-27 09:29
    关注

    You should be checking if isset and not !empty

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

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?