This is a discussion on "[SOLVED] PHP Contact Form" within the PHP Forum section. This forum, and the thread "[SOLVED] PHP Contact Form are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
[SOLVED] PHP Contact Form
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
[SOLVED] PHP Contact Form
Hello everyone,
I have a small problem with the contact form on my website. When the form is submitted, and there was something wrong with something the user entered into the form, the label for that field changes color. Here is a visual: No error Label: [textbox] Error Label: [textbox] Now, that part works great. The problem is that when the form is redisplayed because there was something wrong, the stuff that was entered should still be there so the user knows what they typed and can see if they made a mistake. My entire code is as follows:
Thanks
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
|
|
|
|
#2
|
||||
|
||||
|
Re: PHP Contact Form
You needn't worry about adding the $_POST variables to $variables, just do a check within each and write straight from $_POST
eg value="<?php echo isset($_POST['name']) ? $_POST['name'] : ''; ?>
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
#3
|
|||
|
|||
|
Re: PHP Contact Form
Hmm... It works, yes, but I was wondering if there is one code that can do this for every field without having to add php into the value.
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
|
|
#4
|
||||
|
||||
|
Re: PHP Contact Form
Nope.
Unless you write the entire form with PHP, ie echo everything then you will have to intermingle the code, php writes the HTML it doesn't interact with it. Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
#5
|
|||
|
|||
|
Re: PHP Contact Form
Using templates could maybe simplify your problem....
Last Blog Entry: 10 Reasons Why My Laptop Is Better Than Your Girlfriend (Dec 15th, 2007)
|
|
#6
|
|||
|
|||
|
Re: PHP Contact Form
Templates is not something I want to use on this particular site. Luke's suggestion works fine so I'll use that.
Thanks for the help!
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
Last edited by Stuart; Dec 4th, 2007 at 17:18. |
|
#7
|
|||
|
|||
|
Re: PHP Contact Form
Actually, another small question. Luke, the code you posted works for the textfields, but what about radio buttons and checkboxes? Can't seem to figure it out...
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
|
|
#8
|
||||
|
||||
|
Re: PHP Contact Form
inside them use
<?php echo $_POST['what'] == 'this_value' ? ' selected="selected" ' : ''; ?> replacing selected with checked for radios etc.. So with those, you're checking agains the value that option of radio holds
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
#9
|
|||
|
|||
|
Re: PHP Contact Form
OK, great! It works perfectly! Thanks for all your help
Thread Solved
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] PHP contact form problem | fl0w | PHP Forum | 12 | Jan 31st, 2008 17:56 |
| [SOLVED] PHP contact form redirect to same form | Posie | PHP Forum | 14 | Jan 29th, 2008 20:28 |
| [SOLVED] Wordpress contact form - getting 404 on send | Aso | PHP Forum | 3 | Jan 25th, 2008 11:23 |
| [SOLVED] Contact Form Help | danny322 | PHP Forum | 3 | Nov 7th, 2007 16:05 |
| [SOLVED] PHP Contact Form | Stuart | PHP Forum | 9 | Oct 20th, 2007 00:48 |