hey folks,
im trying to write a mailing list singup form with two required fields "email" and "zipcode". however, to make sure that they are not entered in as blank i figured i would write an if statement to determine whether or not there is a value for each field, this is what ive got:
the problem is that im getting a parse error "syntax error, unexpected T_STRING, expecting ',' or ';' ... on line 16." im not sure where the problem is, but i imagine it has to do with all of those echos
is there a better way to redisplay the form if a field is empty? i.e. instead of using all of those echo echo echo echo...?
thanks.
im trying to write a mailing list singup form with two required fields "email" and "zipcode". however, to make sure that they are not entered in as blank i figured i would write an if statement to determine whether or not there is a value for each field, this is what ive got:
PHP:
//...
if ($register=='yes')
{
if (!isset($_POST['email']) || empty($_POST['email']))
{
echo "<table id="mailing_list_form" width=250><tr><td><fieldset><legend><b>Mailing List!</b></legend>"; //line 16
echo "<form action='http://www.#.net/mailinglist/verify.php?register=yes' method=POST>";
echo "<table><tr><td><label>e-mail:</td><td><input type=text name='email' size=20 maxlength=40 value="$email"></label><span class=error>**email is a required field</span></td></tr>";
echo "<tr><td><label>zipcode:</td><td><input type=text name='zipcode' size=5 maxlength=5 value="$zipcode"></label></td></tr>";
echo "<tr><td><input type="submit" value="register"></td></tr></table>";
echo "</form></fieldset></td></tr></table>";
}
if (!isset($_POST['zipcode']) || empty($_POST['zipcode']))
{
echo "<table id="mailing_list_form" width=250><tr><td><fieldset><legend><b>Mailing List!</b></legend>";
echo "<form action='http://www.#.net/mailinglist/verify.php?register=yes' method=POST>";
echo "<table><tr><td><label>e-mail:</td><td><input type=text name='email' size=20 maxlength=40 value="$email"></label></td></tr>";
echo "<tr><td><label>zipcode:</td><td><input type=text name='zipcode' size=5 maxlength=5 value="$zipcode"></label><span class=error>**zipcode is a required field</span></td></tr>";
echo "<tr><td><input type="submit" value="register"></td></tr></table>";
echo "</form></fieldset></td></tr></table>";
}
$query="INSERT INTO mailing_list (id,email,zipcode,regdate) VALUES (NULL , '$email', '$zipcode', '$date')";
mysql_query($query) or die('<p>Error, insert query failed</p>');
mysql_close($con);
echo "<p>Thank you for registering!</p>";
the problem is that im getting a parse error "syntax error, unexpected T_STRING, expecting ',' or ';' ... on line 16." im not sure where the problem is, but i imagine it has to do with all of those echos
is there a better way to redisplay the form if a field is empty? i.e. instead of using all of those echo echo echo echo...?
thanks.