NuckingFuts
IS-IT--Management
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] == "" )
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] == "" )
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] == "" && $submit[5] == ""
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] != "" && $submit[1] != "" && $submit[5] != "" && $submit[6] != ""
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]."\t".$date."\t".$submit[0]."\t".$submit[1]."\t"
.$submit[2]."\t".$submit[3]."\t".$submit[4]."\t".$submit[5]."\n";
// open file for appending
$fp = fopen("$DOCUMENT_ROOT/falcon/names.txt", '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!
<?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] == "" )
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] == "" )
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] == "" && $submit[5] == ""

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] != "" && $submit[1] != "" && $submit[5] != "" && $submit[6] != ""

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]."\t".$date."\t".$submit[0]."\t".$submit[1]."\t"
.$submit[2]."\t".$submit[3]."\t".$submit[4]."\t".$submit[5]."\n";
// open file for appending
$fp = fopen("$DOCUMENT_ROOT/falcon/names.txt", '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!