473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Page reload

Yep its me again,

I have succesfully created a login page for my site. I have used the PHP_SELF
so that once the user has succesfully logged on the page reloads. Everything
works fine the first time somebody tries to log in but when they revisit, the
log on page is bypassed and it goes straight to the information page. I have a
sneaky suspicion that this is due to the fact that the page is then in their
history of recently visited sites. How can I use PHP to refresh the page
automatically everytime it is requested?

Regards
Dynamo

Jul 17 '05 #1
8 8385
I noticed that Message-ID: <cn*********@drn.newsguy.com> from Dynamo
contained the following:
I have succesfully created a login page for my site. I have used the PHP_SELF
so that once the user has succesfully logged on the page reloads. Everything
works fine the first time somebody tries to log in but when they revisit, the
log on page is bypassed and it goes straight to the information page. I have a
sneaky suspicion that this is due to the fact that the page is then in their
history of recently visited sites. How can I use PHP to refresh the page
automatically everytime it is requested?


How are you doing the log in?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
In article <9n********************************@4ax.com>, Geoff Berrow says...


How are you doing the log in?


Cutting out the irelevant coding it went along the lines of:
<?php
if (!isset($_POST['submit'])) {
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p align="center">
Username <input name="user" type="text" size="20"></br>
Password <input name="pass" type="password" size="20"></br>
<input type="submit" name="submit" value="Continue">
</form>
<?php
}
else {
$userpass = $_POST['user'] . $_POST['pass']
if ($userpass != "testtest") {
// write error message
}
else {
// load the page
}
}
?>

Jul 17 '05 #3
I noticed that Message-ID: <cn*********@drn.newsguy.com> from Dynamo
contained the following:
Cutting out the irelevant coding

The 'load the page' bit is very relevant. There is nothing in your code
to stop someone going to the page by simply typing the URL.

Consider using sessions

For the login page

<?php
session_start();
if (!isset($_POST['submit'])) {
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p align="center">
Username <input name="user" type="text" size="20"></br>
Password <input name="pass" type="password" size="20"></br>
<input type="submit" name="submit" value="Continue">
</form>
<?php
}
else {
$userpass = $_POST['user'] . $_POST['pass']
if ($userpass != "testtest") {
// write error message
}
else {
$_SESSION['logged_in']="Userpass_OK";
header("Location: http://mypage.com/myindexpage.php");
//replace with whatever start page you have
}
}
?>

Then at the absolute begining of every page you wish to protect use an
include to put the following:

<?php
session_start();
if($_SESSION['logged_in']!="Userpass_OK"){
header("Location: URL of login page");
exit;
}
?>

Untested code.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4
In article <sd********************************@4ax.com>, Geoff Berrow says...

I noticed that Message-ID: <cn*********@drn.newsguy.com> from Dynamo
contained the following:

The 'load the page' bit is very relevant. There is nothing in your code
to stop someone going to the page by simply typing the URL.


Perhaps my phrasiology of 'load the page' was not exactly true. A better trimmed
down example of what I was trying to do would be:

if ($userpass != "testtest") {
// write error message
echo "Login Error";
}
else {
// write welcome page
echo "Sucessfully logged in. Welcome to my site";
}
}

I was trying to be clever (perhaps too clever for a newbie) and use the same url
(customer.php) for both the login part and the welcome page. As stated in my
original message, everything works fine the first time. But when the site is
revisited the login part is bypassed and it goes straight to the welcome part.
However, having said that, perhaps using sessions with 2 seperate urls is a
better idea. I'll give it a try.

Regards
Dynamo

Jul 17 '05 #5
I noticed that Message-ID: <cn********@drn.newsguy.com> from Dynamo
contained the following:
However, having said that, perhaps using sessions with 2 seperate urls is a
better idea. I'll give it a try.


You can still use sessions with your method. :-)

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #6

----- Original Message -----
From: "Geoff Berrow" <bl******@ckdog.co.uk>
Newsgroups: comp.lang.php
Sent: Sunday, November 21, 2004 12:11 PM
Subject: Re: Page reload

I noticed that Message-ID: <cn*********@drn.newsguy.com> from Dynamo
contained the following:

Consider using sessions
Untested code.

OK so I tried it and failed miserably. This was my coding:

<html>
<head></head>
<body>
<?php
session_start();
if (!isset($_POST['login'])) {
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<font face="Arial" size="2"><b>
Username</b></font> <input type="text" name="user" size="20">
<font face="Arial" size="2"><b>Password</b></font> <input type="password"
name="pass" size="20">
<p align="center">
<input type="submit" name="login" value="Login">
</p>
</form>
<?php
}
else {
$userpass = $_POST['user'] . $_POST['pass'];
if ($userpass == "testtest"){
$_SESSION['logged_in'] = "Userpass_OK";
header("Location: http://www.mywebsite/index.htm");
}
else {
echo "Login Error";
}
}
?>
</body>
</html>

and these were the error messages I got back

Warning: session_start(): Cannot send session cookie - headers already sent
by (output started at
\\nas16ent\domains\p\mywebsite\user\htdocs\login4. php:4) in
\\nas16ent\domains\p\mywebsite\user\htdocs\login4. php on line 5

Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at
\\nas16ent\domains\p\mywebsite\user\htdocs\login4. php:4) in
\\nas16ent\domains\p\mywebsite\user\htdocs\login4. php on line 5

Any suggestions?
Jul 17 '05 #7
Dynamo wrote:
OK so I tried it and failed miserably. This was my coding:

<html>
<head></head>
<body>
<?php
session_start();
if (!isset($_POST['login'])) {
?>
<snip>
and these were the error messages I got back

Warning: session_start(): Cannot send session cookie - headers already sent
by (output started at
<snip>
Any suggestions?


session_start() must be called before any output to the browser.

You are calling it after outputting "<html><head</hrad><body>".

Move the session_start() call before the HTML:

<?php
session_start();
?>
<html><head><title>I'M TOO LAZY TO TITLE MY PAGES</title></head><body>
<?php
if (!isset($_POST['login'])) {
/* ... */

--
Mail sent to my "From:" address is publicly readable at http://www.dodgeit.com/
== ** ## !! !! ## ** ==
TEXT-ONLY mail to the complete "Reply-To:" address ("My Name" <my@address>) may
bypass the spam filter. I will answer all pertinent mails from a valid address.
Jul 17 '05 #8
I noticed that Message-ID: <cn*********@news2.newsguy.com> from Dynamo
contained the following:
OK so I tried it and failed miserably.


What Pedro said.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: zdhiu | last post by:
Hi javascript gurus, I have a simple html file (simple.html) with javascript. In html page there is sentence from variable defined in .js file (myFirst.js). Once I reload another .js file...
37
by: ajay | last post by:
How to make a web page getting refreshed after a given time interval automatically. HTML Code plz. Tx Ajay
4
by: Lex | last post by:
I want to reload a page only once. Therefor meta refresh is not suitable, because then it refreshes every x seconds. Is there a possibility to refresh only once? regards, Lex Ouburg
18
by: Alan Z. Scharf | last post by:
1. I have a chain of six asynch callbacks initiated by a button, and want the page to refresh at the end of each callback to display A. Results of a SQLServer query showing cumulative running...
8
by: Salvatore Sanfilippo | last post by:
Hello all, I've a very simple problem that appears to don't have a simple solution. I've a (dynamically generated) page with a number of external links. What I need is that if the user clicks...
8
by: T. Wintershoven | last post by:
Hi all, Is there a simple way in php to reload a page coded within an if statement.(see code below) It's very important that the session stays intact. The filename is RCStudent.php ...
2
by: Max | last post by:
Is it possible to reload a web page on user browser when an event occurs at server side? For example when user A places an order, user B should be notified of that and should see that order on his...
16
by: sreemati | last post by:
Hi everyone, This is the scenario: I have two button - Submit and Reset Submit is used for validation and after validation is passed it passes it to another form to enter into database. ...
5
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi, I used the following code to refresh the parent page, and it works very well (Thanks to Peter Bromberg "). Response.Write("<script language='javascript' type='text/javascript'{...
2
by: ericisjusteric | last post by:
I have a page with multiple iframes and need to have the user (ie6) be able to click a button to refresh any one of the iframes - but also to click another button at the top of the page to refresh...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.