Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Accessing form variables with PHP?

Trying to access form variables before a POST



11:38 pm on Sep 19, 2003 (gmt 0)

10+ Year Member

I'm trying to access values set by form objects from within PHP right before they are sent off via post.

For example:

<FORM name="testform" method="post" action="http://foo.com">
<INPUT TYPE="hidden" name="userid" value="3005">
<INPUT TYPE="image" src="some_button.gif" name="submit" onClick="<?php

$body = "Userid = ".? what do I put here to get the value out of the userid form field?

mail("foo@bar.com", "Someone clicked a form!", $body, "From:bar@foo.com");




11:51 pm on Sep 19, 2003 (gmt 0)

10+ Year Member


If I understand it right what you're trying to do, I'd say that it is not possible before the form gets submitted. The form values are on the client side whereas PHP is running on the server-side. Any processing would need to be done by the script specified in the

attribute. But then it's no problem - just put the
command in that script.

Hope it helps,



11:57 pm on Sep 19, 2003 (gmt 0)

10+ Year Member

I was afraid of that.

Unfortunately, I don't have control over the script in the action side, its being hosted by a third party.

Alternatively, could I call my own script or subroutine (even Javascript) and have it re-issue the post? I have no idea how to issue a post without a submit button though...



5:50 am on Sep 20, 2003 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Welcome to WebmasterWorld CernyM,

You could plug in your script as the action and then you have two choices

1. Make a confirmation screen. Email all you need to yourself and then have another submit button at the bottom to resub the info to the other script. Have a titla similar to "You ebtered this info please click submit to send it".

2. take a look at curl


Featured Threads

Hot Threads This Week

Hot Threads This Month