...

View Full Version : Log in Page Help needed please



trikkky
01-04-2012, 05:58 PM
Hi,
I am a newbie trying to create a log in page and the page will not even display now.
I have altered a few errors in my php log file and the last one says unexpected $end at line 101 ( which is the last line)

My idea was to check that everything is ok and then run mysqli to check the database the value are in the database but the page is just blank.
some guiding help would be great .


<?php
//start session
session_start();
include('includes/conn.inc.php');
include('includes/db.inc.php');

//form error alerts
$error['alert'] = '';
$error['user'] = '';
$error['pass'] = '';
$input['user'] = '';
$input['pass'] = '';

if(isset($_POST['submit']))
{
if($_POST['username'] == '' || $_POST['password'] == '')
{
if($_POST['username'] == '') {$error['user'] = 'required!';
if($_POST['password'] == '') {$error['pass'] = 'required!';
$error['alert'] = 'Please fill in the required fields!';

$input['user'] = $_POST['username'];
$input['pass'] = $_POST['password'];

}
else
{
$input['user'] = htmlentities($_POST['username'], ENT_QUOTES);
$input['pass'] = htmlentities($_POST['password'], ENT_QUOTES);

if ($stmt = $mysqli->prepare("SELECT username, password FROM user WHERE username=? AND password = ? "))

$stmt->bind_param('ss', $input['user'], md5($input['pass'].$config['secure']));
$stmt->execute();
$stmt->store_result();

if ($stmt->num_rows > 0)
{
$stmt->close();

$_SESSION['username'] = $input['user'];

header("Location: index.php");

}
// else
// {
// $error['alert'] = "Username or Password incorrect !";
// }

else
{
echo "ERROR could not do the MYSQLI ....";
}
}

}

else {

// show the form
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />

<title>Concept HQ Log in</title>

<meta name="keywords" content="AddContentOf YourSite" />
<link rel="stylesheet" href="css/style.css?v=1.0" />
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>

<body>
<section id="loginphp">
<h1>Log In</h1>
<div id="content">
<form method="post" action="">
<div>

<label for="username">Username *</label>
<input type="text" name="username" value="" />

<label for="password">Password *</label>
<input type="password" name="password" value="" />

<p class="required">* required fields</p>

<input type="submit" name="submit" value="Submit" class="submit"/>
</div>
</form>
<?php
$mysqli->close();
} //end else statement

?>
</body>
</html>

mlseim
01-04-2012, 08:12 PM
Put an opening { after the "if" statement on line 31 ...

and put a closing } on line 50 (for that "if" statement).

trikkky
01-04-2012, 08:34 PM
Hi,
Thanks for the help I have tried and it still doesn't show up. I'm lost as what to do. i just want a login in script with prepare statements.
Thank you for your help.

mlseim
01-04-2012, 08:46 PM
You get a blank white page because there is an error
and your PHP error reporting is turned off. You need
to enable it with your webhost config ... or you can
try putting this line at the top ... see red ...

<?php
//start session
session_start();
error_reporting(E_ALL ^ E_NOTICE);
include('includes/conn.inc.php');
include('includes/db.inc.php');


Let us know what the error says, and which line.


.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum