RE: [PHP] forms and variables?
[snip] Probably a stupid one but anyway... In PHP. Is it possible to point to a variable with the HTML form name by which it was posted from? Example: //point to the variable with something like or somenthing??? $AddNew.SomeVar form name=AddNew method=post action=? $PHP_SELF ? $SomeVar = Add; /form form name=DeleteOld method=post action=? $PHP_SELF ? $SomeVar = Del; /form Or do I just have name the variables uniquely? [/snip] You could write a function...looks like you're trying to do something similar to DOM. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms and variables?
take the following code and do some experimentation: ? echo 'pre'; echo POST vars: \n; var_dump($_POST); echo GET vars: \n; var_dump($_GET); echo '/pre'; ? stick that in your page that contain the form and start playing with different form fields, different form fields names, etc, etc - everytime you submit you'll know see what's being submitted. enjoy William Stokes wrote: Hello, Probably a stupid one but anyway... In PHP. Is it possible to point to a variable with the HTML form name by which it was posted from? Example: //point to the variable with something like or somenthing??? $AddNew.SomeVar this is not asp.NET/asp.NOT, so no to that question. god only knows what you mean by the form examples below... form name=AddNew method=post action=? $PHP_SELF ? $SomeVar = Add; /form form name=DeleteOld method=post action=? $PHP_SELF ? $SomeVar = Del; /form Or do I just have name the variables uniquely? I would, in general, recommend calling every $x. ;-) Thanks -Will -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms and variables?
At 3:45 PM +0300 4/21/06, William Stokes wrote: Hello, Probably a stupid one but anyway... In PHP. Is it possible to point to a variable with the HTML form name by which it was posted from? Example: //point to the variable with something like or somenthing??? $AddNew.SomeVar form name=AddNew method=post action=? $PHP_SELF ? $SomeVar = Add; /form form name=DeleteOld method=post action=? $PHP_SELF ? $SomeVar = Del; /form Or do I just have name the variables uniquely? Thanks -Will -Will: Sure, you're almost there, just make a hidden variable $whichform and use it like so: form name=AddNew method=post action=? $PHP_SELF ? input type=hidden name=whichform value=add /form form name=DeleteOld method=post action=? $PHP_SELF ? input type=hidden name=whichform value=del /form HTH's tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms and variables?
On Fri, April 21, 2006 7:45 am, William Stokes wrote: In PHP. Is it possible to point to a variable with the HTML form name by which it was posted from? The FORM name attribute was an add-on for Javascript client-side. It is not transmitted by HTTP. PHP never sees it. Or do I just have name the variables uniquely? Yes. Or you could just add ONE new INPUT in each form to tell you which FORM was used: INPUT TYPE=HIDDEN NAME=FORM VALUE=AddNew / Or you could have just ONE form and use buttons with name for your INPUTs: form name=irrelevant ... input type=submit name=AddNew value=Add / input type=submit name=DeleteOld value=Del / /form The button the user clicked on is sent as a variable with HTTP. EXCEPTIONS: If there is only ONE submit button, and if the user hits Enter (aka Return) instead of actually clicking on the button, then some browser do not send the button name/value. If you use JavaScript to do the submit, it's your problem to add whatever inputs you need in JavaScript to make things work... As well as anything in JavaScript works, anyway. Or you could have the FORMs have different ACTION attributes so you know which form sent the data because you have scripts dedicated to a specific purpose instead of some monolithic mess trying to be-all do-all end-all. Or you can use arrays in the NAME attributes to organize things in some cases -- probably not in this particular instance, but keep it in mind for INPUT elements within the same form. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Forms Session variables
Guru Geek wrote: perhaps javascript? let me know if you need further help! JavaScript can be turned off. -- W | I haven't lost my mind; it's backed up on tape somewhere. + Ashley M. Kirchner mailto:[EMAIL PROTECTED] . 303.442.6410 x130 IT Director / SysAdmin / WebSmith . 800.441.3873 x130 Photo Craft Laboratories, Inc.. 3550 Arapahoe Ave. #6 http://www.pcraft.com . . .. Boulder, CO 80303, U.S.A. smime.p7s Description: S/MIME Cryptographic Signature
Re: [PHP] Forms Session variables
You need to slow down and think things through. My recommendation would be to get a SINGLE PAGE form to work how you want first, then assess the logic needed to move onto multiple forms. Also, this was asked a while back, so here was my answer sample code last time: http://marc.theaimsgroup.com/?l=php-generalm=104371796307302w=2 Justin on 11/03/03 4:45 PM, Ashley M. Kirchner ([EMAIL PROTECTED]) wrote: I'm trying to build a multi-step form and using sessions to register the field values, but having serious issues. This is what I'd like to do: step 1 (first page): ask for name, address, email. [submit] step 2 (second page): ask for more personal information [submit] step 3 (last page): ask for specific event information [submit] send everything to a back end MySQL db, and redirect to a thank you page. This whole process is just one form.php file that posts to a process.php script. The content of form.php gets changed based on the step# (they get included step1.inc, step2.inc, and step3.inc.) However, after each [submit] I would like to verify the data prior to continuing to the next page. If any of the fields are missing or incorrect, we re-post the same page with the correct fields already filled in (based on whatever the user entered), and the missing one ... blank (obviously.) But, if everything is okay, and all fields check out, register the values and go on to the next page. Repeat the process. I'm having a heck of a time with the validation part. Either things don't register, or it gets stuck in a loop, regardless of what I change after the re-post. So, I need some help. I need some code...help! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php