Jump to content

Can this be done?


R1der

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
Link to comment
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
Link to comment
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.
Link to comment
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
Link to comment
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.
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.