0

Hey everyone. I'm trying to write code to update a stat field within my database and I'm having some trouble passing the variables from the form page to the process page. Below is my code. I know it's not correct. I just want a button to say "Upgrade attribute 1" and on click it goes to process.php, figures out what button was clicked and then runs the function addOneStat which adds one to the stat field. In the future I will have many buttons and I was hoping that the process page could tell the difference between what button was clicked. Any suggestions?? Thanks.

//form page
    <table>
        <tr><td>
        <form action="process.php" method="POST">
            Update att1: <input type="hidden" name="subupgradestat" value="att1">
                         <input type="submit" name="att1" value="att1">
        </form>
        </td></tr>
    </table>
//process.php
    function procUpdateStat()
    {
        global $session, $database;
        
        if($_POST['att1'])
        {
            $database->addOneStat($field);
            header("Location: index.php?page=levelup&id=$session->userid");
        }
    }
3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by DanceInstructor
0

Instead of using buttons why not use just a hyperlink -

example:
<a href="process.php?att=Attribute1">Upgrade attribute 1</a>
<a href="process.php?att=Attribute2">Upgrade attribute 2</a>

etc. etc. etc. etc.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.