![]() |
Form Validation Not Working :(
Hey guys!
Well I have really worn my brain down with what is prob very simple to you seasoned php\'ers! For me there are two issues here but the first is this: When I try testing my form using adapted code from WildHoney here, I find that it keeps giving me the email error message implying the email isn't valid. It is a valid email address and as far as I can see the regex is correct. I am getting no php errors (am testing locally on MAMP). Here is the adapted code (have left WH's comments in to guide sad old me lol); PHP Code:
Is that right? I am sorry this is prob a very simple issue but this is big for me at the moment! LOL. Thanks in advance :) |
You've not populated the
$aVariables array with the items from your form. It should be something like the following:php Code:
|
Well now I am officially a prize prat! *Sigh* Thankyou and sorry :)
|
For fear of asking too much... any ideas for the second part?
I have added into my form this; onSubmit="valid_form();" in the form tag, and made the php and html one page with the action the same file (check.php). I am getting a "undefined index" error on all the variables. I think I need another php book to help me understand more of this stuff :( |
Quote:
Well I could be wrong, but you don't need onSubmit="" at all. Why are you doing that? Are you calling a javascript? Secondly, you can definitley have the php and html all in one page. (check.php) |
I think I have probably just lost the plot to be honest. I have spent so long trying to get this questionnaire working I have almost forgotten the original goal!
Ok so I have taken the on submit bit... the undefined variables error still coming up and it is testing the form validation before I have done anything to it. I put the php in the head. Should I be putting it somewhere else? |
Quote:
Testing it will be tricky, I think you have to close out of your browser for each test, because once you fill out the form, the POST variables will exist, even if you keep hitting refresh. I could be wrong... That could be why it seems the page keeps trying to validate your form? As for the undefined variables, can you post your latest code? |
PHP Code:
|
Where's the form!??
|
Sorry...
Thanks for your patience :) HTML Code:
<form action="send3.php" method="post"> |
Ok, for your PHP code, you have it titled as check3.php, but for your HTML code it's send3.php.
Are both the HTML and PHP code within one page? It really doesn't matter just wondering. Because if you want the HTML to go to the PHP code, that's fine. I'm just confused because it's submitting to send3.php but in the PHP code, you call it check3.php..... Also, which undefined variables is it complaining about? |
I'm really sorry...been a long day. The latest version is check4.php, and the action is to the same...posted older version but the rest of the code is exactly the same.
The errors I am getting... Notice: Undefined index: name in /Applications/MAMP/htdocs/pf5/check4.php on line 77 Notice: Undefined index: company in /Applications/MAMP/htdocs/pf5/check4.php on line 78 Notice: Undefined index: address in /Applications/MAMP/htdocs/pf5/check4.php on line 79 Notice: Undefined index: email in /Applications/MAMP/htdocs/pf5/check4.php on line 80 Notice: Undefined index: phone in /Applications/MAMP/htdocs/pf5/check4.php on line 81 |
Quote:
print out the POST data that's causing the issue and see what we are getting returned from the form.... echo "Name: " . $_POST['name'] . "<br />"; echo "Company: " . $_POST['company'] . "<br />"; echo "Address: " . $_POST['address'] . "<br />"; echo "Email: " . $_POST['email'] . "<br />"; echo "Phone: " . $_POST['phone'] . "<br />"; |
Basically says the same..... Notice: Undefined index: name in /Applications/MAMP/htdocs/pf5/check4.php on line 12
Name: Notice: Undefined index: company in /Applications/MAMP/htdocs/pf5/check4.php on line 14 Company: Notice: Undefined index: address in /Applications/MAMP/htdocs/pf5/check4.php on line 16 Address: Notice: Undefined index: email in /Applications/MAMP/htdocs/pf5/check4.php on line 18 Email: Notice: Undefined index: phone in /Applications/MAMP/htdocs/pf5/check4.php on line 20 Phone: |
Quote:
Unless WH has come up with new methods for accepting data, it's basically just saying that you're not passing any of those variables over to her script... |
Ok so what I don't understand then is why it works when seperate but not when in the same file?
Thanks AWNP for all your time yesterday! :) |
Quote:
Thanks... |
Hey
Here it is all in one chunk... HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
I've got it working.
Test it out on my site, I commented out the part that actually sends the email, but I'm sure that would work... http://www.gatebattle.com/check4.php |
Excellent.... how did u do that? I have been trying it on my site too but not werking :P
|
| All times are GMT. The time now is 11:29 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0