Lee-Bartlett Posted November 14, 2008 Share Posted November 14, 2008 Here is my page, i would like my bottom button, the approve button to pass a value of yes to my db, but im not quite sure how to do this. the code for this is... <?php echo "<td><form action='' method='post'> <input type='hidden' name='id' value='yes'><input type='submit' value='approve' name='approvebutton' ></form></td>"; ?> i was thinking of doing somthing like this tho... <?php echo "<td><form action='' method='post'> <input type='hidden' name='id' value='" . $row['id'] . "'><input type='submit' value='update' name='updatebutton' ></form></td>"; ?> Quote Link to comment Share on other sites More sharing options...
rhodesa Posted November 14, 2008 Share Posted November 14, 2008 the button's value is what is passed and what is displayed on the button. why are you trying to pass a value of 'yes'? Quote Link to comment Share on other sites More sharing options...
Lee-Bartlett Posted November 14, 2008 Author Share Posted November 14, 2008 when a user fills in my form, i want it to be seen by the admins but not by the public so i can check it over and give it the ok, stops people putting random rubbish in to clogg space up. Quote Link to comment Share on other sites More sharing options...
Lee-Bartlett Posted November 14, 2008 Author Share Posted November 14, 2008 Anyone, i tried this echo "<td><form action='' method='post'> <input type='hidden' name='id' value='" . $row['approve'] . "'><input type='submit' value='yes' name='approvebutton' ></form></td>"; no luck Quote Link to comment Share on other sites More sharing options...
rhodesa Posted November 14, 2008 Share Posted November 14, 2008 i guess i don't completely understand what you want...why does the value have to be 'yes'? the following: <?php echo "<td><form action='' method='post'><input type='submit' value='approve' name='approvebutton' ></form></td>"; ?> will submit a value of 'approve'...why can't you just use that? Quote Link to comment Share on other sites More sharing options...
Lee-Bartlett Posted November 14, 2008 Author Share Posted November 14, 2008 Maybe im wording it wrong, maybe value isnt right word. All i need is a button to put the word yes into a db row, becuase the user side depends on that, i got select where approve=yes on my user side. Quote Link to comment Share on other sites More sharing options...
laPistola Posted November 14, 2008 Share Posted November 14, 2008 change the value from approve to yes. when you pass data from a form to a DB is whats in the value field that gets passed are you asking how do you get the data from the form into a DB? Quote Link to comment Share on other sites More sharing options...
Lee-Bartlett Posted November 14, 2008 Author Share Posted November 14, 2008 Yes for some reason some of my old code isnt working, i just need it, when this button is pressed it makes the row and the cell in the db say yes. I can do it with text boxxes but not buttons. Quote Link to comment Share on other sites More sharing options...
Lee-Bartlett Posted November 15, 2008 Author Share Posted November 15, 2008 anyone Quote Link to comment Share on other sites More sharing options...
mapleleaf Posted November 15, 2008 Share Posted November 15, 2008 I am guessing you want an admin to verify something. If so appearance doesn't matter so much. echo '<a href="update.php?id=$row['id']&value=yes">Approve</a>'; Then update.php runs the $query="UPDATE table SET value= '{$_GET['value']}' WHERE id = '{$_GET['id']}'" ; You ought to escape the data for security but that is my concept of how to do it. Quote Link to comment Share on other sites More sharing options...
Lee-Bartlett Posted November 15, 2008 Author Share Posted November 15, 2008 Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/nexodom/public_html/website/admin/index.php on line 74 is what im getting, how about using a radio button to put in a yes? Quote Link to comment Share on other sites More sharing options...
Lee-Bartlett Posted November 15, 2008 Author Share Posted November 15, 2008 Never knew it was so hard to get a submit button to put a yes into a collum, here it my most recent attempt but it just renamed the button and not put yet into the database. echo "<td><form action='' method='post'> <input type='hidden' name='approve' value='" . $row['approve'] . "'><input type='submit' value='yes' name='app' ></form></td>"; Quote Link to comment Share on other sites More sharing options...
laPistola Posted November 16, 2008 Share Posted November 16, 2008 put the whole code on here and someone will help. Quote Link to comment Share on other sites More sharing options...
laPistola Posted November 16, 2008 Share Posted November 16, 2008 That error does look like you have missed ; at the end of a line Quote Link to comment Share on other sites More sharing options...
l_kris06 Posted November 16, 2008 Share Posted November 16, 2008 Your problem lies at the hidden field where you are trying to print the value of $row['id'] inside the value field. Heres a working example: Test.php (page1) ============= <html> <title>Test</title> <head></head> <body> <?php $status = "approved"; ?> <form id="test" name="test" method="post" action="collect.php"> <label> <!-- We hide the value we want to send and then post it --> <input type="hidden" name="status" value="<?php echo $status;?>" /> <input type="submit" name="button" id="button" value="Submit" /> </label> </form> </body> </html> collect.php(page2) ============== <?php include('dbconn.php'); //include db connect file $status = $_POST['status']; //$state now contains the status value, in our case it contains approved //update db $updateDB = "update table set status = '$status' where id = 100;"; $success = mysql_query($updateDB); //use an if to check if your database is updated. from here on, you can redirect the user to another page, by using php's header() function ?> Quote Link to comment Share on other sites More sharing options...
redarrow Posted November 16, 2008 Share Posted November 16, 2008 <?php $updateDB = "update table set status = '$status' where id = '100'"; $success = mysql_query($updateDB)or die(mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.