Reply to Re: [PHP] Re: Question re empty query

Your name:

Reply:


Posted by Jochem Maas on 10/04/96 11:10

Jackson Linux wrote:

>>
>>
>> all you need is 1 if (or if/else) statement, note that my example
>> is the logical reverse of the first if statement I posted (in reply
>> to your question):
>>
>> if (!isset($_GET['r']) || empty($_GET['r']) || !($r =
>> intval($_GET['r']))) {
>> // _GET['r'] is either not set, empty or not a positive int
>> greater than zero.
>> // the required var is 'bad' so lets redirect the user.
>> if (!headers_sent()) {
>> header('location: /yourRvarsucks.php');
>> } else {
>> // you'll have to figure out what to do yourself
>> // if you want to redirect and headers have already been sent!
>>
>> }
>> exit;
>> }
>>
>> // now comes the rest of the script (build SQL, run it, output the data)
>>
>> $where = "WHERE cvjobcats.cv_id=cv.cv_id
>> AND cvjobcats.jobcat_id = '$r'
>> AND jobcat.jobcat_id=cvjobcats.jobcat_id";
>>
>> $sort = "ORDER BY cv.sort";
>>
>> // etc etc ...
>>
>
> Whhooo.
>
> I created this:
>
> $badr = "" )
>
> 1. I believe that this:
>
> if (!isset($_GET['r']) || empty($_GET['r']) || !($r =
> intval($_GET['r']))) {
> // _GET['r'] is either not set, empty or not a positive int greater
> than zero.
> // the required var is 'bad' so lets redirect the user.
> if (!headers_sent()) {
> header('location: {$_SERVER['PHP_SELF']}#bookmark');
> } else {
> // you'll have to figure out what to do yourself
> // if you want to redirect and headers have already been sent!
>
> }
> exit;
> }
>
> should kick back anyone who uses a bad or no $r to the location:
>
> {$_SERVER['PHP_SELF']}#bookmark
>
>
> However two problems:
>
> 1. This is dumb, I'm sure, but when I test this on its own it loops
> into a constant redirect, as the page reloads itself (PHP_SELF), hits
> the header location and tries again. I want it to keep the same page
> name (file.htm) but load a conditional menu if the request is for a
> non-existent or bad $r
>
> 2. Mustn't I also speficy what to do in the event that the $r is good?
>

thats up to you, I thought that was the whole point.

>
> Would that be just continuing the script:
>
> if (isset($_GET['r'])) {
> if(!empty($_GET['r']) && ($r = intval($_GET['r']))){
> } else {
> // And if so, then why do I need the IF statement here at all?
> Shouldn't this be a WHILE?



> }
> }
> // now comes the rest of the script (build SQL, run it, output the data)

do you know include()? http://php.net/include

if (!isset($_GET['r']) || empty($_GET['r']) || !($r = intval($_GET['r'])))
{
// show a list of R's
include('showlist.inc.php');
}
else
{
// process an R
include('process.inc.php');
}
>
>
>
> ??
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация