Forum Moderators: coopster

Message Too Old, No Replies

Inserting user id into hidden form field

         

eball

7:59 pm on Oct 2, 2008 (gmt 0)

10+ Year Member



Hey guys

PHP newbie here. I was wondering if there was a simple way to retrieve and insert a logged in user's ID into a hidden form field. As it stands, I have no way of knowing who is submitting what. Currently using Quadodo as the main login script, and FormTools as my forms processing script.

Any thoughts, suggestions, etc. will be greatly appreciated :)

Eball

eelixduppy

11:42 pm on Oct 2, 2008 (gmt 0)



I'm assuming you are storing the users name at least in a session variable? If so, and the form is being submitted within the same domain, you shouldn't need to use a hidden field in a form, just use the session value itself. Is this the case?

and Welcome to WebmasterWorld! :)

eball

4:42 am on Oct 3, 2008 (gmt 0)

10+ Year Member



Yes that is the case. Forgive my vagueness, like I said, I"m new to this stuff and don't really know what I'm doing yet. It's a process, ya know ;)

I am saving the user ID as a session variable, I can even see it encrypted in my cookies. I just have no idea how to get it into my form. When a user submits a form, I have no idea which user submitted it.

Thanks for your reply, and for helping us newbs :)

Anyango

5:34 am on Oct 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In the Form

<input type="hidden" name="user_id" value="<?php echo $_SESSION['user_id'];?>">

and in the form processing Script

$user_id=$_REQUEST['user_id'];

use $_GET or $_POST depending upon your form METHOD instead of $_REQUEST.

[edited by: Anyango at 5:37 am (utc) on Oct. 3, 2008]

d40sithui

2:43 pm on Oct 3, 2008 (gmt 0)

10+ Year Member



Yes that is the case. Forgive my vagueness, like I said, I"m new to this stuff and don't really know what I'm doing yet. It's a process, ya know ;)
I am saving the user ID as a session variable, I can even see it encrypted in my cookies. I just have no idea how to get it into my form. When a user submits a form, I have no idea which user submitted it.

Thanks for your reply, and for helping us newbs :)


if you learn to write your own login script, this will be cake. it's worth the time and you will get a lot out of it. first listing for google search with keywords "php login script" yields ::
[phpeasystep.com...]
looks pretty good i think. Like eelix mentioned, if the Id is stored in a session variable, then you will have no problem getting it. if you want to put it in a hidden field, its even easier.

eball

2:57 pm on Oct 3, 2008 (gmt 0)

10+ Year Member



Thanks so much guys, everything's working now :)