Jump to content

Recommended Posts

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! 

Link to comment
https://forums.phpfreaks.com/topic/233420-how-do-i-create-a-admin-approved-entry/
Share on other sites

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  :P

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  :P

 

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? 

it never knows anything, you have to tell it.  ;D

 

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

it never knows anything, you have to tell it.  ;D

 

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!

  • 1 year later...

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 by scm22ri

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.