|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome. |
Share Thread: & Tags
|
||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi
I have a problem with php validation and redisplay of textareas in a form. I have a largish form I'm validating with PHP (still haven't learnt Javascript validation), but as there were only a few fields I cared about I thought I would stick with PHP. I finally learnt how to call the same page from the form, so that validation is at the top of the page, after checking that the form had been submitted. $errmsg = ""; if ($_POST['formsubmitted'] == 1) { /* start form validation */ $valid_form = "1"; $owneremail = $_POST["owneremail"]; $masteremail = $_POST["masteremail"]; etc. In the form, I needed to redisplay the contents of each field if there had been an error, so I had code like this: <input type=text name=owneremail value="<? print $owneremail; ?>"> My problem is that when I used textarea, the details were not redisplayed. Is there a different format for redisplaying the textarea fields? The page is http://www.sydney-web-design.com/fer...ookingform.php I still haven't finished everything - haven't done W3 validation yet, and there are hiccups, like the Javascript slideshow stops the css menu working in IE, and in Firefox some pictures go beyond the bottom of the page. I also had fun with sending mail after a valid form. I was testing the mail with a hotmail address hardcoded, and their filter would just completely disregard the mail. I thought the send wasn't working, until I hardcoded it to come from the same domain name. Even adding a CC later to a hotmail address wouldn't work. Or maybe it was a coincidence. And I kept getting php header errors when I used a $headers variable in the mail, so I changed it to the sample below. mail($to, $subject, $message, "From: $correspondto\n"); header("Location: thankyou.php"); This all seems very cumbersome. Is this really the way people code forms? Chris |
|
|||
|
if you want to put the value back in the textarea you need to do something like this:
<textarea name="somename"><?php echo $somevar; ?></textarea> Thats the way i've always done it and it works fine for me. Regarding the emailing I think some mail servers disregard emails if they aren't set to be from or to an email address on that server, at least thats what someone told me once. hope this helps |
|
|||
|
Hi Mike,
I'm using print instead of echo, same diff, and it works for all normal input=text fields, but not for the textarea ones. I Googled, but couldn't find any examples. Maybe it needs col and row variables in the print statement, or something horrible. I had vaguely heard about the server restriction on emails. But it's rather nasty that it doesn't give a warning - just plain didn't send the email. It also means that if I wanted to CC the email to an input address, so that the person filling in the form could get a copy of what they had sent, basically can't get it if they aren't on the same server. Or at least not if they have a hotmail address. Pretty crook. I'll try Yahooing php textarea form redisplay and see what happens. ta |
|
|||
|
Hi,
Think my 'web design' site's contact page does what you want? Take a look and feel free to submit a few mails to test how it works/blocks errors, no worries :) The textarea line looks like this: Code:
<textarea id="message" name="message" cols="40" rows="10" ><?php echo $message; ?></textarea> |
|
|||
|
Hi Mike
I hadn't initially noticed the absence of the "value" statement for textarea, so that was a miss. I tried both echo and print, to no avail. I also have a test version with less fields at http://sydney-web-design.com/fergusons/test2.php The current version there uses this code: <td><textarea name=owneraddress rows=4 cols=20 <? echo "$owneraddress"?> ></textarea></td> But still won't redisplay the content. I even put the same cut-and-pasted code above the form, and the echo worked there - just not inside the textarea. I'll keep playing.. |
|
|||
|
Ooh ooh
The > was in the wrong place! Thanks guys Chris |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |