- This topic is empty.
-
AuthorPosts
-
May 16, 2013 at 11:56 am #44821RohithzrParticipantMay 16, 2013 at 1:04 pm #135308unasAquilaParticipant
In your login.php anywhere where you need to send to user back add this
$_SESSION = $errors;
on the index.php
$errors = $_SESSION;
then do with the $errors what you need to show the information contained
May 16, 2013 at 11:46 pm #135382RohithzrParticipant@unasAquila not working
first of all it shows an unidentified index until and unless i declare it in connect.php
second if i use this command then i end up opening a blank login.php page with no result whatsoever as there is no echo in login.php [there is echo in index.php but the form opens the login.php and no echo event occurs in index.php]well now take a look at these files
login.php [added ur suggestion in wrong password section {and it reaches there tested}]
//signin.php
include 'connect.php';
if(isset($_SESSION) && $_SESSION == true)
{
echo 'You are already signed in, you can sign out if you want.';
}
else
{
if($_SERVER != 'POST')
{
echo 'You cannot access this page dirctly. !!';
}
else
{
$errors = array();
if(!isset($_POST))
{
$errors[] = 'The username field must not be empty.';
}
if(!isset($_POST))
{
$errors[] = 'The password field must not be empty.';
}
if(!empty($errors))
{
echo 'Uh-oh.. a couple of fields are not filled in correctly..
';
echo '- ';
- ' . $value . ' ';
foreach($errors as $key => $value)
{
echo '
}
echo '
}
else
{
$sql = "SELECT
user_id,
user_name,
user_level
FROM
user
WHERE
user_name = '" . mysql_real_escape_string($_POST) . "'
AND
user_pass = '" . sha1($_POST) . "'";
$result = mysql_query($sql);
if(!$result)
{
echo 'Something went wrong while signing in. Please try again later.';
//echo mysql_error(); //debugging purposes, uncomment when needed
}
else
{
if(mysql_num_rows($result) == 0)
{
$error = 'You have supplied a wrong user/password combination. Please try again.';
$_SESSION = $error;
}
else
{
$_SESSION = true;
while($row = mysql_fetch_assoc($result))
{
$_SESSION = $row;
$_SESSION = $row;
$_SESSION = $row;
}
echo 'Welcome, ' . $_SESSION . '.
Proceed to the forum overview.';
}
}
}
}
}
?>
May 17, 2013 at 3:05 am #135391unasAquilaParticipanttry this in the same place. add the `header(‘Location:index.php’)`;
if(mysql_num_rows($result) == 0) {
$error = ‘You have supplied a wrong user/password combination. Please try again.’;
$_SESSION = $error;
header(‘Location: index.php’);
}Also and im so sorry i missed it you need `session_start()` at the top of both files.
May 17, 2013 at 3:29 am #135394unasAquilaParticipantA scaled down version of what you are doing
`index.php`session_start();
if(isset($_SESSION)){
$errors = $_SESSION;
print_r($errors);
}else{
echo ‘no error messages yet’;
}
?>
Test
`login.php`
session_start();
if(empty($_POST)) {
$error = ‘You have supplied a wrong Information’;
$_SESSION = $error;
header(‘Location: index.php’);
}
?>May 17, 2013 at 8:09 am #135422RohithzrParticipant@unasAquila i dont know how to thank you for this. i was getting mad at this problem!! really great help
thanks a lot -
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.