Current location: Hot Scripts Forums » Programming Languages » PHP » back button problem


back button problem

Reply
  #1 (permalink)  
Old 08-25-09, 07:02 AM
sunanurag sunanurag is offline
Newbie Coder
 
Join Date: Aug 2009
Posts: 51
Thanks: 2
Thanked 0 Times in 0 Posts
back button problem

Hi Everyone,
I ve created one login page. In this if username and password is correct then it will open a new page, otherwise it will show an error msg on the same page but in a division that"wrong username or password".
now my problem is when i am giving wrong username and password then it is showing the error msg. now if next time i will give correct username and password then it will show me the new page but if i use browser's back buton, then it will come back to the login page but that error msg will be there. I dont wanr this.
Can nyone please tell me that where is the problem, and how to solve it.
Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 08-25-09, 07:13 AM
therocket954's Avatar
therocket954 therocket954 is offline
Community Liaison
 
Join Date: Jul 2007
Location: Michigan, USA
Posts: 334
Thanks: 2
Thanked 8 Times in 8 Posts
Post some code if you can... but most likely it sounds like you might not be keeping the session open on all pages.

Look for something similar to this on your "authorized" page, and make sure it appears on your login page as well.
PHP Code:

session_start(); 

Or as well, your login page could be looking for $_POST or $_GET values instead of $_SESSION values which would cause this to happen.
__________________
--Eric Allison
Twitter: http://www.twitter.com/Eric_Allison
Reply With Quote
  #3 (permalink)  
Old 08-25-09, 07:21 AM
sunanurag sunanurag is offline
Newbie Coder
 
Join Date: Aug 2009
Posts: 51
Thanks: 2
Thanked 0 Times in 0 Posts
Thanks for reply,
frankly speaking i ve just started php coding 4 days back. I m very new for it. So please if you can then just write a small demo code for me for this situation.
waiting...
Reply With Quote
  #4 (permalink)  
Old 08-25-09, 07:33 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
Please post the code you have.
Reply With Quote
  #5 (permalink)  
Old 08-26-09, 12:00 AM
sunanurag sunanurag is offline
Newbie Coder
 
Join Date: Aug 2009
Posts: 51
Thanks: 2
Thanked 0 Times in 0 Posts
PHP Code:

<?php

session_start
();
$_session["count"]=0;
?>

<html>
<head>

<link href=\"Style.css\" rel=\"stylesheet\" type=\"text/css\" />
</head>
<body style="background-color:#fff">
<form action="1.php" method="post">
<div class="outerBlock">
<table cellpadding="4" align=center >
<tr><td>Username</td><td><input type=text name=username></td></tr><br/>
<tr><td>Password</td><td><input type=password name=password></td></tr><br/>
<tr><td>
</td></tr><br/>
<tr><td><input type=submit name="submit" value="Login"></td></tr>
</table>



<?php
if(isset($_POST['submit']))
{
    if((
$_POST['username'] == "abc") && ($_POST['password']== "abc"))
    {
        
header("Location:2.php");
    }

    else
    {
        
$_session["count"]=1;
    }
}
?>

<?php
if($_session["count"]==1)
{
?>
<div style="background-color:#3399cc; left: 650px; top:-110px; position:relative; width :241px; height :31px">Please enter the correct Login Details</div>
<?php
}
?>
</div>
</form>
</body>
</html>

Last edited by wirehopper; 08-26-09 at 07:27 AM. Reason: PHP tags
Reply With Quote
  #6 (permalink)  
Old 08-26-09, 07:27 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
PHP is case-sensitive, use $_SESSION, instead of $_session.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
two radio button and one text area zoliky JavaScript 1 09-15-06 03:44 AM
how to disable browser's back button after logout shaky ASP 7 08-18-06 07:37 AM
on button click, open an email client ! n3wb!e JavaScript 4 07-14-06 04:37 AM


All times are GMT -5. The time now is 07:58 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.