Hi guys would it be possible for you to check this script; i'm nt to sure that what i am doing is secure, it is a process script from a login form on my site. Any tips or watever would be thankfully welcomed:-
<?php
$serverURL = "http://localhost/beta/modules/myAccount/login.htm";
$host = "MySQL Host"; //Website host eg. localhost
$username = "MySQL UID"; //Database username eg. root
$password = "MySQL PWD"; //Database password eg. password
$database = "MySQL DB"; //MySQL Schema on server eg. MyDB
session_start(); //Start the session
if($_SERVER['HTTP_REFERER'] == $serverURL){;
$userName = $_POST['uid'];
$passWord = md5($_POST['pwd']);
$_POST['uid'] = "Spacebar Computers (NW)";
$_POST['pwd'] = "Spacebar Computers (NW)";
//Connect to MySql Database
$loginSQL = mysql_connect($host,$username,$password)
or die (include 'error.htm');
//Select MySQL Schema on server
mysql_select_db($database)
or die (include 'error.htm');
$loginQuery = mysql_query("SELECT `id`,`username`,`password`,`real_name` FROM `users` WHERE `username` = '$userName'")
or die (include 'error.htm');
$loginResults = mysql_fetch_array($loginQuery);
if($loginResults['username'] = $userName && $loginResults['password'] = $passWord){
$_SESSION['personalID'] = $userName;
$_SESSION['personalWord'] = $passWord;
$userName = "Spacebar Computers (NW)";
$passWord = "Spacebar Computers (NW)";
$_SESSION['name'] = $loginResults['real_name'];
header("Location:../../index.php");
} else {
print "Error!";
}
}
else {
header("Location: http://www.spacebarcomputers.com");
}
?>
NOTE:$serverURL will be changed when the site is entered into production.