Jump to content

Navigating to a new PHP page


Recommended Posts

Hi you can use

1) Redirection using header function

2) You can use the JavaScript for redirecting

3) You can use the include function for including next/other php page in current page.!!!

 

Try this and let me know whethere this works for you!?

 

Regards

Sushant Danekar

 

Basically whats happening is the following:

- A user goes to adminctrl.php  This script checks if they are logged in using session variables.  If they are not logged in, the user is taken to login.html

- The user enters their details on login.html and clicks the LOGON button, which then calls the login.php script.

- The login.php script checks the database to validate they are a user (which all works).  If they are not a user the login.html is displayed again and the cycle repeats.  That is not a problem.  However, when they are a valid user, I want to go back to adminctrl.php

 

When I use header ("Location: adminctrl.php");  nothing happens, same with include_once.  Code in login.php that checks if the user can login to the database:

 


			$gateway = new DatabaseGateway($username, $password);  //form new db constructor

			$logonCheck = $gateway->attemptLogon(); //attempt to logon to the database

			if($logonCheck == 0)  //then login was successful
			{
				//echo ('Logon to database was successful');
				//I WANT THE ADMINCTRL.PHP TO LOAD HERE
			}
			else
			{
				echo ("You have not entered the correct username and password");
			}

 

However, when I uncomment the echo statement and use the header() function, I get the following:

 

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\vdtwebexperimentation\login.php:23) in C:\xampp\htdocs\vdtwebexperimentation\login.php on line 24

 

I have no idea what is going on!  Please help.

hi, you could do it this way. the content is the amount of time to refresh. so you could display a message saying

 

"You have logged in successfully, you will now be directed to the secure site" or something

 

 

<?php
print "<meta http-equiv=\"refresh\" content=\"2; url=http://www....\">";
?>

Hi,

 

There are a couple of meta tags.

These tags are placed in the head section of an HTML page. thay are sued to decribe metadata of a web page' they are useful in SEO or telling web page robots how they should behave.

The structure of a meta tag is

name, content,action(or description).  For example a meta tag to describe the various keywords you want a page to be referenced with in a search eg google is conctructed as follows:

let's say the site is about relationships;

 

<meta name="keywords" content="love, lovelife, sextime, the beautiful,kiss her, kiss him"/>

These are the words that will return that particular page with that meta description should one search..

 

ANYWAY

 

There is one meta tag that is defined with a "refresh"

For your case you could echo it php after successful login thus:

 

<?php

echo ' <http-equiv="refresh" content="2";URL="adminctrl.php">';

?>

 

You can even add a mesasge

 

<?

echo' Login successful! You will now be redirected to the ........ page now';

echo ' <http-equiv="refresh" content="2;URL="adminctrl.php">';

?>

 

Note: Content defines the re-direct delay in seconds. In some PHP versions, 5 or lower you write secods with 2 zeros ie content ="500" for 5 seconds

Play around with this..

 

I hope it helps

 

Get back if you run into trouble.

 

Cheers

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.