if && if

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
mrpaul
-


Joined: 23 Sep 2005
Posts: 18

PostPosted: Thu Sep 29, 2005 10:29 pm    Post subject: if && if Reply with quote

hi, i need help with a script that checks to see IF to things are what i want them to be. the script sould be checking teh refererd link to see if it came form admin.php and if it did then echo something if not then echo soemthing else.

the code:

<?php

$referer = $_SERVER['HTTP_REFERER'];
$ref = "127.0.0.1/admin.php";

if ( $referer != null) && ($referer == ref)
{ echo ("great it worked"); }
else echo ("Sorry you were not sent here by a script")

?>

Also how would i get it to check 3 things or even 4 things,
i was hoeping to make a page were people cant jsut type in the link and get error that could lead to a exploite.
the reson i need 3/4 if checks? things is i would like to add a password to this page, and i dont want people directly connecting to the page. i tried to put a if inside a if but fialed.

oh btw the error;
Parse error: parse error, unexpected T_BOOLEAN_AND in C:\Abyss Web Server\htdocs\ref.php on line 6
Back to top View user's profile Send private message
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Thu Sep 29, 2005 10:33 pm    Post subject: Re: if && if Reply with quote

Code:
<?php

 $referer = $_SERVER['HTTP_REFERER'];
 $ref = "127.0.0.1/admin.php";

if ( $referer != null) && ($referer == ref)
{ echo ("great it worked"); }
else echo ("Sorry you were not sent here by a script")

?>


remove the ")" and the "(" from either side of the "&&" so you end up with
Code:
if ( $referer != null && $referer == ref)


simple!
_________________
Anthony R

Roganty
| Links-Links.co.uk
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Fri Sep 30, 2005 1:46 pm    Post subject: Re: if && if Reply with quote

Try instead:

Code:

if ( ( $referer != null) && ($referer == $ref) )


We have enclosed the condition between ( and ) as the if syntax requires. We have also changed ref to $ref.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group