Help with PHP Form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vincenzobar
Forum Commoner
Posts: 95
Joined: Wed Nov 02, 2005 9:57 am

Help with PHP Form

Post 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?
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post 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.
vincenzobar
Forum Commoner
Posts: 95
Joined: Wed Nov 02, 2005 9:57 am

Post 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?
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post 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.
vincenzobar
Forum Commoner
Posts: 95
Joined: Wed Nov 02, 2005 9:57 am

Post 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!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Try not to give in and make a register_globals emulation layer. That only causes more security problems.
Post Reply