Page 1 of 1

Help with PHP Form

Posted: Wed Dec 21, 2005 9:35 am
by vincenzobar
I have a form and code that calls errors to the same page but i can not figure out how to get it to show

how do i write the action to refresh with the errors or continue. I tried this with no luck

Code: Select all

if (empty($form_data['date_start'])) $form_data['date_start'] = date("m/d/Y");
		
		return '<form method="post" action="'.$_POST['PHP_SELF'].'">
					<b>Target URL</b><br />
I have 2 buttons preview and submit both named submit but values are there title.

then i have

Code: Select all

if (!empty($submit)) {
		
		###
		# If the user has selected to preview their ad.
		###
		if ($submit == 'Preview') {
and

Code: Select all

elseif ($submit == 'Submit') {
I am at a loss any one know?

Posted: Wed Dec 21, 2005 10:27 am
by jayshields
I don't really understand what your problem is, but you have some blatant errors in your code.

Set error repoting to E_ALL first off, so PHP can tell you what's going wrong.

Some things wrong with your code are unclosed curly braces, unclosed quotation marks, etc.

When you turn error repoting on in your script PHP should point you in the right direction to fixing your code.

Good luck.

Posted: Wed Dec 21, 2005 1:29 pm
by vincenzobar
I just gave you snippets of the code the code is actually like 200 lines long.

I was just showing the opening that the form should call to generate the correct page.

what fould go in the Form tag if action = Preview or Submit or Error?

Posted: Wed Dec 21, 2005 2:00 pm
by jayshields
I still don't understand you. Since you haven't actually posted your full script, I'm presuming the same script shows a HTML form, and processes the data. In this situation you would always set the form action to the same page you are submitting from. You can do it like you have done it, or hard code it. Either way it's the same.

If you script isn't working properly and you are actually wanting the form to be submitted to itself then the form tag isn't going to be the cause of your error.

Posted: Wed Dec 21, 2005 2:20 pm
by vincenzobar
That is what i thought!!! Thanks a bunch the code is screwey, a friend wrote it and it worked on his site but i guess i have to write my own for mine. oh well!


Thanks a bunch!

Posted: Wed Dec 21, 2005 4:32 pm
by John Cartwright
Looks to me like your friend codes with register_globals set to ON, which is bad, bad, bad. Luckily, your server appears to have it disabled. Try changing the instances of your form variables, such as $submit to $_POST['submit'].. and it should work.

Posted: Wed Dec 21, 2005 4:50 pm
by Ambush Commander
Try not to give in and make a register_globals emulation layer. That only causes more security problems.