Jump to content


Photo

Help sorting out my if{} and else{} statements


  • This topic is locked This topic is locked
18 replies to this topic

#1 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 23 October 2006 - 12:02 AM

I keep getting errors like unexpected T_Else from this script, and i'm not sure how to use case or switch statements with php... can someone please help me sort this error out? thanks in advance.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>GSmash Tournament registration</title>
</head>
<body>
<?php
// Check to make sure that the user isnt spamming people via the form:
function spamcheck($field)
{

	if(eregi("to:",$field) || eregi("cc:",$field)) 
	{
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}
function checkType($type)
{
	if($_REQUEST['type1'] == TRUE AND $_REQUEST['type2'] == FALSE)
	{
		$type = "1";
	}
	else if($_REQUEST['type1'] == FALSE and $REQUEST['type2'] == TRUE)
	{
		$type = "2";
	}
	else
	{
		$type= "3";
	}
	return $type;
	}
	//Make sure the form is filled out:
	if(isset($_REQUEST['email']));
	{
		//check if the email address is invalid
		$mailcheck = spamcheck($_REQUEST['email']);
			if ($mailcheck==TRUE)
			{
				echo "Sorry, the e-mail you have entered is invalid, please re-enter it.";
			}
			else
			{ 
				//send email if the e-mail is valid
				$email = $_REQUEST['email']; 
				$subject = "Smash Entry For: " . $_REQUEST['name'];
				$message = $_REQUEST['sname'] . ", " . $_REQUEST['char'] . ", " . checkType($type);
				mail("Linkmaster424@aol.com", "Subject: $subject",
				$message, "From: $email" );
				echo "Thanks for your entry!Your data will be sent to the tournament staff.";
			}
	} 
	else
	{
		echo "<h1 align='center'>Glenwood SSBM Tournament Form</h1><hr /><br /><h3 align='center'>Fill 		out the form and click the &quot;Send&quot; button.</h3>"
		echo "<form method='post' action='ssbm.php'>
		Email: <input type='text' name='email' /><br />
		Name: <input type='text' name='name' /><br />
		Smash Name: <input type='text' name='sname' max=4 min=1 size=16><br />
		Character: <input type='text' name='char' /><br />
		Entry Type(select at least one):<br />
		One on One:<input type='checkbox' name='type1'><br />
		Teams:<input type='checkbox' name='type2'><br />
		</form>";
		echo "<p><em>Note: In order to join the tournament, you will be required to pay an entry fee 					of &nbsp; &nbsp; $5.00 upon entry. &nbsp;This is mandatory for both teams and singles, meaning that if you are on a team, &nbsp;you AND your partner will need to pay the entry fee, totalling ten dollars. &nbsp;The same goes if you &nbsp;were to enter in both tournaments, you would have to pay a fee of ten dollars(five for each &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tournament).</em></p><br /><p><font size='2'>&copy;2006 By Tristan Nolan.</font></p>"
}
?>
</body>
</html>


#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 23 October 2006 - 12:25 AM

you are missing one closing '}' at teh end of that code (bewteen the echo statement and the '}')
follow me on twitter @PHPsycho

#3 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 23 October 2006 - 12:26 AM

:D
thx, i'll test it out again real fast

#4 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 23 October 2006 - 12:29 AM

still getting this error:

Parse error: syntax error, unexpected T_ELSE in /home/pc72/public_html/smash/Registration.php on line 58



#5 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 23 October 2006 - 12:38 AM

I see the problem...

From the start of the checktype function you have an if statement at the end of whic you have return xxx.  You will note the if statement finishes above the return and there is another closing brace immediately after - this is closing the function code block - decide what shoudl happen there and adjust the script accordingly.
follow me on twitter @PHPsycho

#6 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 23 October 2006 - 12:41 AM

STrike that - just loaded it into my editor - it was just your nesting of code that threw me...

There is a missing ';' at the end of teh last echo line.
follow me on twitter @PHPsycho

#7 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 23 October 2006 - 12:50 AM

fixed the missing ';' and still getting the error, and are you saying that i need to move the return line into the if statement?

#8 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 23 October 2006 - 01:34 AM

try this...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>GSmash Tournament registration</title>
</head>
<body>
<?php
// Check to make sure that the user isnt spamming people via the form:
function spamcheck($field)
{

	if	(
		eregi("to:",	$field)
		||
		eregi("cc:",	$field)
		||
		eregi(";",		$field)
		) 
	{
		return true;
	}
	else
	{
		return false;
	}
}
function checkType($type)
{
	if	(
		$_POST['type1']	==	true
		&&
		$_POST["type2"]	==	false
		)
	{
		$type = 1;
	}
	elseif	(
			$_POST['type1']	==	false
			&&
			$_POST["type2"]	==	true
			)
	{
		$type = 2;
	}
	else
	{
		$type= 3;
	}
	return $type;
}
	//Make sure the form is filled out:
if(isset($_POST['email']));
{
	//check if the email address is invalid
	$mailcheck	=	spamcheck($_POST['email']);
	if	(
		(bool)$mailcheck	==	true)
	{
		echo "Sorry, the e-mail you have entered is invalid, please re-enter it.";
	}
	else
	{ 
		//send email if the e-mail is valid
		$email		=	$_POST['email']; 
		$subject	=	"Smash Entry For: " . $_POST['name'];
		$type		=	checkType();
		$message	=	$_POST['sname'] . ", " . $_POST['char'] . ", " . $type;
		mail("Linkmaster424@aol.com", "Subject: " . $subject, $message, "From: " . $email . "\r\n");
		echo "Thanks for your entry!Your data will be sent to the tournament staff.";
	}
} 
else
{
?>
		<h1 align="center">Glenwood SSBM Tournament Form</h1>
		<hr />
		<br />
		<h3 align="center">Fill out the form and click the &quot;Send&quot; button.</h3>
		<form method="post" action="ssbm.php">
		Email: <input type="text" name="email" /><br />
		Name: <input type="text" name="name" /><br />
		Smash Name: <input type="text" name="sname" max=4 min=1 size=16><br />
		Character: <input type="text" name="char" /><br />
		Entry Type(select at least one):<br />
		One on One:<input type="checkbox" name="type1"><br />
		Teams:<input type="checkbox" name="type2"><br />
		</form>
		<p><em>Note: In order to join the tournament, you will be required to pay an entry fee
		of &nbsp; &nbsp; $5.00 upon entry. &nbsp;This is mandatory for both teams and singles,
		meaning that if you are on a team, &nbsp;you AND your partner will need to pay the entry fee,
		totalling ten dollars. &nbsp;The same goes if you &nbsp;were to enter in both tournaments, you
		would have to pay a fee of ten dollars(five for each tournament).</em></p>
		<br />
		<p><font size="2">&copy;2006 By Tristan Nolan.</font></p>
<?php
}
?>
</body>
</html>


follow me on twitter @PHPsycho

#9 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 23 October 2006 - 01:39 AM

Now I'm getting this error:
Parse error: syntax error, unexpected T_ELSE in /home/pc72/public_html/smash/Test.php on line 73


#10 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 23 October 2006 - 01:44 AM

D'OH

the is an ';' rigth after if(isset($_POST['email'])); !!! I missed that! take it out.

Just looked at your code and spotted something that will save you some headaches...

You have the check type function to check which type was set... but if you look at the logic and your html you will notice that the user coudl check bothboxes or neither which would set type to 3 - be careful with that!!! If you only want them to be able to slect one I suggest you change to radio buttons....
follow me on twitter @PHPsycho

#11 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 23 October 2006 - 01:53 AM

Teh checkboxes are meant to allow them to check both at once, however you pointed out that they can check neither, thanks much, i missed a handler for that situation :-D

Aside from that, I'm now getting this error when I try to run the script:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/pc72/public_html/smash/Test.php on line 52


And here's what my code looks like right now(after all above changes):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>GSmash Tournament registration</title>
</head>
<body>
<?php
// Check to make sure that the user isnt spamming people via the form:
function spamcheck($field)
{

	if	(
		eregi("to:",	$field)
		||
		eregi("cc:",	$field)
		||
		eregi(";",		$field)
		) 
	{
		return true;
	}
	else
	{
		return false;
	}
}
function checkType($type)
{
	if	(
		$_POST['type1']	==	true
		&&
		$_POST["type2"]	==	false
		)
	{
		$type = 1;
	}
	elseif	(
			$_POST['type1']	==	false
			&&
			$_POST["type2"]	==	true
			)
	{
		$type = 2;
	}
                elseif        (
                                                $_POST['type1']        ==            false
                                                &&
                                                $_POST['type2']        ==            false
                               )
                {
                echo "<font color="red">ERROR: You must select a tournament type.</font>"
                }

	else
	{
		$type= 3;
	}
	return $type;
}
	//Make sure the form is filled out:
if(isset($_POST['email']))
{
	//check if the email address is invalid
	$mailcheck	=	spamcheck($_POST['email']);
	if	(
		(bool)$mailcheck	==	true)
	{
		echo "Sorry, the e-mail you have entered is invalid, please re-enter it.";
	}
	else
	{ 
		//send email if the e-mail is valid
		$email		=	$_POST['email']; 
		$subject	=	"Smash Entry For: " . $_POST['name'];
		$type		=	checkType();
		$message	=	$_POST['sname'] . ", " . $_POST['char'] . ", " . $type;
		mail("Linkmaster424@aol.com", "Subject: " . $subject, $message, "From: " . $email . "\r\n");
		echo "Thanks for your entry!Your data will be sent to the tournament staff.";
	}
} 
else
{
?>
		<h1 align="center">Glenwood SSBM Tournament Form</h1>
		<hr />
		<br />
		<h3 align="center">Fill out the form and click the &quot;Send&quot; button.</h3>
		<form method="post" action="ssbm.php">
		Email: <input type="text" name="email" /><br />
		Name: <input type="text" name="name" /><br />
		Smash Name: <input type="text" name="sname" max=4 min=1 size=16><br />
		Character: <input type="text" name="char" /><br />
		Entry Type(select at least one):<br />
		One on One:<input type="checkbox" name="type1"><br />
		Teams:<input type="checkbox" name="type2"><br />
		</form>
		<p><em>Note: In order to join the tournament, you will be required to pay an entry fee
		of &nbsp; &nbsp; $5.00 upon entry. &nbsp;This is mandatory for both teams and singles,
		meaning that if you are on a team, &nbsp;you AND your partner will need to pay the entry fee,
		totalling ten dollars. &nbsp;The same goes if you &nbsp;were to enter in both tournaments, you
		would have to pay a fee of ten dollars(five for each tournament).</em></p>
		<br />
		<p><font size="2">&copy;2006 By Tristan Nolan.</font></p>
<?php
}
?>
</body>
</html>


#12 mikc

mikc
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 23 October 2006 - 11:55 AM

Teh checkboxes are meant to allow them to check both at once, however you pointed out that they can check neither, thanks much, i missed a handler for that situation :-D

Aside from that, I'm now getting this error when I try to run the script:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/pc72/public_html/smash/Test.php on line 52


And here's what my code looks like right now(after all above changes):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>GSmash Tournament registration</title>
</head>
<body>
<?php
// Check to make sure that the user isnt spamming people via the form:
function spamcheck($field)
{

	if	(
		eregi("to:",	$field)
		||
		eregi("cc:",	$field)
		||
		eregi(";",		$field)
		) 
	{
		return true;
	}
	else
	{
		return false;
	}
}
function checkType($type)
{
	if	(
		$_POST['type1']	==	true
		&&
		$_POST["type2"]	==	false
		)
	{
		$type = 1;
	}
	elseif	(
			$_POST['type1']	==	false
			&&
			$_POST["type2"]	==	true
			)
	{
		$type = 2;
	}
                elseif        (
                                                $_POST['type1']        ==            false
                                                &&
                                                $_POST['type2']        ==            false
                               )
                {
                echo "<font color="red">ERROR: You must select a tournament type.</font>"
                }

	else
	{
		$type= 3;
	}
	return $type;
}
	//Make sure the form is filled out:
if(isset($_POST['email']))
{
	//check if the email address is invalid
	$mailcheck	=	spamcheck($_POST['email']);
	if	(
		(bool)$mailcheck	==	true)
	{
		echo "Sorry, the e-mail you have entered is invalid, please re-enter it.";
	}
	else
	{ 
		//send email if the e-mail is valid
		$email		=	$_POST['email']; 
		$subject	=	"Smash Entry For: " . $_POST['name'];
		$type		=	checkType();
		$message	=	$_POST['sname'] . ", " . $_POST['char'] . ", " . $type;
		mail("Linkmaster424@aol.com", "Subject: " . $subject, $message, "From: " . $email . "\r\n");
		echo "Thanks for your entry!Your data will be sent to the tournament staff.";
	}
} 
else
{
?>
		<h1 align="center">Glenwood SSBM Tournament Form</h1>
		<hr />
		<br />
		<h3 align="center">Fill out the form and click the &quot;Send&quot; button.</h3>
		<form method="post" action="ssbm.php">
		Email: <input type="text" name="email" /><br />
		Name: <input type="text" name="name" /><br />
		Smash Name: <input type="text" name="sname" max=4 min=1 size=16><br />
		Character: <input type="text" name="char" /><br />
		Entry Type(select at least one):<br />
		One on One:<input type="checkbox" name="type1"><br />
		Teams:<input type="checkbox" name="type2"><br />
		</form>
		<p><em>Note: In order to join the tournament, you will be required to pay an entry fee
		of &nbsp; &nbsp; $5.00 upon entry. &nbsp;This is mandatory for both teams and singles,
		meaning that if you are on a team, &nbsp;you AND your partner will need to pay the entry fee,
		totalling ten dollars. &nbsp;The same goes if you &nbsp;were to enter in both tournaments, you
		would have to pay a fee of ten dollars(five for each tournament).</em></p>
		<br />
		<p><font size="2">&copy;2006 By Tristan Nolan.</font></p>
<?php
}
?>
</body>
</html>


this should work you forgot a semicolon
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>GSmash Tournament registration</title>
</head>
<body>
<?php
// Check to make sure that the user isnt spamming people via the form:
function spamcheck($field)
{

	if	(
		eregi("to:",	$field)
		||
		eregi("cc:",	$field)
		||
		eregi(";",		$field)
		) 
	{
		return true;
	}
	else
	{
		return false;
	}
}
function checkType($type)
{
	if	(
		$_POST['type1']	==	true
		&&
		$_POST["type2"]	==	false
		)
	{
		$type = 1;
	}
	elseif	(
			$_POST['type1']	==	false
			&&
			$_POST["type2"]	==	true
			)
	{
		$type = 2;
	}
                elseif        (
                                                $_POST['type1']        ==            false
                                                &&
                                                $_POST['type2']        ==            false
                               )
                {
                echo "<font color="red">ERROR: You must select a tournament type.</font>";
                }

	else
	{
		$type= 3;
	}
	return $type;
}
	//Make sure the form is filled out:
if(isset($_POST['email']))
{
	//check if the email address is invalid
	$mailcheck	=	spamcheck($_POST['email']);
	if	(
		(bool)$mailcheck	==	true)
	{
		echo "Sorry, the e-mail you have entered is invalid, please re-enter it.";
	}
	else
	{ 
		//send email if the e-mail is valid
		$email		=	$_POST['email']; 
		$subject	=	"Smash Entry For: " . $_POST['name'];
		$type		=	checkType();
		$message	=	$_POST['sname'] . ", " . $_POST['char'] . ", " . $type;
		mail("Linkmaster424@aol.com", "Subject: " . $subject, $message, "From: " . $email . "\r\n");
		echo "Thanks for your entry!Your data will be sent to the tournament staff.";
	}
} 
else
{
?>
		<h1 align="center">Glenwood SSBM Tournament Form</h1>
		<hr />
		<br />
		<h3 align="center">Fill out the form and click the &quot;Send&quot; button.</h3>
		<form method="post" action="ssbm.php">
		Email: <input type="text" name="email" /><br />
		Name: <input type="text" name="name" /><br />
		Smash Name: <input type="text" name="sname" max=4 min=1 size=16><br />
		Character: <input type="text" name="char" /><br />
		Entry Type(select at least one):<br />
		One on One:<input type="checkbox" name="type1"><br />
		Teams:<input type="checkbox" name="type2"><br />
		</form>
		<p><em>Note: In order to join the tournament, you will be required to pay an entry fee
		of &nbsp; &nbsp; $5.00 upon entry. &nbsp;This is mandatory for both teams and singles,
		meaning that if you are on a team, &nbsp;you AND your partner will need to pay the entry fee,
		totalling ten dollars. &nbsp;The same goes if you &nbsp;were to enter in both tournaments, you
		would have to pay a fee of ten dollars(five for each tournament).</em></p>
		<br />
		<p><font size="2">&copy;2006 By Tristan Nolan.</font></p>
<?php
}
?>
</body>
</html>


#13 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 23 October 2006 - 02:31 PM

Now I've got this error :(
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/pc72/public_html/smash/Test.php on line 52



#14 KevinM1

KevinM1
  • Moderators
  • Snarkimus Prime
  • 5,248 posts

Posted 23 October 2006 - 02:58 PM

The error stems from you using double quotes to both echo output and to set a font color on that line.  If you use double quotes for output, you need to use single quotes for HTML tags that you set properties on within that output.  Try the following and see if it works:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>GSmash Tournament registration</title>
</head>
<body>

<?php
// Check to make sure that the user isnt spamming people via the form:
function spamcheck($field){
   if(eregi("to:", $field) || eregi("cc:", $field) || eregi(";", $field)){
      return true;
   }

   else{
      return false;
   }
}

function checkType($type){
   if($_POST['type1'] == true && $_POST['type2'] == false){
      $type = 1;
   }

   elseif($_POST['type1'] == false && $_POST['type2'] == true){
      $type = 2;
   }

   elseif($_POST['type1'] == false && $_POST['type2'] == false){
      echo "<font color='red'>ERROR: You must select a tournament type.</font>";
   }

   else{
      $type = 3;
   }

return $type;
}

//Make sure the form is filled out:
if(isset($_POST['email'])){
   //check if the email address is invalid
   $mailcheck = spamcheck($_POST['email']);

   if((bool)$mailcheck == true){
      echo "Sorry, the e-mail you have entered is invalid, please re-enter it.";
   }

   else{ 
      //send email if the e-mail is valid
      $email = $_POST['email']; 
      $subject = "Smash Entry For: " . $_POST['name'];
      $type = checkType();
      $message = $_POST['sname'] . ", " . $_POST['char'] . ", " . $type;
      mail("Linkmaster424@aol.com", "Subject: " . $subject, $message, "From: " . $email . "\r\n");
      echo "Thanks for your entry!  Your data will be sent to the tournament staff.";
   }
}
 
else{
?>
   <h1 align="center">Glenwood SSBM Tournament Form</h1>
   <hr />
   <br />
   <h3 align="center">Fill out the form and click the &quot;Send&quot; button.</h3>
   <form method="post" action="ssbm.php">
   Email: <input type="text" name="email" /><br />
   Name: <input type="text" name="name" /><br />
   Smash Name: <input type="text" name="sname" max=4 min=1 size=16><br />
   Character: <input type="text" name="char" /><br />
   Entry Type(select at least one):<br />
   One on One:<input type="checkbox" name="type1"><br />
   Teams:<input type="checkbox" name="type2"><br />
   </form>

   <p><em>Note: In order to join the tournament, you will be required to pay an entry fee
   of $5.00 upon entry. &nbsp;This is mandatory for both teams and singles,
   meaning that if you are on a team, you AND your partner will need to pay the entry fee,
   totalling ten dollars. &nbsp;The same goes if you were to enter in both tournaments, you
   would have to pay a fee of ten dollars(five for each tournament).</em></p>
   <br />

   <p><font size="2">&copy;2006 By Tristan Nolan.</font></p>

<?php
}
?>
</body>
</html>

Using 'global' is a sign of doing it wrong

#15 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 23 October 2006 - 05:00 PM

OMG, IT WORKS!! :D
ty ty ty

#16 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 23 October 2006 - 08:53 PM

wait... not so fast
it loads the page fine, but when i try to submit data through the form, it doesnt email me, but instead displays this message:
[quote]Warning: Missing argument 1 for checktype() in /home/pc72/public_html/smash/Index.php on line 21[/quote

more help needed.. lol

#17 KevinM1

KevinM1
  • Moderators
  • Snarkimus Prime
  • 5,248 posts

Posted 23 October 2006 - 09:14 PM

You have a logic problem.

You originally define the function checkType as one that takes one argument:

<?php
function checkType($type){
   if($_POST['type1'] == true && $_POST['type2'] == false){
      $type = 1;
   }

   elseif($_POST['type1'] == false && $_POST['type2'] == true){
      $type = 2;
   }

   elseif($_POST['type1'] == false && $_POST['type2'] == false){
      echo "<font color='red'>ERROR: You must select a tournament type.</font>";
   }

   else{
      $type = 3;
   }

return $type;
}
?>

But when you use it, you don't pass it an argument (line 54):
<?php
$type = checkType();
?>

With the way you have your function defined, you don't really use the argument to pass to it, so try using:
<?php
function checkType(){
   if($_POST['type1'] == true && $_POST['type2'] == false){
      $type = 1;
   }

   elseif($_POST['type1'] == false && $_POST['type2'] == true){
      $type = 2;
   }

   elseif($_POST['type1'] == false && $_POST['type2'] == false){
      echo "<font color='red'>ERROR: You must select a tournament type.</font>";
   }

   else{
      $type = 3;
   }

return $type;
}
?>

Using 'global' is a sign of doing it wrong

#18 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 24 October 2006 - 12:31 AM

:D I think you nailed it

However, it's not e-mailing it to me when i submit the form, no error being displayed, but yeah.

also, what code would I use to make a back button appear on the page after a successful registration occurs?

#19 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 24 October 2006 - 08:48 PM

still not mailing the info, can someone plz help?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users