Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse error with elseif statements...

Status
Not open for further replies.

NuckingFuts

IS-IT--Management
Joined
Jun 5, 2003
Messages
2
Location
US
K, I've got a fairly simple HTML form set up as a contest entry form. It stores it's output in a flat-file and this script processes the entry and displays it on the screen. I've been working on building some error-checking, so we can alert the person if they don't fill in certain fields. The first "if" statement works by itself, but when I implemented the "elseif" statements I keep getting a "Parse error: parse error, unexpected T_ELSEIF in /pathtoscript/filename.php on line 28" in the browser. Can anyone see what's wrong with this picture?


<?php
//create short variable names
$submit[0] = $HTTP_POST_VARS['name'];
$submit[1] = $HTTP_POST_VARS['address'];
$submit[2] = $HTTP_POST_VARS['city'];
$submit[3] = $HTTP_POST_VARS['state'];
$submit[4] = $HTTP_POST_VARS['zip'];
$submit[5] = $HTTP_POST_VARS['phone'];
$submit[6] = $HTTP_POST_VARS['birdname'];

$DOCUMENT_ROOT = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
?>
<html>
<head>
<title>Help Name Fargo's Falcons</title>
</head>
<body>
<h1>Thank you for participating in our contest!</h1>
<?php
$date = date('H:i, jS F');


if( $submit[6] == &quot;&quot; )

echo '<h3>You did not suggest a bird name.</h3>';
echo '<h3>Please click the <strong>BACK</strong> button to enter a bird name.</h3>';

elseif( $submit[0] == &quot;&quot; )
echo '<h3>You did not enter your name.</h3>';
echo '<h3>Please click the <strong>BACK</strong> button to enter a bird name.</h3>';

elseif($submit[1] == &quot;&quot; && $submit[5] == &quot;&quot;)
echo '<h3>We need you to enter your contact information, so we may contact you if you win.</h3>';
echo '<h3>Please click your <strong>BACK</strong> button to enter your contact information.</h3>';

elseif($submit[0] != &quot;&quot; && $submit[1] != &quot;&quot; && $submit[5] != &quot;&quot; && $submit[6] != &quot;&quot;)

echo '<p>Name submitted at ';
echo $date;
echo '<br />';
echo '<p>You submitted the following information:';
echo '<br />';
echo '<strong>Your Name:</strong> '.$submit[0].' <br />';
echo '<strong>Address:</strong> '. $submit[1].' <br />';
echo '<strong>City:</strong> '.$submit[2].' <br />';
echo '<strong>State:</strong> '.$submit[3].' <br />';
echo '<strong>Zip/Postal Code:</strong> '.$submit[4].' <br />';
echo '<strong>Phone Number:</strong> '.$submit[5].' <br />';
echo '<strong>Suggested Bird Name:</strong> '.$submit[6].' <br />';

$outputstring = $submit[6].&quot;\t&quot;.$date.&quot;\t&quot;.$submit[0].&quot;\t&quot;.$submit[1].&quot;\t&quot;
.$submit[2].&quot;\t&quot;.$submit[3].&quot;\t&quot;.$submit[4].&quot;\t&quot;.$submit[5].&quot;\n&quot;;

// open file for appending
$fp = fopen(&quot;$DOCUMENT_ROOT/falcon/names.txt&quot;, 'a');

flock($fp, LOCK_EX);

if (!$fp)
{
echo '<p><strong> Your submission could not be processed at this time. '
.'Please try again later.</strong></p></body></html>';
exit;
}

fwrite($fp, $outputstring);
flock($fp, LOCK_UN);
fclose($fp);

echo '<p><strong>Thank you for your submission!</strong></p>';

?>

</body>
</html>


Thanks in advance for the help!
 
K, I'm an idiot. I'm missing my { } in the if/elseif statements. Popped those in and it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top