簡體   English   中英

php標頭在xxamp上本地工作,但不在godaddy服務器上

[英]php header working locally on xxamp but not on godaddy server

我想重定向到adm/index.php文件if($count==1) ,但是頁面只是刷新並停留在同一頁面上。

我嘗試了幾種解決方案,但無濟於事:

  1. 在開始<?php>之前檢查空格
  2. 在開始<?php>之前刪除了所有html鏈接

在xxamp上本地一切正常,但是問題是上傳后,沒有錯誤消息; 只是同一頁面刷新而為空白。

在主程序中有兩個函數被調用。 主程序還包含一些回聲。 是否可以使標題正常工作?

$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM adminlogin WHERE username = '$myusername' and password ='$mypassword'";
$result=mysql_query($sql); // from adminlogin table, ngetasacco
$sql2="SELECT * FROM memberslogin WHERE username = '$myusername' and password ='$mypassword'";
$result2=mysql_query($sql2); // from the memberslogin table, ngetasacco

// Mysql_num_row is counting table row
$count = mysql_num_rows($result);
$count2 = mysql_num_rows($result2);

// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)// only the admin
{
$_SESSION['myusername'] = myusername;
$_SESSION['mypassword'] = mypassword;
header("location: adm/index.php");
}
elseif($count2==1)// any registered member with access
{
$_SESSION['myusername'] = myusername;
$_SESSION['mypassword'] = mypassword;
header("location: adm/member.php");
}
else {
echo "<musuya>Wrong username or Password</musuya><br/><br/>";
//echo md5($mypassword);
//$m=md5($mypassword);
usernamePass();
}
ob_end_flush();
}// end of function auth()
function usernamePass()
{
echo "<form method='post' action=" . $_SERVER['PHP_SELF'] . ">";
echo " username <input type='text' name='username' /><br/><br/>";
echo "password <input type='password' name='password' value=''/><br/>";
echo "<input type='submit' value='Login' />";
}// end of function usernamePass()
//++++++++++++++++++++++++++main program
+++++++++++++++++++++++++++++++++++
if(empty($_POST["username"]) || empty($_POST["password"]))
{ 
echo"username and pasword cannot be empty</br></br>";
usernamePass();
}
if(!(empty($_POST["username"])) && !(empty($_POST["password"])))
{
auth();
}
if(!empty($_GET['status']))
{
echo '<div>You have been logged out!</div>';
}      
//++++++++++++++++++++++++ end of main program
++++++++++++++++++++++++++++++
?>

connections / db_connect.php

<?php
$host="";// Host name
$username="";//Mysql username
$password="";//Mysql password
$db_name="";//Database name
$tbl_name="";//Table name
//Connect to server and select databse.
mysql_connect("$host", "$username", "$password");//or die("cannot connect");
mysql_select_db("$db_name");//or die("cannot select DB");
//echo "connected to server and dbase";
?>

添加ob_end_flush(); 在文件底部並檢查它

<?php
function auth(){
ob_start();
include"connections/db_connect.php";
// Define $myusername and $mypassword
$myusername=md5($_POST['username']);
$mypassword=md5($_POST['password']);
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM adminlogin WHERE username = '$myusername' and password     = '$mypassword'";
$result=mysql_query($sql); // from adminlogin table, ngetasacco
$sql2="SELECT * FROM memberslogin WHERE username = '$myusername' and     password = '$mypassword'";
$result2=mysql_query($sql2); // from the memberslogin table, ngetasacco
// Mysql_num_row is counting table row
$count = mysql_num_rows($result);
$count2 = mysql_num_rows($result2);
// If result matched $myusername and $mypassword, table row must be 1 row
//if($count==1){
if($count==1)// only the admin
{
    $_SESSION['myusername'] = myusername;
    $_SESSION['mypassword'] = mypassword;
    //header("location: login_success.php");
    header("location: adm/index.php");
}
ob_end_flush();
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM