Page 1 of 1

Redirect to new page after every link is clicked

Posted: Tue Oct 06, 2009 5:11 pm
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?

Re: Redirect to new page after every link is clicked

Posted: Tue Oct 06, 2009 5:31 pm
by requinix
Isn't that what links do? Redirect the user to another page?

Re: Redirect to new page after every link is clicked

Posted: Tue Oct 06, 2009 5:43 pm
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

Re: Redirect to new page after every link is clicked

Posted: Tue Oct 06, 2009 6:04 pm
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';">

Re: Redirect to new page after every link is clicked

Posted: Tue Oct 06, 2009 6:12 pm
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

Re: Redirect to new page after every link is clicked

Posted: Tue Oct 06, 2009 6:32 pm
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.

Re: Redirect to new page after every link is clicked

Posted: Tue Oct 06, 2009 6:45 pm
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>