Welcome to WebmasterWorld Guest from 54.205.126.164

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)

Preferred Member

10+ Year Member

joined:Sept 16, 2003
posts:485
votes: 0


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");

?>">

--Mike

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

New User

10+ Year Member

joined:Feb 23, 2003
posts:27
votes: 0


Hi,

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

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

Hope it helps,

M.

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

Preferred Member

10+ Year Member

joined:Sept 16, 2003
posts:485
votes: 0


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

--Mike

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

Administrator

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

joined:July 24, 2001
posts:15756
votes: 0


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
[ca.php.net...]

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members