php代码不能在表单上提交ie(但在chrome,ff上工作正常)

时间:2012-05-05 11:50:49

标签: php html forms form-submit

我做了一个登录/注册页面。它在chrome和firefox上工作正常,但在Internet Explorer上不起作用(8,9)。单击任何提交按钮后,即重定向到索引页面。我在基于此代码的其他页面上遇到了同样的问题。

这是html代码:

<?php

$log_in=false;
$token_sent=0;
$errors1 = array();
$missing1 = array();
$errors = array();
$missing = array();

if(isset($_POST['submit'])){
     $expected = array('login', 'email', 'pwd');
     $required = array('login', 'email', 'pwd');
     require('./rejestracja.inc.php');
}

if ($token_sent) {
    header('Location: (..) '); 
    exit;
}

if(isset($_POST['submit1'])) {
    $expected=array('login1','pwd1');
    $required=array('login1','pwd1');
    require('./login.inc.php');

    if($log_in) {
        if (isset($_SESSION['name']) && !empty($_SESSION['name'])) {
            unset($_SESSION['login1']);
            if (isset($_COOKIE[session_name()])) {
                setcookie(session_name(), '', time()-86400, '/');
            }
            session_destroy();
        }

        if (isset($_POST['login1'])) {
            session_start();
            $_SESSION['name'] = $login1 ;
        }
        header('Location: http:// (...) ');  
        exit;
    }
}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title></title>
    <meta name="description" content="">
    <meta name="copyright" content="Copyright (c) 2012 k">
    <meta name="author" content="">
    <link href="style.css" rel="stylesheet" type="text/css" media="screen">
    <link href="login.css" rel="stylesheet" type="text/css" media="screen"> 
</head>

<body>
<div id="wrap">
    <?php include('./login_menu.inc.php');?>
    <div id="header">
        <h1></h1>
    </div>
    <?php include('./fb.inc.php');?>
    <?php include('./menu.inc.php');?>
    <?php include('./w_budowie.inc.php');?>

    <div id='left'>
        <div id='info'>
            <h1 class='title'>LOGIN</h1> <br/>
            <form class='form' name="login1" action=" " method="post">


                <?php if ($missing1) { ?>
            <span class="warning">...</span><br/>
            <?php } ?>

            <?php if(isset($errors1['wrong'])){ ?>
            <span class="warning">...</span><br/>
            <?php } ?>

            <?php if(isset($errors1['not_verified'])){ ?>
            <span class="warning">...</span><br/>
            <?php } ?>

            <label for="login1">Login: </label>
            <input type="text" name="login1" 
            <?php if ($missing1 || $errors1) {
            echo 'value="' . htmlentities($login1, ENT_COMPAT, 'UTF-8') . '"';
            } ?>
            />

            <br/>           
            <label for="pwd1">Password:</label>
            <input type="password" name="pwd1" /> <br/>

            <br/>           
            <span class='submit'><input name="submit1" type="submit" value="LOGIN" /></span>
            </form> 

            <br/>
        </div>  
    </div>

    <div id='right'>
        <div id='info'>
            <h1 class='title'>REGISTRATION</h1> <br/>
            <form class='form' name="register" action=" " method="post">

                <label for="login">Login: </label>
                <input type="text" name="login" 
                <?php if ($missing || $errors) {
                echo 'value="' . htmlentities($login, ENT_COMPAT, 'UTF-8') . '"';
                } ?>
                /> 
                      <?php if ($missing && in_array('login', $missing)) { ?>
                      <span class="warning">...</span>
                      <?php 
                       } elseif(isset($errors['login_mini'])){ ?>
                      <span class="warning">...</span>
                      <?php 
                       } elseif(isset($errors['login_maxi'])){ ?>
                      <span class="warning">...</span>
                       <?php
                       } elseif(isset($errors['login'])){ ?>
                      <span class="warning"> A-Z, a-z, 0-9.</span>
                      <?php 
                       } elseif(isset($errors['login_exist'])){ ?>
                      <span class="warning">...</span>
                       <?php } ?>

                <br/>


                <label for="email">Email: </label>
                <input type="text" name="email"
                <?php if ($missing || $errors) {
                echo 'value="' . htmlentities($email, ENT_COMPAT, 'UTF-8') . '"';
                } ?>
                /> 
                    <?php if ($missing && in_array('email', $missing)) { ?>
                      <span class="warning">...</span>
                      <?php } elseif(isset($errors['email'])){ ?>
                      <span class="warning">...</span>
                      <?php } elseif(isset($errors['email_exist'])){ ?>
                      <span class="warning">...</span>
                       <?php } ?>

                <br/>

                <label for="pwd">Password:</label>
                <input type="password" name="pwd" />
                <?php if ($missing && in_array('pwd', $missing)) { ?>
                      <span class="warning">...</span>
                      <?php 
                       } elseif(isset($errors['pwd_mini'])){ ?>
                      <span class="warning">...</span>
                      <?php 
                       } elseif(isset($errors['pwd_maxi'])){ ?>
                      <span class="warning">...</span>
                       <?php } ?>       
                <br/>
                <span class='submit'><input type="submit" name="submit" value="REGISTER" /></span>          
            </form>
            <br/>
        </div>  
    </div>
    <?php include('./footer.inc.php'); ?>
</div>
</body>
</html>

这是'login.inc.php'代码:

<?php

$login1 = "";
$pwd1 = "";
$salt = "(...)";


/*---------------con------------------------*/
include('./sql_connect.inc.php');

/*---------------------------------------------*/
foreach ($_POST as $key => $value) {
     $temp = is_array($value) ? $value : trim($value);
     if (empty($temp) && in_array($key, $required)) {
          $missing1[] = $key;
     } elseif (in_array($key, $expected)) {
          ${$key} = $temp;
     }
}


if(!$missing1){
     $login1 = mysql_real_escape_string($login1); 
     $hash = $salt . $pwd1;
     for ( $i = 0; $i < 100; $i ++ ){
         $hash = hash('sha256', $hash);
     }

/*---------------COMPARE-----------------*/
      $result = mysql_query("SELECT user_nick='$login1' FROM users WHERE user_password='$hash'") or die('Sorry, we could not count the number of results: ' . mysql_error());
     if($result){
          if(mysql_result($result, 0)){

/*-------IS ACTIVATED?------------------------------*/
              $verified =  mysql_query("SELECT user_verified='yes' FROM users WHERE user_nick='$login1'");
              if($verified){
                  if(mysql_result($verified, 0)){
                      $log_in=true;          
                  }else{
                       $errors1['not_verified'] = true; 
                  }
               }
          }else{
               $errors1['wrong'] = true;    
          }
     }
}
mysql_close($con);

?>

1 个答案:

答案 0 :(得分:1)

你真的在使用<form class='form' name="register" action=" " method="post">吗? 它可以来自这里,尝试使用action="#"

PHP不存在任何跨浏览器问题,它来自HTML(生成与否)