Jump to content

Protection for a one time use PHP page


ridgey28

Recommended Posts

Hi I am wondering how to tackle a problem and would like some advice.

 

Basically I have a one time use registration script that sets up 3 tables in my database.  Once the tables have been setup, I then want to protect the page from being executed again.  I thought about deleting it from the server which is fine for me but is not user friendly to others when released.

 

My thoughts were to write a function to check the database.  If the database has already been setup then redirect the user, otherwise show the form.

 

My only question is that how do you check to see if the table has not been setup  without getting those horrible mysql error messages when the table does not exist.

 

Currently using MYSQL 5

 

What way would you do it?

 

Thanks in advance

 

Tracy

Link to comment
https://forums.phpfreaks.com/topic/201497-protection-for-a-one-time-use-php-page/
Share on other sites

My only question is that how do you check to see if the table has not been setup  without getting those horrible mysql error messages when the table does not exist.

 

You could use error suppression to hide said errors. eg Place @ before any call that might trigger an error. But deleting the file is likely your best option, you can have the script itself do this.

If you know the database name you can do:

 

SHOW TABLES [FROM database]

 

or if you don't:

 

SELECT count(*)

FROM information_schema.tables

WHERE table_name = <table-or-view-name>

 

Credits:

http://forums.mysql.com/read.php?101,33936,34067#msg-34067

http://forums.mysql.com/read.php?101,33936,34090#msg-34090

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.