|
|
||||||
|
||||||
| 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 |
|
|||
|
I have created a dozen personal sites, but am finally doing my first paid one. So I want to do it properly.
I have a form, collecting around 20 input fields, and sending an email. Probably CCing to the sender. Whose email address will be entered. And I guess ideally should be validated. 1. Is it "better" to accept all input, and go to a new page with the thanks/success message. Or to stay on the same page, resetting all fields, displaying thanks/success message at the top/bottom of the page? 2. I have toyed with writing my own php code. It sends ok. But so far I'm not setting up the header info correctly. And I worry how resilient it is across platforms. Am I reinventing the wheel? Should I persevere with the php, or is there a standard formmail bit of code that everybody uses? Or is that lazy/cheating? Chris |
|
|||
|
I work in a small web design firm and we have hosting options of NT or Unix. Depending on which the client requests, we have a couple standard procedures we follow for this situation. For Unix we have php script that handles it all on the same page and sends a thank you to the sender. For NT, we have it redirect to a thank you page and send a thank you. In both cases though, we have a javascript regular expression that processes the email address to make sure its not just someone putting in jibberish.
|
|
|||
|
Quote:
As for validation, I'd suggest doing it in both JavaScript and PHP. JS will be more immediately responsive as mistakes are made and PHP will be more reliable in case they have JS turned off or are running a browser with a wonky JS impementation. Quote:
Quote:
|
|
|||
|
Many hosting companies offer built in form handler scripts. Check with yours. Some are also prohibiting FormMail scripts with glaring security holes so check before trying to install a script that may get your site suspended.
From a user point of view, send them to a thanks page. This makes it clear that the form submission worked. Any time you make it easy for the visitor, your site works better. Make sure the thanks page has navigation allowing the visitor to get back to the main body of your site. JM http://www.probizhosting.com - You can do it sitebuilder. http://www.crucibledesigns.com - Web Design & Development http://www.jomaries.com - Do it yourself website makeover |
|
|||
|
Ok. So I'll goto a new page when successful, and start by validating in php. (Will try javascript validation when I've got this right).
I'm a relative oldie who left uni before object-oriented stuff came in, so please forgive the top-down approach. (Long live Pascal and PL/1) The page to display the form will be formpage.php. If they enter it right, it will redirect to newpage.php. So in formpage.php: if details-entered then validate form. if valid-form then send-email if email-sent-ok then goto successpage (header(location: newpage) else set error message else (invalid-form) set field error messages ...... display form (action=formpage.php) hidden field details-entered set to true Is this how to structure it? The idea of validating before displaying the actual form seems wierd. I'm learning PHP from a QuickStart book at home, so haven't been able to look over the shoulder of people coding PHP nicely. When I re-enter formpage.php upon actioning the form, will I run into the problem that the fields entered will be reset to blank? All this validation code at the top is so search-engine unfriendly, too. Am I approaching this correctly? |
|
||||
|
Quote:
The form is submitted if (isset($submit_button)){ for each field in form{ if !validate(field){ generate a form with entered values pointing out where they messed up - or redirect back to form page with data on what they entered and how they messed up. } } if send(email){ Generate Success page }else{ Generate Error Page } } Quote:
Quote:
Quote:
|
|
|||
|
Thanks for help so far.
I've got a cut-down version going at http://sydney-web-design.com/fergusons/test.php, going mostly well with PHP validation, but there are some problems. I'm doing <input type=text name=ownername value="<? print $ownername; ?>"> so the text field value doesn't get reset to blank when they hit submit. But I haven't worked out how to do that for radio buttons. Any tips? Current radio html is: <input type="radio" name="correspondent" value="Owner">Owner <input type="radio" name="correspondent" value="Master">Master <input type="radio" name="correspondent" value="Agent">Agent Apart from that I think it's working. Will try the javascript validation next month. ta Chris |
|
|||
|
Quote:
<input type="radio" name="correspondent" value="Owner" <? print $correspondent="Owner"?"checked='checked'":"" ?>/>Owner <input type="radio" name="correspondent" value="Master" <? print $correspondent="Master"?"checked='checked'":"" ?>/>Master <input type="radio" name="correspondent" value="Agent" <? print $correspondent="Agent"?"checked='checked'":"" ?>/>Agent |
![]() |
|
| 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 |