Noob question - Not sure why this doesnt work!

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
phear
New php-forum User
New php-forum User
Posts: 7
Joined: Wed Apr 17, 2013 8:31 am

Noob question - Not sure why this doesnt work!

Post by phear » Wed Apr 17, 2013 8:37 am

Code: Select all

<?php
if ((!isset($_POST['searchsubmit'])) && (!isset($POST['enrollsubmit']))) {
echo "Error - Form Not Submitted";
}
elseif  ((isset($_POST['searchsubmit'])) && (!isset($POST['enrollsubmit']))){
	echo "Search Submitted";
	}
elseif  ((isset($_POST['enrollsubmit'])) && (!isset($POST['searchsubmit']))){
	echo "Enrollment Submitted";
	}
else {
	echo "Unknown Error!";
	}
?>
If i load this script without clicking through one of the buttons on my form, i get the 'Error - form not submitted'
If i click the 'searchsubmit' button i get the correct read out.
If i click the 'enrollsubmit' button i get 'Error - Form Not Submitted'

Why does this not work? been sat scrathing my head for a while now.

phear
New php-forum User
New php-forum User
Posts: 7
Joined: Wed Apr 17, 2013 8:31 am

Re: Noob question - Not sure why this doesnt work!

Post by phear » Wed Apr 17, 2013 8:42 am

Wait wait wait.... one second....

I figured it out, i forgot the underscore. Rookie error. BUT.... still that doesnt explain it?

Code: Select all

elseif  ((isset($_POST['enrollsubmit'])) && (!isset($POST['searchsubmit']))){
	echo "Enrollment Submitted";
	}
that should work... $_POST['Enrollsubmit'] has been set to true and $POST['searchsubmit'] is set to false because it doesnt exist?

Im not sure why that didnt 'just work' anyway?

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Re: Noob question - Not sure why this doesnt work!

Post by seandisanti » Wed Apr 17, 2013 2:06 pm

It's easier to help diagnose form issues when you show the code for the form so we have some idea what you're talking about.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest