Re: [PHP] header redirection

2002-04-22 Thread Norman Zhang

Hi,

My codes are as follows,

login.php

?
  session_start();

  if (!$HTTP_POST_VARS['logname']  !$HTTP_POST_VARS['logpass'])
  {
  // User needs to supply login name and password.
?
// This is my default header that I want to include on every page.
  html
  head
titleSupport Center/title
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
link rel=stylesheet href=css/test.css type=text/css
  /head

  body leftmargin=0 topmargin=0 rightmargin=0
table width=100% border=0 bgcolor=#005796 cellpadding=0
cellspacing=0
tr
  td align=left bgcolor=#005796img src=images/logo.gif
  alt=logo/td
  td align=right class=ttextbSupportbrCenter/b/td
  tdnbsp;nbsp;/td
/tr
tr bgcolor=orange
  td align=leftnbsp;upload nbsp; download/td
  td colspan=2 align=rightLogoutnbsp;/td
/tr
/table
// End of my default header that I want to include on every page.

h1 align=centerSupport Center/h1
form name=fm method=post action=login.php
table border=0 cellspacing=5 cellpadding=5 align=center
bgcolor=#fffacc
  tr
td align=rightbUser Name/b/td
tdinput type=text size=25 maxlength=20 name=logname
value= //td
  /tr
  tr
td align=rightbPassword/b/td
tdinput type=password size=25 maxlength=20 name=logpass
value= //td
  /tr
  tr
td colspan=2 align=centerinput type=submit
value=Log in Now name=submit /nbsp;
input type=reset value=Cancel name=reset //td
  /tr
/table
/form

  /body
  /html
?
  }
  else
  {
// connect to mysql
$authdb=mysql_connect('localhost', 'webauth', 'webauth')
  or die(Cannot connect to database.);

// select the appropriate database
mysql_select_db('auth', $authdb) or die(Cannot select db.);

// query the database to see if there is a record which matches
$query=select * from auth where
  usrname='$HTTP_POST_VARS[logname]' and
  usrpass=md5('$HTTP_POST_VARS[logpass]');

$result=mysql_query($query) or die(Cannot run query.);

$row=mysql_fetch_row($result);

if (mysql_num_rows($result)  0)
{
  $_SESSION['userid']=$row[0];
  $_SESSION['userlevel']=$row[1];
  $_SESSION['usersec']=mt_rand(100, 999);

  $updatesql=update auth set seckey='$_SESSION[usersec]'
where usrid='$_SESSION[userid]';

  if (!mysql_query($updatesql))
die (Cannot update database.);

  header(Location: down.php);
  die ();
}
else
{
  echo h1Go Away!/h1;
  echo You are not authorized to view this resource.;
  die();
}
  }
?

down.php

?
  session_start();

  if ($_SESSION['userid']  $_SESSION['userlevel']  $_SESSION['usersec'])
  {
// connect to mysql
$authdb=mysql_connect('localhost', 'webauth', 'webauth')
  or die(Cannot connect to database.);

// select the appropriate database
mysql_select_db('auth', $authdb)
  or die(Cannot select db.);

// query the database to see if there is a record which matches
$query=select * from auth where
  usrid='$_SESSION[userid]' and
  usrlevel='$_SESSION[userlevel]' and
  seckey='$_SESSION[usersec]';

$result=mysql_query($query, $authdb)
  or die(Cannot run query.);

$row=mysql_fetch_row($result);

if (mysql_num_rows($result)  0)
{
?

// I want to include the default header in here again. But it does not work.

?

}
  }
?

Thanks,
Norman

Jason Wong [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
On Saturday 20 April 2002 05:07, Norman Zhang wrote:
 Hi,

 I use header(location: ...) for redirection to another page. But I also
 want to include title, meta and link tags in the other page. Is
there
 a way to this? Because php complains that the header already been sent.

Show us your code.

--
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Spiritual leadership should remain spiritual leadership and the temporal
power should not become too important in any church.
- Eleanor Roosevelt
*/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] header redirection

2002-04-19 Thread Norman Zhang

Hi,

I use header(location: ...) for redirection to another page. But I also want
to include title, meta and link tags in the other page. Is there a way
to this? Because php complains that the header already been sent.

Regards,
Norman



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] header redirection

2002-04-19 Thread Kevin Stone

Headers will be created whenever information is outuputted to the browser.
In this case when you include the .html file into your php script the
browser is going to create all the headers it will ever know for that page.
Obviously this does you no good if you want to add headers later.

Ways around this.  You can use output buffering to set headers in non-linear
format.  You could use a Javascript to refresh the page after it loads.  Or
the way I prefer to do it.. just echo a meta refresh tag between the head
tags of your html page.  This works with the vast majority of browsers and
you can control the number of seconds before the page redirects.

echo 'head';
echo 'META HTTP-EQUIV=Refresh Content=5;
URL=http://www.yourdomain.com;';
echo '/head';

Hope this helps,
Kevin

- Original Message -
From: Norman Zhang [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, April 19, 2002 3:07 PM
Subject: [PHP] header redirection


 Hi,

 I use header(location: ...) for redirection to another page. But I also
want
 to include title, meta and link tags in the other page. Is there a
way
 to this? Because php complains that the header already been sent.

 Regards,
 Norman



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] header redirection

2002-04-19 Thread Jason Wong

On Saturday 20 April 2002 05:07, Norman Zhang wrote:
 Hi,

 I use header(location: ...) for redirection to another page. But I also
 want to include title, meta and link tags in the other page. Is there
 a way to this? Because php complains that the header already been sent.

Show us your code.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Spiritual leadership should remain spiritual leadership and the temporal
power should not become too important in any church.
- Eleanor Roosevelt
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] header redirection

2001-09-14 Thread Poppy Brodsky

does not execute until the remainder
of the script has executed...
How can I redirect the user:

header(Location: http://www.foo.bar\n\n;);

and continue to execute a set of commands
after the redirection?
Just having the redirection code before the other code does not work.


Linux running apache and php4

poppy


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] header redirection

2001-09-14 Thread Steve Edberg

It's my understanding that PHP's normal behavior IS to send the 
header when it is encountered in your program, and then continue 
running the program (unless you have an exit statement after the 
header).

Perhaps you have output buffering turned on?

If that's not the case, please most more info, and perhaps the 
relevant parts of the script if possible.

By the way, I'm pretty sure you don't need those trailing newlines 
(\n\n) there; PHP takes care of that for you. I don't know if 
that's the source of your problem or not...

-steve





At 12:59 PM -0400 9/14/01, Poppy Brodsky wrote:
does not execute until the remainder
of the script has executed...
How can I redirect the user:

header(Location: http://www.foo.bar\n\n;);

and continue to execute a set of commands
after the redirection?
Just having the redirection code before the other code does not work.


Linux running apache and php4

poppy


-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] header redirection

2001-03-21 Thread Jason Stechschulte

On Tue, Mar 20, 2001 at 10:05:06PM -0800, [EMAIL PROTECTED] wrote:
 Why wouldn't this redirect?  The query works, but the page won't redirect. I
 have used the same two lines successfully on other pages.  I'm very tired,
 it's probably obvious.
 
 ?php
 // assuming $uid, $itemid, $week, $cur_wk in querystring
 
 //connect to db
 $db = mysql_connect ("localhost","user","password");
 mysql_select_db("mydb",$db);
 
 //update item - weekX to Taken and record buyer
 $sql = "update items set week" . $week . " = 'T', buyerID = " . $uid .
" where itemID = " . $itemid;
 $result = mysql_query($sql);
 
 $redirurl = "bid.php?uid=" . $uid . "itemid=" . $itemid;
 header ($redirurl);
 ?

It appears your code is missing the "Location: " part of the header.

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
It's getting harder and harder to think out loud.  One of these days
someone's gonna go off and kill Thomas a'Becket for me...
 -- Larry Wall in [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] header redirection

2001-03-21 Thread Yasuo Ohgaki

"Jason Stechschulte" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Tue, Mar 20, 2001 at 10:05:06PM -0800, [EMAIL PROTECTED] wrote:
SNIP
 
  $redirurl = "bid.php?uid=" . $uid . "itemid=" . $itemid;
  header ($redirurl);
  ?

 It appears your code is missing the "Location: " part of the header.

In addition to this, you probably better off using absolute URI. (Unless you are
using Apache)
Refer to RFC for details.

--
Yasuo Ohgaki



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] header redirection

2001-03-20 Thread Jason Murray

 Why wouldn't this redirect?

Because you need to do this:

?
   header ("Location: $redirurl");
?

Jason

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]