Dave, Thank you, yes, that helps a lot. Particularly makes me understand a little more of isset() which I now recall Bj was introducing me to when I was getting to grips with php some time ago.
So the script will pick up the entered value without the value attribute, so long s there is a name attribute; the php in the value attr. does not affect this, but allows the part correct form to be represented, without forcing the user to refill values that are ok. ? Sometimes there are boxes that drop down with choices - like countries - which are not radio buttons or checkboxes. That was in my mind, wondering if that was why I was having trouble with the piece of script. Your explanation removes that confusion. Though my shaky small understanding of php got very rusty I am at least able to see script now with a modicum of recognition! Joseph Joseph Harris www.smilepoetryweekly.com From: "David Precious" > On Friday 24 June 2005 04:09, Joseph Harris wrote: > > I am just settling in my mind conflicting ways of dealing with forms. > > > > In one the user box is identified by name="whatever" and that is > > dealt with by the action file. > > > > The other is something like this: value="<?=$_POST['first_name'];?>" > > also dealt with by the action file. > > > > Am I right in thinking the second would be used where there is a > > range of options to select from. I have an example which, as there > > is no list, produces a notice of an unidentified variable and also > > shows the php code in the textbox. > > > > Is there a reason for using the second version where the form is > > filled with new information? > > The second version simply writes the value of $_POST['first_name'] (if > there is one) in place of the <?....?> bit. > > This is useful if the form has been submitted but something was wrong > with the input, you can re-display the form with the values that were > submitted filled in. > > However, if the form hasn't yet been submitted to itself, that will not > work, you'd need to do something like: > > <input .... value="<?php echo (isset($_POST['first_name']))? > $_POST['first_name'] : ''; ?>"> > (that could all be on one line) > > That'd stop the problems with undefined variables. > > If your form is submitting to a seperate "action" file then that won't > help you anyway. > > It sounds as though you're trying to figure out how to get at the > contents of form fields submitted to the PHP script, am I right? > > In that case, given a field: > <input type="text" name="first_name" value="" /> > in the form, when the form is POSTed to the PHP script, the value the > user entered in the first_name field can be found in > $_POST['first_name']. > > I'm not sure what you mean by "lists" - if you mean a simple select > list, it works the same. > > If it's a set of checkboxes, the easy way is to do: > > <input type="checkbox" name="Food[]" value="Chicken" /> > <input type="checkbox" name="Food[]" value="Pizza" /> > > Because of the square brackets in the name 'Food[]', the contents of > $_POST['Food'] when submitted will be an array of the items that were > checked. > > The same principle applies for a multiple <select> field. > > Hope this helps a little? > > Cheers > > Dave P ____ The WDVL Discussion List from WDVL.COM ____ To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] or use the web interface http://e-newsletters.internet.com/discussionlists.html/ Send Your Posts To: [email protected] To change subscription settings, add a password or view the web interface: http://intm-dl.sparklist.com/read/?forum=wdvltalk ________________ http://www.wdvl.com _______________________ You are currently subscribed to wdvltalk as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED] To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016 Please include the email address which you have been contacted with.
