TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-13-2009, 03:40 PM   #21 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by Guezala View Post
Excellent.... how did u do that? I have been trying it on my site too but not werking :P
The reason it was working when broken into 2 pages is that the PHP side of it is kicking in before your HTML side. So when it was broken up to the 2nd page, you didn't see this part since the only time you would post to it, was when you wanted it to execute.

I added a name to your button so we can look for it later in the code so change to this:

Code:
<input type="submit" name="submit" value="Send Questionnaire!"/>


Then somewhere around line 150-160, you have the actual part of the PHP code that calls the function. You need to change it to this. This will check that the button has been clicked.

Code:
if($_POST['submit']) {
$aValidatedForm = valid_form($aVariables);
		  }
I also removed the check for phone syntax because it was causing too many problems, so use this new array.


Code:
$aValidationRules 	= array('name' => '[A-Za-z0-9\.|-|_/i]{2,20}', 
						     'company' => '[A-Za-z0-9\.|-|_/i]{3,30}', 
							 'address' => '[A-Za-z0-9\.|-|_/i]{3,50}', 
							   'email' => '[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,5})');


The problem is that you don't indicate to the end user what format the phone# needs to be in, so I was trying it 3-4 different ways and it still came back as bad form. So I just took it out.


Oh and one more thing, look for this code because I commented it out too...just make sure you comment it out on your end.


Code:
#echo 'Oops: ' . $aValidatedForm['message'];
allworknoplay is offline  
Reply With Quote
Old 05-13-2009, 04:29 PM   #22 (permalink)
The Contributor
 
Guezala's Avatar
 
Join Date: May 2009
Location: West Midlands
Posts: 26
Thanks: 2
Guezala is on a distinguished road
Default

I have been advised to try removing the action ref which has cleared the index errors but the form is still being validated before it has been filled out....(on my site)
Send a message via MSN to Guezala Send a message via Skype™ to Guezala
Guezala is offline  
Reply With Quote
Old 05-13-2009, 04:34 PM   #23 (permalink)
The Contributor
 
Guezala's Avatar
 
Join Date: May 2009
Location: West Midlands
Posts: 26
Thanks: 2
Guezala is on a distinguished road
Default

Thanks - must have crossed paths.... will look into that now. I still have some more validation to add but will post to let you know how i have got on. i really appreciate your help. I understand chunks of php but am really struggling to stick it all together in a functional way.

Yes I am going to refine my form and state what format the number etc. should be in. Are you in the uk? If not maybe that's why...
Send a message via MSN to Guezala Send a message via Skype™ to Guezala
Guezala is offline  
Reply With Quote
Old 05-13-2009, 04:37 PM   #24 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by Guezala View Post
Thanks - must have crossed paths.... will look into that now. I still have some more validation to add but will post to let you know how i have got on. i really appreciate your help. I understand chunks of php but am really struggling to stick it all together in a functional way.

Don't worry I'm the same way. I've been on a 3-4 month crusade to tackle all the little nuances of PHP that I've managed to overlook the last 8 years or so of PHP programming...

It just takes time....
allworknoplay is offline  
Reply With Quote
Old 05-13-2009, 05:04 PM   #25 (permalink)
The Contributor
 
Guezala's Avatar
 
Join Date: May 2009
Location: West Midlands
Posts: 26
Thanks: 2
Guezala is on a distinguished road
Default

Hey! The good news is it works - YEY!!!! I could kiss you all over :)

I think that some of the errors must simply be related to testing locally.. is this likely?

I will add some more validation and refine my form now lmao... never ending. I owe you a biggie. And WildHoney for starting me off on the right path... thanks guys. I hope I can become a useful member here one day too :D
Send a message via MSN to Guezala Send a message via Skype™ to Guezala
Guezala is offline  
Reply With Quote
Old 05-13-2009, 05:11 PM   #26 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by Guezala View Post
Hey! The good news is it works - YEY!!!! I could kiss you all over :)

I think that some of the errors must simply be related to testing locally.. is this likely?

I will add some more validation and refine my form now lmao... never ending. I owe you a biggie. And WildHoney for starting me off on the right path... thanks guys. I hope I can become a useful member here one day too :D
Good job! I don't think it was any issue with local testing because I ran into the same issues you did until I made some changes to prevent execution of the PHP code before the HTML....


Also, if I could make a suggestion, look into using $_SESSION variables instead of $_POST variables. Once you get your form working, I would tinker around with it using sessions.

Because this way, if the user makes a mistake, the session will hold the original data that the user typed in so they don't have to start all over from scratch....

Then after the mail function, you can destroy all the sessions....
allworknoplay is offline  
Reply With Quote
Old 05-13-2009, 07:57 PM   #27 (permalink)
The Contributor
 
Guezala's Avatar
 
Join Date: May 2009
Location: West Midlands
Posts: 26
Thanks: 2
Guezala is on a distinguished road
Default

Cool...yes I have heard of sessions but avoided it cos i was in such a pickle with what i had done so far! Sounds just the thing cos I was going to look into making the form "sticky" ... is that a completely different concept?

So much to ask :) hehe.
Send a message via MSN to Guezala Send a message via Skype™ to Guezala
Guezala is offline  
Reply With Quote
Old 05-13-2009, 08:28 PM   #28 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by Guezala View Post
Cool...yes I have heard of sessions but avoided it cos i was in such a pickle with what i had done so far! Sounds just the thing cos I was going to look into making the form "sticky" ... is that a completely different concept?

So much to ask :) hehe.
Yeah, it's the same thing, sessions will do the trick. Otherwise, you'd have to go out of your way to repopulate all the fields with your POST variables, it makes no sense and is just extra coding for nothing....
allworknoplay is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form to submit to another form patmagpantay General 8 07-21-2008 07:42 AM
Form validation with Regex [Prototype] Haris Javascript, AJAX, E4X 7 12-08-2007 10:49 AM
Form validation Tanax Javascript, AJAX, E4X 3 09-28-2007 08:45 AM
Form validation help 3gg1 General 0 10-06-2006 03:16 PM
Form Processing William Tips & Tricks 8 04-17-2005 03:24 PM


All times are GMT. The time now is 10:52 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design