The frustrations are piling up for an absolute newbie...
I can't even get simple things to work like:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>justatitle.dk</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
</head>
<body>
<?
header ("Location: http://www.justawebsite.com/folder/main.php");
exit;
?>
</body>
</html>
Isn't this supposed to automacially send me on to http://www.justawebsite.com/folder/main.php when I visit a page with the code above?!
What is wrong?
Thank you.
- cmarc
What is wrong?
Moderator: General Moderators
- Sekka
- Forum Commoner
- Posts: 91
- Joined: Mon Feb 18, 2008 10:25 am
- Location: Huddersfield, West Yorkshire, UK
Re: What is wrong?
Headers can only be sent before anything what so ever is sent to the user.
If you are wanting to redirect someone, all you need to do is,
Hope this helps!
If you are wanting to redirect someone, all you need to do is,
Code: Select all
<?php
header ("Location: http://www.justawebsite.com/folder/main.php");
exit();
?>Re: What is wrong?
Okay, maybe that's my problem then.
Is there a way to redirect in pure html-code then?
Thank you.
- cmarc
Is there a way to redirect in pure html-code then?
Thank you.
- cmarc
Re: What is wrong?
I'm now able to redirect using PHP just by making sure that nothing else comes first, then it works.
But this is my exact problem as I wanted to redirect from a page that specifies assorted variables to pass their values on to the main page, where they will be used only once.
Is there a way to do this?
- cmarc
But this is my exact problem as I wanted to redirect from a page that specifies assorted variables to pass their values on to the main page, where they will be used only once.
Is there a way to do this?
- cmarc
-
devendra-m
- Forum Contributor
- Posts: 111
- Joined: Wed Sep 12, 2007 3:16 am
Re: What is wrong?
Is there a way to redirect in pure html-code then?
Code: Select all
<meta http-equiv="refresh" content="0;URL=test.php">- Sekka
- Forum Commoner
- Posts: 91
- Joined: Mon Feb 18, 2008 10:25 am
- Location: Huddersfield, West Yorkshire, UK
Re: What is wrong?
You can pass variables from page to page in a number of ways. The two most popular are,cmarc wrote:I'm now able to redirect using PHP just by making sure that nothing else comes first, then it works.
But this is my exact problem as I wanted to redirect from a page that specifies assorted variables to pass their values on to the main page, where they will be used only once.
Is there a way to do this?
- cmarc
Sessions
Page 1:
Code: Select all
session_start();
$_SESSION['var1'] = "something";
header ("Location: http://www.somewhere.com/somepage.php");
exit ();Code: Select all
session_start();
if (isset ($_SESSION['var1'])) {
$var1 = $_SESSION['var1'];
// Do something
}Place the variables on the end of the URL link to the next page, e.g.
Page 1:
Code: Select all
header ("Location: http://www.somewhere.com/somepage.php?var1=something");
exit ();Code: Select all
if (isset ($_GET['var1'])) {
$var1 = $_GET['var1'];
// Do something
}That method doesn't always work and is disliked by many search engines. You can get black listed for using them. I would recommend redirecting in PHP instead.devendra-m wrote:Code: Select all
<meta http-equiv="refresh" content="0;URL=test.php">