So, I am working a Username and Password entry form and whenever I insert this PHP code to connect to my MySQL database, and load my page, it gives a blank white screen. It is supposed to check against users in my database. But fails. Other PHP code work in PHP files such as "fwrite()" or "echo". Maybe it's an operator error and I just can't figure out what I'm doing wrong. Any help would be great! Thanks!
Here is my PHP code:
<?php
session_start();
include('config.php');
$usercheck = $_POST["username"];
$passcheck = $_POST["password"];
$db_query= mysql_query("SELECT * from users WHERE username ="'.$usercheck.""');
if (mysql_num_row($db_query)== 1){
$record = mysql_fetch_array($db_query);
if (md5($passcheck) == $record['password']){
$_SESSION['user']= $usercheck;
$_SESSION['password']= $passcheck;
}
else
echo "Sorry, wrong password. <br/>";
}
else
echo "Sorry, wrong username. <br/>";
if(isset($_SESSION['user'])){
echo "You are now logged in!";
echo "<p><a href="index.html">HOME</a></p>";
}
else
echo "<p color="red">An error accured trying to log you in. Please try again later.</p>";
And my config.php:
<?php
$db_con= mysql_connect("localhost","root", "password");
if(!$db_con){
die('Could not connect to the Database:'. mysql_error());
}
mysql_select db("my_data", $db_con);
?>