Can't get to page without logging in

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

yankees230230
New php-forum User
New php-forum User
Posts: 18
Joined: Fri Jul 11, 2003 1:44 pm

Can't get to page without logging in

Postby yankees230230 » Sat Jul 12, 2003 5:13 pm

Hey i was wondering how i could do this.. I imagine theres probably a million ways. On my home.htm i have a field called password... it actions to this php(action.php)..

Code: Select all

<?php
switch ($password)
{
case "schedule":
print '<meta http-equiv="refresh" content="3;URL=http://WWW.HAPPYDOGBehavior.com/html/exlusive/schedule.htm">';
break;
case "signup":
print '<meta http-equiv="refresh" content="3;URL=http://WWW.HAPPYDOGBehavior.com/html/exlusive/signup.htm">';
break;
default:
   print "Sorry, but you have entered an invalid password";
}
?>

on those urls is there anyway i can check the referring URL to make sure the user came from action.php? Because what i don't want a user doing is going to either schedule or signup.htm and say adding it to their favorites and just come back to it a month later... Thanks
Also a side question... how to I echo a complex html page.. Like a full page with java script in the head for image swap ect. .. Thanks!

Joel
New php-forum User
New php-forum User
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand
Contact:

Postby Joel » Sat Jul 12, 2003 8:23 pm

Have this code as your page for e.g. signup.htm.

Code: Select all

if ($_SERVER['REQUEST_URI'] == 'action.php') {
     //signup.htm
}
else {
     header("Location: home.htm");
}

yankees230230
New php-forum User
New php-forum User
Posts: 18
Joined: Fri Jul 11, 2003 1:44 pm

Postby yankees230230 » Mon Jul 14, 2003 2:28 pm

Ok i changed it so it goes to signup.php instead of signup.htm... now i have this on the signup.php

Code: Select all

<?php
if ($_SERVER['REQUEST_URI'] == 'action.php') {
     //signup.htm
}
else {
     header("Location: home.htm");
}
?>


but i get this error message

Code: Select all

Parse error: parse error, unexpected T_ELSE, expecting ',' or ';' in /home/happydog/public_html/html/exlusive/signup.php on line 3


what am i doing wrong... with that code am i supposed to create a seperate signup.htm and if the url is right it will pull signup.htm into the document??

Joel
New php-forum User
New php-forum User
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand
Contact:

Postby Joel » Tue Jul 15, 2003 2:03 am

Are you sure thats all the code you have? I ran it, and it executed successfully.

yankees230230
New php-forum User
New php-forum User
Posts: 18
Joined: Fri Jul 11, 2003 1:44 pm

Postby yankees230230 » Tue Jul 15, 2003 10:40 am

wow i feel so incredibly stupid...i must of deleted something before.. now its workin kind of but still going wrong... heres the address http://www.happydogbehavior.com/password.htm ... tha you fill that out and hit enter and it actions to you http://www.happydogbehavior.com/PHP/php.php... which is than supposed to bounce you to signup.php if you enter the correct password (signup)... Here are the 3 source codes...

Password.htm.....................................................

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body><form action="/PHP/php.php" method="post">
  <input name="password" type="text" id="password">
</form>

</body>
</html>




php.php..........................................................

Code: Select all

<?php
switch ($password)
{
case "schedule":
print '<html> <meta http-equiv="refresh" content="3;URL=http://WWW.HAPPYDOGBehavior.com/html/exlusive/schedule.php"> </html>';
break;
case "signup":
print '<html> <meta http-equiv="refresh" content="3;URL=http://WWW.HAPPYDOGBehavior.com/html/exlusive/signup.php"></html>';
break;
default:
   print "Sorry";
}
?>


signup.php.......................................................

Code: Select all

<?php
if ($_SERVER['REQUEST_URI'] == 'http://www.happydogbehavior.com/PHP/php.php') {
     //aaa
}
else {
     header("Location: /html/home/");
}
?>

Joel
New php-forum User
New php-forum User
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand
Contact:

Postby Joel » Tue Jul 15, 2003 11:15 pm

What exactly is the trouble?

yankees230230
New php-forum User
New php-forum User
Posts: 18
Joined: Fri Jul 11, 2003 1:44 pm

Postby yankees230230 » Wed Jul 16, 2003 11:11 am

its redirecting to home.htm everytime regardless wheter u came from php.php or not

Joel
New php-forum User
New php-forum User
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand
Contact:

Postby Joel » Wed Jul 16, 2003 10:12 pm

Thats because the request URI does not produce output like you are comparing it too. It produces something like "/PHP/php.php" so you must do this.

Code: Select all


<?php
if ($_SERVER['REQUEST_URI'] == "/PHP/php.php") {
     //aaa
}
else {
     header("Location: /html/home/");
}
?>



If you are in doubt echo $_SERVER['REQUEST_URI'].

yankees230230
New php-forum User
New php-forum User
Posts: 18
Joined: Fri Jul 11, 2003 1:44 pm

Postby yankees230230 » Thu Jul 17, 2003 9:07 am

ok thanks.. yes that works.. my fault... what i ended up doing was making the form action to a php page which does if password = each thing than the html page. than the defauly fowards you to an error page. anyway thanks again


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 2 guests

cron