NameSilo

Refresh/Reload

Spaceship Spaceship
Watch

LeetPCUser

Account Closed
Impact
36
I have a php login and it requires me to click another link, which then reloads the header, so it displays the name at the top. Is there a refresh command or something in which I can redisplay the header without getting the error of calling it twice??
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Alternatively I make the actual login process its own file, then use Header("Location: filename.php"); before it displays anything onthe screen. Works very seamlessly. Try this instead. Trust me.
 
0
•••
Well I have it so it logs in with a seperate file and everything but then displays, "Welcome User". After that then you are logged in and if you click another link it will load it fine.

I just tried using the header() function of php. It won't work because I already define all the things from header.php which starts all the html. If someone could please help me with some bits of code to figure this out it would be great.
 
Last edited:
0
•••
Frankly, you've structured your code poorly. If you're new to PHP, then you can learn from this and make things easier down the road.

Javascript:

<body onLoad="javascript:document.location = document.location">

Perhaps?
 
0
•••
It might have poor coding but it is structured for practical user interface. It is much better than a white screen with two login boxes. What big sites do that? Absolutely none! I don't want javascript. There has to be a way.
 
0
•••
Well, I don't mean visual structure. I mean design structure of your PHP code. The way you organize it and use it is inefficient and, as shown by this scenario, limits your capabilities. I do not know of any other way.
 
0
•••
I heard of buffering so I am going to find that.

I am trying PHP's title command with header("Location: /url"); but it giving me an error that I already called it, any ideas?
 
Last edited:
0
•••
you have to put the header("Location: url.php"); at the top of your page

example:

if you have:

<?
session_start();
if(!isset($_session[user]) && !isset($_session[pass]))
{
echo " you have to login ";
exit;
header("Location: /url");
}

then you get the header already send becasue basicly you send the output via an echo through the browser to the user.

thats why you get the header already sent error,
 
0
•••
How can I get a refresh without using javascript and having my code so header errors out? Is there another way around it?

100NP$ For Anyone Who Can Figure It Out...Please PM Me
 
Last edited:
0
•••
xlusive said:
you have to put the header("Location: url.php"); at the top of your page

example:

if you have:

<?
session_start();
if(!isset($_session[user]) && !isset($_session[pass]))
{
echo " you have to login ";
exit;
header("Location: /url");
}

then you get the header already send becasue basicly you send the output via an echo through the browser to the user.

thats why you get the header already sent error,

First thing.. Echo has to go after the headers.. No output (print, echo,etc) can go before headers.

Now.. There is no other real way.. You can use other programming languages.. Such as VB lol..

<SCRIPT RUNAT=Server Language=VBScript>

Sub Session_OnStart
Dim varStartPage
Dim varCurentPage

'Check to see if current page is the correct login page
varStartPage = "/LogIn/LogIn.asp"

'Get the current page
varCurrentPage = Request.ServerVariables("SCRIPT_NAME")

'If page is not correct then send the visitor to the correct login page
If StrComp(varCurrentPage, varStartPage, 1) Then
Response.Redirect( StartPage)
End If

End Sub

</SCRIPT>

But pretty much there is no HTML code for redirecting. Just JS, PHP, etc..

iNod
 
0
•••
You need a Windows host though, or some sort of very unique VBScript-supporting linux host.
 
0
•••
Can I put the header after basic HTML statements as long as it is before all echo statements?
 
0
•••
No.
 
0
•••
compuXP said:
You need a Windows host though, or some sort of very unique VBScript-supporting linux host.


Thats true I was just demostrating how you can do it using different methods. I suggest you have a .. You are now being transfered if you are not transferred within blah minutres please press this link to manually get transferred. Using Javascript.

iNod
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back