Page 1 of 1

pass a value from a .php file to other .php file

Posted: Wed Feb 25, 2009 10:46 am
by ktiniatros
Hello,

i have the following php file:

Code: Select all

<html>
<head><title>win</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>
<?php
$bet=2.75;
?>
<form method="post" action="update.php">
        <input type="number" name="stake" size="5"/><br/>
        <input type="submit" value="place"/></form>
</body><html>
and i want to pass the value $bet*stake (number that user will type in the input number field of the form multiplied with my integer variable)
to the update.php file.
how do i do that?? im frustrated with the tutorials i googled.
thanks in advance.

Re: pass a value from a .php file to other .php file

Posted: Wed Feb 25, 2009 2:20 pm
by asparak
stab in the dark, but look at this example and see if it helps any.
http://www.tizag.com/phpT/examples/formex.php

Re: pass a value from a .php file to other .php file

Posted: Wed Feb 25, 2009 2:35 pm
by granite
You can use global variables, such as $_SESSION and $_POST.

Pass the value $bet to a global variable in the code you posted.
$_SESSION['bet'] = $bet;

Then, in your other php code, use
$stake = $_POST['stake'];
$bet = $_SESSION['bet'];
$fbet = $bet*$stake;