Posted by Michael Austin on 10/22/25 11:40
csj wrote:
> I'm having a problem with my PHP script.
>
> When the user arrives on my page there is an item for sale for them to
> buy.
> The user already has 200 points stored in their database row. I want
> it work so that when the user clicks on the "buy" button(only then)
> an mysql query is executed to update there points.
>
> I thought of using an "if (isset ($_POST['submit'])) {...."
> script, but I don't know what to make the else part of the statement +
> I can't get it to work.
>
> If anybody knows what I'm talking about then please help me. Can I
> user the If statement or is there something better/easier to use?
>
> Thanks
> http://eye.cc php newsgroups
I use a "hidden" variable that only gets set at submit time
<html><body>
<?php
if (isset($_POST['flag'])) {
echo $_POST['in_name'] ."<br>";
echo '<form method=post><br><center>";
echo '<input TYPE=submit value=Back></center>';
echo '</form>';
// do a bunch of other stuff
}else {
?>
<form method="post">
Enter a NAME:
<input type="text" name="in_name" size="90" />
<input type=hidden name=flag value=1>
<input TYPE=submit value=Submit>
<input TYPE=reset value=Reset>
</form>
<?php
}
?>
</body></html>
--
Michael Austin.
DBA Consultant
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Navigation:
[Reply to this message]
|