473,324 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

force users to different pages?

Hello

Say I have a welcome page and 2 other pages, a.htm and b.htm.

How can I guide visitors, alternately to a and to b?

Cheers

Geoff
Mar 21 '08 #1
11 1444
Geoff Cox wrote:
Hello

Say I have a welcome page and 2 other pages, a.htm and b.htm.

How can I guide visitors, alternately to a and to b?
Put a gun to their head?

Not enough information, and not sure it is a good idea.

Do you mean alternated links from one visitor to the next? if so that
would require recording the which link was last presented on the server.

Or do you mean alternate for a single visitor upon subsequent visits?
That would require a persistent cookie.

A much simpler method would be a link randomizer.

<?php

$links = array('a.html','b.html','c.html','d.html');
$last=count($links)-1;
$link=$links[rand(0,$last)];

echo "<a href=\"$link\">Mystery Tour</a>";

?>

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Mar 21 '08 #2
On Fri, 21 Mar 2008 09:40:41 -0400, "Jonathan N. Little"
<lw*****@central.netwrote:
>A much simpler method would be a link randomizer.

<?php

$links = array('a.html','b.html','c.html','d.html');
$last=count($links)-1;
$link=$links[rand(0,$last)];

echo "<a href=\"$link\">Mystery Tour</a>";

?>
Thanks Joanathan,

when I use the above I get

Mystery Tour"; ?>

I must be missing something?

Cheers

Geoff

Mar 21 '08 #3
Geoff Cox wrote:
On Fri, 21 Mar 2008 09:40:41 -0400, "Jonathan N. Little"
<lw*****@central.netwrote:
>A much simpler method would be a link randomizer.

<?php

$links = array('a.html','b.html','c.html','d.html');
$last=count($links)-1;
$link=$links[rand(0,$last)];

echo "<a href=\"$link\">Mystery Tour</a>";

?>

Thanks Joanathan,

when I use the above I get

Mystery Tour"; ?>

I must be missing something?
1) your server must support php

2) the page is named with a ".php" extension (normally for most server
setups)

3) attention to the escaped quotes

echo "<a href=\"$link\">Mystery Tour</a>";
^ ^
or concatenate with single quotes

echo '<a href="' . $link . '">Mystery Tour</a>';

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Mar 21 '08 #4
On Fri, 21 Mar 2008 13:12:49 -0400, "Jonathan N. Little"
<lw*****@central.netwrote:
>The reason for the 2 pages is that this web site will have some music
related exercises and we wish to have a kind of control group etc.

And what will happen if the visitor has JavaScript disabled?
Much of the site will require javascript so if javascript disabled
these people will not be able to use the site ........... it is for a
short duration project.

The javascript (soundManager which uses flash) is used to play mp3
files and also for AJAX MySQL connection. I think I could use flash ro
create the sound items but I do not have Adobe Flash software.

Cheers

Geoff
>The server side solution means it doesn't matter.

Mar 21 '08 #5
..oO(Jonathan N. Little)
>3) attention to the escaped quotes

echo "<a href=\"$link\">Mystery Tour</a>";
^ ^
or concatenate with single quotes

echo '<a href="' . $link . '">Mystery Tour</a>';
Or simply

echo "<a href='$link'>Mystery Tour</a>";

HTML also allows single quotes, which avoids both the ugly escaping and
concatenations in the script.

Micha
Mar 21 '08 #6
On 2008-03-21, Jonathan N. Little wrote:
Geoff Cox wrote:
>On Fri, 21 Mar 2008 09:40:41 -0400, "Jonathan N. Little"
<lw*****@central.netwrote:
>>A much simpler method would be a link randomizer.

<?php

$links = array('a.html','b.html','c.html','d.html');
$last=count($links)-1;
$link=$links[rand(0,$last)];

echo "<a href=\"$link\">Mystery Tour</a>";

?>

Thanks Joanathan,

when I use the above I get

Mystery Tour"; ?>

I must be missing something?

1) your server must support php

2) the page is named with a ".php" extension (normally for most server
setups)

3) attention to the escaped quotes

echo "<a href=\"$link\">Mystery Tour</a>";
^ ^
or concatenate with single quotes

echo '<a href="' . $link . '">Mystery Tour</a>';
Or use the safer and more portable printf instead of the
deprecated echo:

printf '<a href="%s">Mystery Tour</a>\n' "$link"

--
Chris F.A. Johnson <http://cfaj.freeshell.org>
================================================== =================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Mar 21 '08 #7
..oO(Chris F.A. Johnson)
Or use the safer and more portable printf instead of the
deprecated echo:
Deprecated? Safer? More portable? What are you talking about?

The only thing is that (s)printf() is much more flexible if you want to
embed multiple variables or complex expressions in a string. That's it.
For everything else print and echo are perfectly fine.
>printf '<a href="%s">Mystery Tour</a>\n' "$link"
For PHP you just have to add some (),; and please remove the quotes
around the $link variable - quoting a single variable is just stupid.

Micha
Mar 21 '08 #8
On Fri, 21 Mar 2008 21:02:41 +0000, "Chris F.A. Johnson"
<cf********@gmail.comwrote:
Or use the safer and more portable printf instead of the
deprecated echo:

printf '<a href="%s">Mystery Tour</a>\n' "$link"
Chris,

I couldn't get above to work so after trying various combinations the
following is OK.

printf("<a href='%s'>Mystery Tour</a>",$link);

Seem OK to you?

Cheers

Geoff
Mar 21 '08 #9
On 2008-03-21, Michael Fesser wrote:
.oO(Chris F.A. Johnson)
> Or use the safer and more portable printf instead of the
deprecated echo:

Deprecated? Safer? More portable? What are you talking about?
I was talking about something completely different. My apologies;
please ignore my post.

--
Chris F.A. Johnson <http://cfaj.freeshell.org>
================================================== =================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Mar 21 '08 #10
Michael Fesser wrote:
.oO(Chris F.A. Johnson)
>>printf '<a href="%s">Mystery Tour</a>\n' "$link"

please remove the quotes
around the $link variable - quoting a single variable is just stupid.
Aren't the quotes around the $link variable part of the <acode, i.e.
for quoting the href attribute value?

--
Berg
Mar 21 '08 #11
..oO(Bergamot)
>Michael Fesser wrote:
>.oO(Chris F.A. Johnson)
>>>printf '<a href="%s">Mystery Tour</a>\n' "$link"

please remove the quotes
around the $link variable - quoting a single variable is just stupid.

Aren't the quotes around the $link variable part of the <acode, i.e.
for quoting the href attribute value?
No. The same in PHP would be

printf('<a href="%s">Mystery Tour</a>\n', "$link");

The quotes for the href attribute are already in the first parameter,
the format string. The second parameter is just the value for the %s
placeholder. For PHP "$link" is a double-quoted string with an embedded
variable. But since there are no other characters in the string, the
quotes are pointless and just cause an unnecessary parsing overhead.

Micha
Mar 21 '08 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Matthew Sims | last post by:
Is it possible to force a download without using the readfile function? My website setup consists of my server that serves the web pages plus a high-speed file server elsewhere on the internet...
24
by: Jim Hubbard | last post by:
Anybody know?
11
by: opt_inf_env | last post by:
Hello everybody, I have created a page consisting of two frames. The second frame is made to display "external" sites (i.e. written not by me, for example www.google.com). But I found that some...
3
by: xscully | last post by:
Is there a way to force the user to read a textarea? Just like those 'agreements' that is used in a few offline instalation.. You have to scroll all the way down of the textarea and then the I...
3
by: Stuart Read | last post by:
Hi, - I'm running .NET framework 1.1 on win2k server I'm investigating error pages at the moment. I have found how to: a) display friendly or real .NET errors in the remote browser, by...
9
by: Jonathan Wood | last post by:
I've spent days trying to come up with a solution. I'd appreciate it if anyone can help. My site requires all users to log on. There are three different roles of users, and each user type will...
3
by: Andy_Khosravi | last post by:
I have a method in place in my application to force users out. It's a simple tactic I got from these newsgroups where you create a table with one record called logout, then check that field with a...
41
by: Twayne | last post by:
Hi, How would I go about "forcing" a user from one page to another? I have a very simple random question/answer entrance requirement for an e-mail form. After 3 page views most people are...
0
by: peter.c.bradley | last post by:
Hi folks, I have an Access report that has an unbound text box in the details section. The report also includes the standard headers and footers. The details section is populated by a query...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.