Click to See Complete Forum and Search --> : Can i make a script that will do this


Conor
11-20-2003, 02:30 PM
i want to enter a number in a form. Then i want a new page to come up That says like you chose number 42 the correct # was 17. Sorry Please try again

so is this possible


even maybe a link to something to tell me how to do it

Sexay_Hamster
11-20-2003, 03:16 PM
u mean like pick a random number and guess it game?

that is extremely easy :D

n8guy
11-20-2003, 05:03 PM
Technically, it can be done, but with the hours, nay, DAYS, it would take to code, is it really worth it?

Or I guess you could probably do it in 5 minutes.

What you do is this:

> Create a form with some fields that points to the 'form handler' (handler.php, for example)
+ name one of those fields "guessedNumber"

> Create another page that is a 'form handler', which will take the number that the user submitted and compare it to another number and then return a message based on that
+ this is a .php page
+ create a variable that will grab the information submitted in the form, like this: $guess = @$_POST["$guessedNumber"]; for forms that use the post method or $guess = @$_GET["$guessedNumber"]; for forms that use the get method
+ write a conditional statement that says something like this: if ($guess == 17) { echo "you are smart!" } else { echo "you're a damn buffoon!" }

> Finally, go read some PHP tutorials, because this is stuff that you should have a handle of before you start coding

> Never be afraid to ask questions, just don't ever assume that someone will do the work for you without you looking into it and trying to get it done yourself

> ENJOY!

Conor
11-20-2003, 06:21 PM
:D thanks for all the help

pyro
11-20-2003, 08:05 PM
Originally posted by n8guy
Technically, it can be done, but with the hours, nay, DAYS, it would take to code, is it really worth it?What are you talking about? What do you think would take days? :confused:

Conor
11-20-2003, 08:11 PM
what i need the script for is the store on my message boards. Its liek a Roulette. I want the people to pick a # from 1-42 and then it will randomly generate another# which could bee write or wrong and then if there right it will tell them right

maybe something in the php manual about it

pyro
11-20-2003, 08:22 PM
Still not sure what was supposed to take "DAYS", but here's what 3 minutes and 30 seconds will get you. :rolleyes:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?PHP
if (isset($_POST['submit'])) {
$num = $_POST['num'];
$rand = rand(1, 42);
if ($num == $rand) {
echo "You are correct; you live.";
}
else {
echo "You are not correct; you die.";
}
}
?>
<form action="<?PHP echo $_SERVER['PHP_SELF']; ?>" method="post">
<p>Enter a number between 1 and 42: <input type="text" name="num"> <input type="submit" name="submit" value="submit"></p>
</form>
</body>
</html>

Conor
11-20-2003, 08:33 PM
thanks pyro ill run with that

pyro
11-20-2003, 09:17 PM
Happy to help... :)

n8guy
11-21-2003, 10:29 AM
Pyro - lol :D

I was being quite sarcastic when I said that... In fact, right after I said Technically, it can be done, but with the hours, nay, DAYS, it would take to code, is it really worth it? I said Or I guess you could probably do it in 5 minutes. So, I guess it would have taken me a minute and a half more than it took you... C'est la vie.

pyro
11-21-2003, 10:41 AM
Ah sorry... Guess your sarcasm was a bit hard to pick up. Since on forums, one does not have the benefit of hearing the tone of voice used, smilies are a good substitue to convey your emotion... ;)

n8guy
11-21-2003, 12:52 PM
Pyro - you bet! :) ;) :rolleyes:

Hey, I checked out your site and stuff - it looks sweet. You have official CSS, design, AND coding skillz. Impressive. InfinityPages.com is darn sweet as well. You rock.

In case you are interested, my associate just created a sweet CSS, XHTML-compliant, tableless site. He's a stud as well. It's http://sacajawea.idahostatesman.com/. It is not 'officially' out there right now, as it is going through final phases, but yeah. Anyway. You rock.

(sorry for spamming the thread)

pyro
11-21-2003, 01:16 PM
Thank you very much. :)

I took a look at that site. Astetically, quite nice, and not bad coding, either. Semantics could be a bit better, but that site is much better than most of them out there... :)