Go Back   Velocity Reviews > Newsgroups > HTML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

HTML - PHP question

 
Thread Tools Search this Thread
Old 12-16-2004, 07:51 AM   #1
Default PHP question


On one of my sites I use
<? header("location: http://www.MYDOMAIN.com/pages/index.php");?> to forward
people that goto http://www.MYDOMAIN.com to that page. Now is there a way to
make it randomly pick a file to send to?

Like
<?
$num = $rand(1,3)
header("location: http://www.MYDOMAIN.com/pages/index$rand.php");?>
Where $rand would pick 1 2 or 3 then send the user to that index page?




Viper
  Reply With Quote
Old 12-16-2004, 07:57 AM   #2
Chris Hope
 
Posts: n/a
Default Re: PHP question
Viper wrote:

> On one of my sites I use
> <? header("location: http://www.MYDOMAIN.com/pages/index.php");?> to
> forward people that goto http://www.MYDOMAIN.com to that page. Now is
> there a way to make it randomly pick a file to send to?
>
> Like
> <?
> $num = $rand(1,3)
> header("location: http://www.MYDOMAIN.com/pages/index$rand.php");?>
> Where $rand would pick 1 2 or 3 then send the user to that index page?


Yes.

http://www.php.net/rand

"int rand ( [int min, int max])

If called without the optional min, max arguments rand() returns a
pseudo-random integer between 0 and RAND_MAX. If you want a random
number between 5 and 15 (inclusive), for example, use rand (5, 15)."

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/


Chris Hope
  Reply With Quote
Old 12-16-2004, 08:23 AM   #3
Viper
 
Posts: n/a
Default Re: PHP question
Chris Hope wrote:
> Viper wrote:
>
>> On one of my sites I use
>> <? header("location: http://www.MYDOMAIN.com/pages/index.php");?> to
>> forward people that goto http://www.MYDOMAIN.com to that page. Now is
>> there a way to make it randomly pick a file to send to?
>>
>> Like
>> <?
>> $num = $rand(1,3)
>> header("location: http://www.MYDOMAIN.com/pages/index$rand.php");?>
>> Where $rand would pick 1 2 or 3 then send the user to that index
>> page?

>
> Yes.
>
> http://www.php.net/rand
>
> "int rand ( [int min, int max])
>
> If called without the optional min, max arguments rand() returns a
> pseudo-random integer between 0 and RAND_MAX. If you want a random
> number between 5 and 15 (inclusive), for example, use rand (5, 15)."


Thanks that helped a bit.
This works:

<?
$newpage = "http://www.MYDOMAIN.com/pages/index".rand(1,3).".php";
header("location: $newpage")

;?>




Viper
  Reply With Quote
Old 12-16-2004, 08:45 AM   #4
Chris Hope
 
Posts: n/a
Default Re: PHP question
Viper wrote:

> Chris Hope wrote:
>> Viper wrote:
>>
>>> On one of my sites I use
>>> <? header("location: http://www.MYDOMAIN.com/pages/index.php");?> to
>>> forward people that goto http://www.MYDOMAIN.com to that page. Now
>>> is there a way to make it randomly pick a file to send to?
>>>
>>> Like
>>> <?
>>> $num = $rand(1,3)
>>> header("location: http://www.MYDOMAIN.com/pages/index$rand.php");?>
>>> Where $rand would pick 1 2 or 3 then send the user to that index
>>> page?

>>
>> Yes.
>>
>> http://www.php.net/rand
>>
>> "int rand ( [int min, int max])
>>
>> If called without the optional min, max arguments rand() returns a
>> pseudo-random integer between 0 and RAND_MAX. If you want a random
>> number between 5 and 15 (inclusive), for example, use rand (5, 15)."

>
> Thanks that helped a bit.
> This works:
>
> <?
> $newpage = "http://www.MYDOMAIN.com/pages/index".rand(1,3).".php";
> header("location: $newpage")
>
> ;?>


You could also do something like this, although there's a little more
overhead involved as it has to initiate the array and use memory:

$pages = array(
"somepage.php",
"anotherpage.php",
"someotherpage.php"
...
);

$rand = rand(0, sizeof($pages)-1);

$newpage = "http://www.MYDOMAIN.com/pages/" . $pages[$rand];
header("location: $newpage");
exit;

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/


Chris Hope
  Reply With Quote
Old 12-16-2004, 08:47 AM   #5
Charles Sweeney
 
Posts: n/a
Default Re: PHP question
Viper wrote:

> Chris Hope wrote:
>> Viper wrote:
>>
>>> On one of my sites I use
>>> <? header("location: http://www.MYDOMAIN.com/pages/index.php");?> to
>>> forward people that goto http://www.MYDOMAIN.com to that page. Now is
>>> there a way to make it randomly pick a file to send to?
>>>
>>> Like
>>> <?
>>> $num = $rand(1,3)
>>> header("location: http://www.MYDOMAIN.com/pages/index$rand.php");?>
>>> Where $rand would pick 1 2 or 3 then send the user to that index
>>> page?

>>
>> Yes.
>>
>> http://www.php.net/rand
>>
>> "int rand ( [int min, int max])
>>
>> If called without the optional min, max arguments rand() returns a
>> pseudo-random integer between 0 and RAND_MAX. If you want a random
>> number between 5 and 15 (inclusive), for example, use rand (5, 15)."

>
> Thanks that helped a bit.
> This works:
>
> <?
> $newpage = "http://www.MYDOMAIN.com/pages/index".rand(1,3).".php";
> header("location: $newpage")
>
> ;?>


Well done that man! Looks neat.

--
Charles Sweeney
http://CharlesSweeney.com


Charles Sweeney
  Reply With Quote
Old 12-16-2004, 09:37 AM   #6
Viper
 
Posts: n/a
Default Re: PHP question
Charles Sweeney wrote:
> Viper wrote:
>
>> Chris Hope wrote:
>>> Viper wrote:
>>>
>>>> On one of my sites I use
>>>> <? header("location: http://www.MYDOMAIN.com/pages/index.php");?>
>>>> to forward people that goto http://www.MYDOMAIN.com to that page.
>>>> Now is there a way to make it randomly pick a file to send to?
>>>>
>>>> Like
>>>> <?
>>>> $num = $rand(1,3)
>>>> header("location: http://www.MYDOMAIN.com/pages/index$rand.php");?>
>>>> Where $rand would pick 1 2 or 3 then send the user to that index
>>>> page?
>>>
>>> Yes.
>>>
>>> http://www.php.net/rand
>>>
>>> "int rand ( [int min, int max])
>>>
>>> If called without the optional min, max arguments rand() returns a
>>> pseudo-random integer between 0 and RAND_MAX. If you want a random
>>> number between 5 and 15 (inclusive), for example, use rand (5, 15)."

>>
>> Thanks that helped a bit.
>> This works:
>>
>> <?
>> $newpage = "http://www.MYDOMAIN.com/pages/index".rand(1,3).".php";
>> header("location: $newpage")
>>
>> ;?>

>
> Well done that man! Looks neat.


Thanks but now I have to wonder how search engines will handle it. See what
I am planning to do is take all the domains I own that have no pages on them
and make up "portal" pages using PPC Search engines. I want it to show a
different portal page that has a different set of PPC Search engines links
on it each time they visit. But will Google, etc even list these pages?




Viper
  Reply With Quote
Old 12-16-2004, 10:25 AM   #7
Charles Sweeney
 
Posts: n/a
Default Re: PHP question
Viper wrote:

> Charles Sweeney wrote:
>> Viper wrote:
>>
>>> Chris Hope wrote:
>>>> Viper wrote:
>>>>
>>>>> On one of my sites I use
>>>>> <? header("location: http://www.MYDOMAIN.com/pages/index.php");?>
>>>>> to forward people that goto http://www.MYDOMAIN.com to that page.
>>>>> Now is there a way to make it randomly pick a file to send to?
>>>>>
>>>>> Like
>>>>> <?
>>>>> $num = $rand(1,3)
>>>>> header("location:
>>>>> http://www.MYDOMAIN.com/pages/index$rand.php");?> Where $rand
>>>>> would pick 1 2 or 3 then send the user to that index page?
>>>>
>>>> Yes.
>>>>
>>>> http://www.php.net/rand
>>>>
>>>> "int rand ( [int min, int max])
>>>>
>>>> If called without the optional min, max arguments rand() returns a
>>>> pseudo-random integer between 0 and RAND_MAX. If you want a random
>>>> number between 5 and 15 (inclusive), for example, use rand (5,
>>>> 15)."
>>>
>>> Thanks that helped a bit.
>>> This works:
>>>
>>> <?
>>> $newpage = "http://www.MYDOMAIN.com/pages/index".rand(1,3).".php";
>>> header("location: $newpage")
>>>
>>> ;?>

>>
>> Well done that man! Looks neat.

>
> Thanks but now I have to wonder how search engines will handle it. See
> what I am planning to do is take all the domains I own that have no
> pages on them and make up "portal" pages using PPC Search engines. I
> want it to show a different portal page that has a different set of
> PPC Search engines links on it each time they visit. But will Google,
> etc even list these pages?


As I understand it, when using a redirection, Google will index the page
it gets sent to, but drop the sending page.

--
Charles Sweeney
http://CharlesSweeney.com


Charles Sweeney
  Reply With Quote
Old 12-16-2004, 01:55 PM   #8
Karl Core
 
Posts: n/a
Default Re: PHP question

"Charles Sweeney" <> wrote in message
news:Xns95C16A020C173mecharlessweeneycom@130.133.1 .4...
> Viper wrote:
>
>> Charles Sweeney wrote:
>>> Well done that man! Looks neat.

>>
>> Thanks but now I have to wonder how search engines will handle it. See
>> what I am planning to do is take all the domains I own that have no
>> pages on them and make up "portal" pages using PPC Search engines. I
>> want it to show a different portal page that has a different set of
>> PPC Search engines links on it each time they visit. But will Google,
>> etc even list these pages?

>
> As I understand it, when using a redirection, Google will index the page
> it gets sent to, but drop the sending page.
>



AFAIK that's only if Google knows it is a redirection - i.e. if you're
sending the proper headers while redirecting.
Would googlebot know if Viper's site is redirecting it?


--
-Karl Core
Please Support "Project Boneyard":
http://www.insurgence.net/info.aspx?...&item=boneyard




Karl Core
  Reply With Quote
Old 12-16-2004, 03:23 PM   #9
Jeffrey Silverman
 
Posts: n/a
Default Re: PHP question
On Thu, 16 Dec 2004 08:55:40 -0500, Karl Core wrote:

> AFAIK that's only if Google knows it is a redirection - i.e. if you're
> sending the proper headers while redirecting.
> Would googlebot know if Viper's site is redirecting it?


Probably. PHP is pretty decent about complying with header standards.

--
Jeffrey D. Silverman |
Website | http://www.newtnotes.com

Drop "PANTS" to reply by email



Jeffrey Silverman
  Reply With Quote
Old 12-16-2004, 03:25 PM   #10
Justin Koivisto
 
Posts: n/a
Default Re: PHP question
Viper wrote:
> Charles Sweeney wrote:
>
>>Viper wrote:
>>
>>
>>>Chris Hope wrote:
>>>
>>>>Viper wrote:
>>>>
>>>>
>>>>>On one of my sites I use
>>>>><? header("location: http://www.MYDOMAIN.com/pages/index.php");?>
>>>>>to forward people that goto http://www.MYDOMAIN.com to that page.
>>>>>Now is there a way to make it randomly pick a file to send to?
>>>>>
>>>>>Like
>>>>><?
>>>>>$num = $rand(1,3)
>>>>>header("location: http://www.MYDOMAIN.com/pages/index$rand.php");?>
>>>>>Where $rand would pick 1 2 or 3 then send the user to that index
>>>>>page?
>>>>
>>>>Yes.
>>>>
>>>>http://www.php.net/rand
>>>>
>>>>"int rand ( [int min, int max])
>>>>
>>>>If called without the optional min, max arguments rand() returns a
>>>>pseudo-random integer between 0 and RAND_MAX. If you want a random
>>>>number between 5 and 15 (inclusive), for example, use rand (5, 15)."
>>>
>>>Thanks that helped a bit.
>>>This works:
>>>
>>><?
>>>$newpage = "http://www.MYDOMAIN.com/pages/index".rand(1,3).".php";
>>>header("location: $newpage")
>>>
>>>;?>

>>
>>Well done that man! Looks neat.

>
> Thanks but now I have to wonder how search engines will handle it. See what
> I am planning to do is take all the domains I own that have no pages on them
> and make up "portal" pages using PPC Search engines. I want it to show a
> different portal page that has a different set of PPC Search engines links
> on it each time they visit. But will Google, etc even list these pages?


Depending on how your files are set up, instead of doing a redirect with
headers, you could use an include or an fpassthru call. That way, the
content is displayed without a redirect...

--
Justin Koivisto -
http://www.koivi.com


Justin Koivisto
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Dial-up Modem Question w_tom A+ Certification 0 09-18-2005 09:12 PM
"Installing two drives" question - what next? Jim A+ Certification 12 08-07-2005 01:19 PM
Re: Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good God DVD Video 3 04-25-2005 04:19 PM
Re: Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good Filthy Mcnasty DVD Video 0 04-25-2005 04:29 AM
Re: Safe Mode Question (A+ question) Gordon Findlay A+ Certification 0 06-16-2004 10:48 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46