Jeffro Posted April 11, 2011 Share Posted April 11, 2011 Hello. I'm not a php programmer. I just play one on the internet. Point being that I know enough to make small things happen and can slop some code together for little ideas. For my newest idea, I'm trying to have a user submitted form that requires admin approval. I know how to create a form and do the mysql insert, but how I do create a "hold" on the data being sent from a form, so that I can require approval? I'm looking for the easiest way.. If I need to approve directly through mysql (instead of creating an admin.php page), then that would be fine. I don't anticipate a lot of submissions. Just wasn't sure how this is usually handled. Thanks! Quote Link to comment Share on other sites More sharing options...
spiderwell Posted April 11, 2011 Share Posted April 11, 2011 set an extra column in the db called approved, and have it default to 0 in db structure, then as later admin you can set to 1 to approve it. when user submits, use the same code, as approved wont need entering to the row, its will set to 0 by default. then via phpmyadmin, or build a page for an admin to login to set approved to 1 **disclaimer** this is how i would do it, there might be a better way Quote Link to comment Share on other sites More sharing options...
Jeffro Posted April 11, 2011 Author Share Posted April 11, 2011 set an extra column in the db called approved, and have it default to 0 in db structure, then as later admin you can set to 1 to approve it. when user submits, use the same code, as approved wont need entering to the row, its will set to 0 by default. then via phpmyadmin, or build a page for an admin to login to set approved to 1 **disclaimer** this is how i would do it, there might be a better way So "approved" is some sort of "built-in" column whereby just creating it, mysql will know to hide the entire row until set to 1? Quote Link to comment Share on other sites More sharing options...
spiderwell Posted April 11, 2011 Share Posted April 11, 2011 it never knows anything, you have to tell it. lets assume the front end will only display approved items SELECT * FROM table1 WHERE `approved` = 1 on the admin side do the opposite to get the unapproved ones, but if you dont want to build a backend management page, just do it directly in phpmyadmin as you stated Quote Link to comment Share on other sites More sharing options...
Jeffro Posted April 11, 2011 Author Share Posted April 11, 2011 it never knows anything, you have to tell it. lets assume the front end will only display approved items SELECT * FROM table1 WHERE `approved` = 1 on the admin side do the opposite to get the unapproved ones, but if you dont want to build a backend management page, just do it directly in phpmyadmin as you stated Ahh! Makes perfect sense. Don't know why I didn't think of it! Thanks much for your help! Quote Link to comment Share on other sites More sharing options...
scm22ri Posted January 4, 2013 Share Posted January 4, 2013 (edited) Hi Everyone, I know this question is kinda old but this is what I'm attempting to do. My only concern is when I have a default value 0. The item my user is inputting into the database via a form is automatically displaying on my website. It's my understanding if a item has a default value of 0 shouldn't my MySql database know not to show that item without me approving it first? aka turning the 0 into a 1? The structure of my column. My column is called 'approve' Type ENUM Length/Values '0','1' Default As Defined 0 With a setup like this shouldn't MySql know now to show the items that have a mark of 0? Edited January 4, 2013 by scm22ri Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 4, 2013 Share Posted January 4, 2013 Databases don't know anything about what your data is, they just store it and let you retrieve the data you are interested in. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 4, 2013 Share Posted January 4, 2013 The only thing that comes to mind that would 'automatically' do this, is if you use a VIEW with a where clause that only matches rows that are approved - CREATE VIEW view_name AS SELECT * FROM some_table WHERE approve = 1;. You would normally use the name of the view in queries. You would use the actual table name in queries when accessing all the rows for administrative purposes. 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.