php文件在localhost上工作,但不在服务器上

时间:2015-03-25 12:42:59

标签: php mysql

这是我的注册php页面..!

当我在 localhost 上注册时,它运行正常,并将我重定向到feedsomeinfo.php

但在服务器

它正在重定向我的login_attempt.php

为什么会发生这种情况?

 <?php

    // Report runtime errors
    error_reporting(E_ERROR | E_WARNING | E_PARSE);

    // Report all errors
    error_reporting(E_ALL);

    // Same as error_reporting(E_ALL);
    ini_set("error_reporting", E_ALL);

    // Report all errors except E_NOTICE
    error_reporting(E_ALL & ~E_NOTICE);

    session_start();
    include("config.php");
    function clean($str) {
    $str = @trim($str);
    if(get_magic_quotes_gpc()) {
    $str = stripslashes($str);
    }
            return mysql_real_escape_string($str);
        }
    $user=$_SESSION['SESS_MEMBER_ID'];
    $invitecount=5;
    $fname=ucfirst(clean($_POST['fname']));
    $lname=ucfirst(clean($_POST['lname']));

    $usern=clean($_POST['usern']);
    $emailadd=clean($_POST['emailadd']);
    $password=mysql_real_escape_string($_POST['password']);
     $password= sha1($password); 


    $num='1';
    mysql_query("INSERT INTO members(fname, lname, invitecount, usern, email, password,  profilepic, coverphoto,number)
    VALUES('$fname', '$lname', '$invitecount', '$usern', '$emailadd', '$password', 'profilepic/friends.png', 'coverphotos/cover.png', '$num')");



         //Create query
        $result=mysql_query("SELECT * FROM members WHERE email = '$emailadd' AND password = '$password'");

            if(mysql_num_rows($result) > 0) {
                //Login Successful
                session_regenerate_id();
                $member = mysql_fetch_assoc($result);
                $_SESSION['SESS_MEMBER_ID'] = $member['id'];
                $_SESSION['SESS_FIRST_NAME'] = $member['fname'];
                $id=$member['id'];
                $name=$member['fname'];
                $number=$member['number'];
                $expires = 1 * 1000 * 60 * 60 * 24;
              setcookie("email", $emailadd, time()+$expires);
        setcookie("password", $password, time()+$expires);
                mysql_query("insert into logged(logid,logdin) VALUES('$id', '$name') ");
                if($number=='1')
                { header("location: feedsomeinfo.php");

                }
                else
                { header("location: timewall.php");

                }

            }
            else{
                header("location: login_attempt.php");
                exit();
            }



    mysql_close($bd);
    ?>

编辑: - 值未保存在数据库中

当我尝试这段代码时

<?php error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set('display_errors', 1);
error_reporting(E_ALL);
ini_set("error_reporting", E_ALL);
error_reporting(E_ALL & ~E_NOTICE);

session_start();
include("config.php");
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
        return mysql_real_escape_string($str);
    }
$user=$_SESSION['SESS_MEMBER_ID'];
$invitecount=5;
$fname=ucfirst(clean($_POST['fname']));
$lname=ucfirst(clean($_POST['lname']));
$emailadd=clean($_POST['emailadd']);
$password=mysql_real_escape_string($_POST['password']);
 $password= sha1($password); 

$num='1';
mysql_query("INSERT INTO members(fname, lname, invitecount , email, password,  profilepic, coverphoto,number)
VALUES('$fname', '$lname', '$invitecount', '$emailadd', '$password', 'profilepic/friends.png', 'coverphotos/cover.png', '$num')");

// removed to redirect to next page and user have to login again :(

mysql_close($bd);
?>

d值存储在数据库中......!

1 个答案:

答案 0 :(得分:0)

在你的情况下,我会检查:

  • 如果数据库连接正常
  • 如果数据库行是这样的话 相同
  • or die(mysql_error());添加到您的查询中并检查是否存在 是一些错误
  • 将扩展程序安装到浏览器firebug并检查 在您提交注册表时,请记录一下。查找POST数据 和你的回应。