
Originally Posted by
djr33
PHP Code:
<?php if(isset ($error)) {
echo '<div id="login-errors">'.$error.'</div>'
} ?>
Use {} for if statements, rather than (). And don't end that with a ;. I'm not exactly sure what's not working there, but the code was written incorrectly, and it should now work.
That creates a new error:
Parse error: syntax error, unexpected '}', expecting ',' or ';'
Here is what I have written incase I did it wrong:
PHP Code:
<?php if(isset ($error)) { echo '<div id="login errors">'.$error.'</div>' } ?>
Alright I added ";" at the end and it fixed it, but now the page is breaking layout and displaying:
PHP Code:
array (size=3)
'username' => string 'dfdf' (length=4)
'password' => string 'dfdfd' (length=5)
'logintoadmincenter' => string 'Login' (length=5)
So why is this PHP breaking my HTML layout and adding that code in the upper left corner which is not what it is suppose to do:
My PHP
PHP Code:
<?php
session_start();
if($_POST && isset($_POST['logintoadmincenter']))
{
include_once '/include/connection.php';
$username = $_POST['username'];
$password = $_POST['password'];
if (empty($username) && empty($password))
{
$error = "Please fill in the required fields";
}
else
{
print "<pre>";
var_dump($_POST);
$username = strip_tags ($username);
$password = strip_tags ($password);
$username = mysql_real_escape_string ($username);
$password = mysql_real_escape_string ($password);
$password = md5($password);
$sql = mysql_query("SELECT * From Members WHERE name = '$username' && password = '$password' LIMIT 1") or die (mysql_error ());
$num_rows = mysql_num_rows ($sql);
if ($num_rows == 1)
{
$rows = mysql_fetch_array($sql);
extract ($rows);
$_SESSION['username'] = $name;
$_SESSION['level'] = $access_level;
if (isset ($$_SESSION['username']));
{
$update = msql_query("UPDATE Members SET last_log_time = now()") or die(mysql_error());
header("location: index.php");
}
}
else
{
$error = 'Invalid Credentials';
}
}
}
?>
Never mind I found the issue:
PHP Code:
print "<pre>";
var_dump($_POST);
Bookmarks