Help with form buttons

Reply

Join Date: Oct 2006
Posts: 164
Reputation: Barefootsanders is an unknown quantity at this point 
Solved Threads: 3
Barefootsanders Barefootsanders is offline Offline
Junior Poster

Help with form buttons

 
0
  #1
Apr 8th, 2007
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.

  1. //form page
  2. <table>
  3. <tr><td>
  4. <form action="process.php" method="POST">
  5. Update att1: <input type="hidden" name="subupgradestat" value="att1">
  6. <input type="submit" name="att1" value="att1">
  7. </form>
  8. </td></tr>
  9. </table>

  1. //process.php
  2. function procUpdateStat()
  3. {
  4. global $session, $database;
  5.  
  6. if($_POST['att1'])
  7. {
  8. $database->addOneStat($field);
  9. header("Location: index.php?page=levelup&id=$session->userid");
  10. }
  11. }
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 187
Reputation: phper is an unknown quantity at this point 
Solved Threads: 15
phper's Avatar
phper phper is offline Offline
Junior Poster

Re: Help with form buttons

 
0
  #2
Apr 13th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: Help with form buttons

 
0
  #3
Apr 14th, 2007
<input type="submit" value="att1">

and in your php do:

if($_POST['submit'] == "att1") {
do stuff...
}
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC