English 中文(简体)
在当地工作但并不在生活环境中工作
原标题:Login Script working local but not on live environment
  • 时间:2012-01-13 17:01:14
  •  标签:
  • php

I seem to have a problem with a login script, it works on a local php dev box, but not on my live environment, i m assuming i m missing something can anyone advise further?

<?php
$user = $_POST["swtorun"];
$pass = $_POST["swtorpw"];

// Generate hash
$enc_pwd = hash( sha256 , $pass);

// Connect to DataBase
include( ../../settings.php );

$conn = mysql_connect($host,$username,$password);
$db = mysql_select_db($database, $conn);

// mySql Query users
$sql = "SELECT * FROM `users` WHERE username= $user  and password= $enc_pwd ";
$result = mysql_query($sql, $conn);

$count = mysql_num_rows($result); // number of results (should be 1)

if($count==1){
// initiate session
session_start();
$_SESSION[ logged ] = "1";
echo "you are now logged in, return to the <a href="../../index.php">index</a>";
} else {
echo "Wrong Username or Password";
}
?>
最佳回答

The issue turned out to be that I had the table name capitalised on one script, but lower case on this script, hence the query failed and so did the code relying on it, I have since fixed the other script to create the table in lower case.

由于在帮助解决麻烦问题上留下的所有压力。

问题回答

增加<代码>session_start();至贵系统编码的顶端。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签