Jump to content

Archived

This topic is now archived and is closed to further replies.

R1der

Can this be done?

Recommended Posts

ok this is hard to explain

I just made a game for my users. Basicly thay click alot of numbered links.

i.e
[code]<a href="#t=1&s=0#">0</a><a href="#t=1&s=1#">1</a><a href="#t=1&s=2#">1</a>[/code]

Ok so i got a rand statement

[code]<?
$rand = rand(1,100);
if($rand==1 || $rand==20 || $rand==25 || $rand==56 || $rand==72 || $rand==100) {

echo "Wow you found a needle. Keep looking and see if you can find more. Remember the more needles you find the better the chance of winning.";

$db->query("UPDATE users SET uNeedle=uNeedle+'1' WHERE uID='" . $user['uID'] . "'");
}
?>[/code]

ok now what i want it to do if the user gets the random number that echos "Wow you found a needle. Keep looking and see if you can find more. Remember the more needles you find the better the chance of winning." i want it to redirect them to say needle.php?view How can this be done?


Hope this makes sence :(

Thanks in advance

Share this post


Link to post
Share on other sites
Use a header redirect after you've updated the database.

[code]<?php
if($rand==1 || $rand==20 || $rand==25 || $rand==56 || $rand==72 || $rand==100) {

echo "Wow you found a needle. Keep looking and see if you can find more. Remember the more needles you find the better the chance of winning.";

$db->query("UPDATE users SET uNeedle=uNeedle+'1' WHERE uID='" . $user['uID'] . "'");

header("Location: needle.php?view");
}
?>[/code]

Regards
Huggie

Share this post


Link to post
Share on other sites
Thanks for your reply. but i tried that one b4 i posted my problem on here.

You see because the page dont refresh or anything when you click the links. it dont do anything really it just goes to say "needle.php#t=1&s=1#" and so on when clickin the links. that it but the page dont refresh

Does this make sence? if not you can goto [url=http://www.hcn-chat.com/needle.php]http://www.hcn-chat.com/needle.php[/url] to try this game to see what i mean.

Share this post


Link to post
Share on other sites
In that case I don't think I've understood what you're after.

As for getting me to try it, that page is riddled with errors.  I'd correct them first:

[quote]
Warning: main(../includes/inc-header.php): failed to open stream: No such file or directory in /home/fhlinux202/h/hcn-chat.com/user/htdocs/needle.php on line 3

Warning: main(../includes/inc-header.php): failed to open stream: No such file or directory in /home/fhlinux202/h/hcn-chat.com/user/htdocs/needle.php on line 3

Warning: main(../includes/inc-header.php): failed to open stream: No such file or directory in /home/fhlinux202/h/hcn-chat.com/user/htdocs/needle.php on line 3

Warning: main(): Failed opening '../includes/inc-header.php' for inclusion (include_path='.:/usr/share/pear') in /home/fhlinux202/h/hcn-chat.com/user/htdocs/needle.php on line 3
[/quote]

Regards
Huggie

Share this post


Link to post
Share on other sites
Thats just a copy of the game. that isnt the main game the error is just because i dragged it there so you didn't have to signup to my game if ya wanna see it without the errors you can signup to my game you can goto [url=http://www.hcn-chat.com/game]www.hcn-chat.com/game[/url]

Sorry about this.

Share this post


Link to post
Share on other sites
OK, let me see if I've got this correct...

The page loads, you click links on the page, this is meant to generate a random number using php and check if the random number is one of the needles.  If it is, it adds one to their total in the database and then redirects them to needle.php?view

Regards
Huggie

Share this post


Link to post
Share on other sites
Ok thanks for your reply huggie. i have now solved the problem. i just changed the links to goto somewhere else. like needles.php?stp=1 and so on. damnit was so simple. sorry to have wasted your time

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.