Jump to content

BeeR_KeG

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

BeeR_KeG's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Many thanks to the both of you. I appreciate wildteen's inout script, but to put it simply, I'd rather do it with PHP because $minerals is not the only variable I'll be transfering, but a little knowledge doesn't hurt.
  2. Alright, I need to transfer the value of a variable which is generated by mt_rand( ). I want that same value to be transfered to another file, but everytime I test it, I get the undefined variable error. I can't include the file with the piece of code that generates the integer, because it'll create a different number. I've tried setting it as a global variable and trying to create a session, but I don't have much experience in there. I'd also like it if it didn't require the use of a MySQL, because I know nothing about that. Here's the code: data.php [code]<?php srand((double)microtime() * 1000000); $minerals = rand(0, 2500); global $minerals; ?>[/code] index.php [code]<?php error_reporting(E_ALL & ~E_NOTICE); session_start ( ); echo <<<HTML <form action="form.php" method="POST"> Enter your username: <input type="text" name="name" /><br /> Enter the amount of minerals you wish to bet: <input type="text" name="minbet" /><br /> <input type="submit" /> </form> HTML; require ("data.php"); echo "You currently have {$minerals} minerals <br />"; ?>[/code] form.php [code]<?php error_reporting(E_ALL & ~E_NOTICE); echo "Welcome {$_POST["name"]} <br />"; echo $minerals; ?>[/code] Alright, here's a brief summary of what is happening. I start up in index.php, which gives me an HTML form which asks for a name and amount of minerals to bet. The file will include $minerals, which is a random integer from 0 to 2500 which will be generated in data.php and required in index.php. When I submit the query form in index.php, it'll load form.php, but the $minerals doesn't transfer. Thanks in advance.
×
×
  • 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.