PDA

View Full Version : [PHP] Script to only allow from a page... (Process form)



thesleuth
September 20th, 2006, 08:14 AM
Is there a script that only allows users to update their admin details ONLY on the page I've provided. (userdetails.php)

The way my users upload their personal details is through a process (process_update.php), PHP checks the user id and updates the mySQL table. So means that users can actually have another copy of the update form in their system and actioned to my process page and with a success!

What script do I use to prevent that? Thanks in advance.

bwh2
September 20th, 2006, 09:32 AM
$_SERVER['HTTP_REFERER'] (http://us3.php.net/reserved.variables)

thesleuth
September 20th, 2006, 09:49 AM
Thanks, but how come there is no referer when I submit from my system? (Not localhost)

bwh2
September 20th, 2006, 09:58 AM
did you try grabbing $_SERVER['HTTP_REFERER']? if not, you need to do that first.

also, as the PHP documentation i linked to says, HTTP_REFERER isn't always 100% reliable because it's not always set by the referer. so you need to make sure that your referring page does have it set.

thesleuth
September 21st, 2006, 05:39 AM
Grab? How do I go about doing it?

thesleuth
September 23rd, 2006, 08:19 AM
Oh and I want to create a clock (show the time) that every real minute equals to one hour and every real second is equal to one minute. How do I do it?

E.g. The time now is 12:05:50 PM and I want the clock to be 5:50 PM

I've tried but when the minute reaches 13, it will not change to one. Thanks in advance

bwh2
September 23rd, 2006, 11:03 AM
something like:

if( $_SERVER['HTTP_REFERER'] != 'server address you want' ) {
echo 'error';
}
else {
/* this is where you put your processing code */
}i'll play around with the clock idea a little bit, although i have no idea why you would want to do something like that.

thesleuth
September 23rd, 2006, 11:13 AM
Oh great, I finally figured it out. I used the if and else if methods... Thanks for the trouble.

thesleuth
September 28th, 2006, 06:39 AM
And by the way, how should I store what items my user has and also my user's profile? If it's in the database, do I have to create multiple columns to have an item name in it?

bwh2
September 28th, 2006, 10:06 AM
And by the way, how should I store what items my user has and also my user's profile? If it's in the database, do I have to create multiple columns to have an item name in it?i'm not sure what your site is about, but if you're trying to store user profile type of data, you might want to look through the facebook dissection thread (http://kirupa.com/forum/showthread.php?t=227583) for the database entity relationship diagram that i posted (post 55).

thesleuth
September 29th, 2006, 11:40 AM
Oh, you know, those inventories where player's items are being stored... however I do not know what's the best solution to store the data (the item names or ids) of what my players have. I am thinking of storing them in a colum of the user's table but I don't know how I should go about doing it. The facebook thread is very helpful. Thanks for your suggestions :D