Jump to content


Photo

If statment to open diffrent page


  • Please log in to reply
4 replies to this topic

#1 tobywuk

tobywuk
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 16 June 2006 - 02:59 PM

i have the code


if($_POST[password] == $correct)
{
http "blogentry.php";
} else {
echo "Password was incorect";
include("index.php");
}
?>

im trying to make it so if the password is entered correctly the page blogentry.php will load. the only thing is i dont know how to do this. I know if i put echo"password is correct" this will display but i dont want just text to display i want the page to actualy load. I'v tried include"blogentry.php" but this just opens up that page within that webpage which i dont want

can anyone help?
[a href="http://www.unwantedforum.com" target="_blank"][/a]

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 16 June 2006 - 03:03 PM

You want to use the [a href=\"http://www.php.net/header\" target=\"_blank\"]header[/a]() function here:
<?php
if($_POST['password'] == $correct)
{
     header("location: blogentry.php");
     exit();
} else {
echo "Password was incorect";
include("index.php");
}
?>

Ken

#3 tobywuk

tobywuk
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 16 June 2006 - 03:11 PM

i put that in but now i get

Warning: Cannot modify header information - headers already sent by (output started at /home/tobywuk/public_html/nstorm/bloglogin.php:9) in /home/tobywuk/public_html/nstorm/bloglogin.php on line 21

line 21 is
header("location: blogentry.php");

[a href="http://www.unwantedforum.com" target="_blank"][/a]

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 16 June 2006 - 03:22 PM

Read the [a href=\"http://www.phpfreaks.com/forums/index.php?s=&showtopic=37442&view=findpost&p=138336\" target=\"_blank\"]sticky note[/a] at the top of the forum.

Ken

#5 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 16 June 2006 - 03:50 PM

Dont forget to read the [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=95562\" target=\"_blank\"]FAQ/Code Respority[/a] forum either.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users