Redirect to new page after every link is clicked

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
robertbarzyk
Forum Newbie
Posts: 19
Joined: Tue Oct 06, 2009 4:12 pm

Redirect to new page after every link is clicked

Post by robertbarzyk »

basically i have a page, with some links on it
is there a way i can redirect to another page
automatically after each link is clicked?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Redirect to new page after every link is clicked

Post by requinix »

Isn't that what links do? Redirect the user to another page?
robertbarzyk
Forum Newbie
Posts: 19
Joined: Tue Oct 06, 2009 4:12 pm

Re: Redirect to new page after every link is clicked

Post by robertbarzyk »

well yeah, but thats not what i mean haha
here is an example
say this would be my website,
and say i have all links set as target="_blank" so they open in a new page
and if i had x amount of links on my page
after all links are clicked i want the main page to redirect
WITHOUT having to click anything

i hope u understand what im trying to say,
if you dont get me ill provide my code
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Redirect to new page after every link is clicked

Post by requinix »

I have yet to see a quality site that does stuff like that. Frankly, it's annoying.

Know much JavaScript?

Code: Select all

<a href="someplace" target="_blank" onclick="document.location.href='anotherplace';">
robertbarzyk
Forum Newbie
Posts: 19
Joined: Tue Oct 06, 2009 4:12 pm

Re: Redirect to new page after every link is clicked

Post by robertbarzyk »

right now im in the process of learning javascript
so no im not too familiar with it =/
but that seems to work, but it redirects after clicking one link
if you got my message, it should clear up any confusion on what im asking
thanks
oliur
Forum Commoner
Posts: 29
Joined: Tue May 26, 2009 3:43 am

Re: Redirect to new page after every link is clicked

Post by oliur »

if you know the x amount beforehand each time a link is clicked use a session variable to count.

once the session varible equals to x amount you know users have clicked on the last link. For the very last link you can use the redirection.
robertbarzyk
Forum Newbie
Posts: 19
Joined: Tue Oct 06, 2009 4:12 pm

Re: Redirect to new page after every link is clicked

Post by robertbarzyk »

i will never know how many rows will be shown through my database
unless i use

Code: Select all

$result = mysql_query("SELECT * FROM people WHERE points>=0");      
$rows = mysql_num_rows($result);
this page will be changing constantly, links will come and go,
im coding a site for someone,but is used to help people get more friends on myspace
each person needs to have 0 or more points daily to be shown
if there in the negative they wont show,
but i think i will need javascript for this, im not very sure

again i need it so after every link is clicked on the page,
the page will auto redirect
here is my script so far

Code: Select all

 
<?php 
    
$ip = $_SERVER['REMOTE_ADDR']; 
 
mysql_connect("localhost", "unrealar_me", "xxxxxx") or die(mysql_error());
mysql_select_db("unrealar_login") or die(mysql_error());
 
mysql_query("UPDATE clicks SET clicks=0 WHERE ip='$ip'") 
or die(mysql_error());   
 
?>
 
<html>
<head><title>Get Famous</title>
<LINK REL=StyleSheet HREF="main.css" TITLE="Contemporary">
</head>
<body>
 
<center><div class="header";>
<?php
$fid = $_GET['user'];
 
?>
<?php
      
 
 
$start='<img src="';
$end='">';
 
mysql_connect("localhost", "unrealar_me", "xxxxxx") or die(mysql_error());
mysql_select_db("unrealar_images") or die(mysql_error());
 
$result = mysql_query("SELECT * FROM header") 
or die(mysql_error());  
 
while($row = mysql_fetch_array( $result )) {
    // Print out the contents of each row into a table
    echo $start." ".$row['head']." ".$end;
    
} 
echo "</table>";
?>
</div>
 
 
<center><div "class="riders";>
<?php
$add='<a href="http://www.unrealart.org/addme.php?friendid=';
$me='" target="_blank"><img border="0" src="addme1.gif">    ';
 
mysql_connect("localhost", "unrealar_me", "xxxxx") or die(mysql_error());
mysql_select_db("unrealar_login") or die(mysql_error());
 
$result = mysql_query("SELECT * FROM people WHERE points>=0")
or die(mysql_error());   
 
while($row = mysql_fetch_array( $result )) {
    // Print out the contents of each row into a table
        echo $add."".$row['friendid']."".$me;
       
    
} 
echo "</table>";
 
</div></center>
</body>
</html>
 
 
 
Post Reply