Skip to main content

Login Script working local but not on live environment



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";

}

?>




Comments

  1. Add session_start(); to the topmost part of your PHP code.

    ReplyDelete

Post a Comment

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?