The values of a form can not be passed on to the action file or the action file can not get the values of the fields in the form
Question
This is the PHP code:
$html=<<<eod
<div>Your current account balance is <span style="color:red">$$balance</span></div><br/>
<form id="digitalchange" action="digitalchange.php?" action="post">
<input type="hidden" name="tid" value=$announcementid />
<table rules=all FRAME=BOX><tr><td>Balance:<span class="price">$balance</span></td><td>Current Shortfall:$shortfall</td>
<td>Unit Price:<span class="price">$$unitprice</span></td></tr>
<tr><td>Add Balance:$<input type="text" id="addbalance" name="addbalance" size="5" /></td>
<td>Add Shortall:<input type="text" id="addquota" name="addquota" size="4" /></td><td></td></tr>
<tr><td></td><td>Reduce Shortfall:<input type="text" id="reducequota" name="reducequota" size="4" /></td><td></td></tr></table>
Please click Confirm only once.
<input type="submit" value="Confirm" /></form>
<hr>
eod;
echo $html;
Below are the first two lines in digitalchange.php:
$addbalance=$_POST['addbalance'];
echo "What is wrong".$addblance;
Outputs:
What is wrong
digitalchange.php simply can not get the value of addbalance,I tried $_REQUEST, but still failed. The inputbox of addbalance is not empty. But it seems that the values of the form of digitalchange can not be passed on to digitalchange.php. What's wrong?
Solution
I see two things wrong with the code you posted:
<form id="digitalchange" action="digitalchange.php?" action="post">
^
This should be method="post"
. Try validating your HTML to find problems like this.
$addbalance=$_POST['addbalance'];
echo "What is wrong".$addblance;
^
A simple typo here. You should always check your error log, it would have given you a warning about using an undeclared variable $addblance
.
OTHER TIPS
try print_r($_POST)
and print_r($_GET)
as you probably just have a typo in a field name somewhere.