Forum Moderators: coopster

Message Too Old, No Replies

Can you see the error?

         

Dexie

9:09 am on Dec 30, 2005 (gmt 0)

10+ Year Member


Hi all, Bit of a newbie to PHP, but an struggling along. I've got together the code below for a form, but am getting a parsing error when trying to view it on the net.

Parse error: parse error, unexpected T_BOOLEAN_OR in /home/practice/public_html/291205/index.php on line 54

Any help very much appreciated.

Dexie.

<? ob_start();?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<?

function numberOfIntegers($String)
{

$x=0;
$numOfInts=0;

while ($x < strlen($String))
{

if (is_numeric($String{$x}))
{
$numOfInts++;
}
$x++;

}

return $numOfInts;

}

?>
<HTML>
<HEAD>
<TITLE>Form processing with PHP</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">

<?

// Check to see if the form has been submitted
if ($_GET["submit"])
{

// Assign 0 to the error variable
$Error = 0;

// Let's extract the GET form field elements
extract($_GET);

$ValidEmail = substr_count($email, '@');
$ValidEmail1 = substr_count($email, '.');

// Now, we'll check to see if ANY of the form elements are blank
if (!($name) ¦¦!($email) ¦¦!($phone) ¦¦!($day_in) ¦¦!($month_and_year_in) ¦¦!($day_out) ¦¦!($month_and_year_out)
¦¦ ($ValidEmail < 1) ¦¦ ($ValidEmail1 < 1) ¦¦ (numberOfIntegers($phone)) < 6) ¦¦!($number_of_people))
{
// at least one of the form fields are blank
if (!($day_in))
{
$Error = 1;
$ErrorDay_in = 1;
}

if (!($month_and_year_in))
{
$Error = 1;
$ErrorMonth_and_year_in = 1;
}

if (!($day_out))
{
$Error = 1;
$ErrorDay_out = 1;
}

if (!($month_and_year_out))
{
$Error = 1;
$ErrorMonth_and_year_out = 1;
}

if (!($name))
{
$Error = 1;
$ErrorName = 1;
}

if (!($phone))
{
$Error = 1;
$ErrorPhone = 1;
}

if (!($email))
{
$Error = 1;
$ErrorEmail = 1;
}

if (!($number_of_people))
{
$Error = 1;
$ErrorNumber_of_people = 1;
}

} else {

// all the form fields are filled in with data

// email the data to YOUR email address
$To = "emailaddress@domain.com";
$Subject = "Form submission";
$Message = "Name: $name \nEmail: $email \nPhone: $phone \nDay_in: $day_in \nMonth_and_year_in: $month_and_year_in \nDay_out: $day_out \nMonth_and_year_out: $Month_and_year_out \nComments: $comments";
mail($To, $Subject, $Message, "From: $email"[smilestopper]);

// email a copy of this message to the USER'S email address
$replyTo = $email;
$replySubject = "Form submission";
$replyMessage = "Your submission: \n\nName: $name \nEmail: $email \nPhone: $phone \nDay_in: $day_in \nMonth_and_year_in: $month_and_year_in \nDay_out: $day_out \nMonth_and_year_out: $Month_and_year_out \nComments: $comments";
mail($replyTo, $replySubject, $replyComments, "From: $To"[smilestopper]);

// redirect to the thank you page
header("Location: http://www.domain.com/291205/thanks.php"[smilestopper]);

}

}
?>

<? if ($Error > 0)
{
// Instruct the user that an error is present
echo "<strong>Oops, you did not fill out all required fields. Those fields are marked below.</strong> <br />";
} elseif ((($ValidEmail < 1) ¦¦ ($ValidEmail1 < 1)) && ($_GET["submit"])) {
echo "<strong>Oops, you did not provide a valid email address. Please try again.</strong> <br />";
$highlightEmail = 1;
} elseif ((numberOfIntegers($phone) < 6) && ($_GET["submit"])) {

echo "<strong>Oops, you did not provide a valid telephone number. Please ensure that your phone ";
echo "number contains AT LEAST 6 NUMBERS and submit the form again.</strong> <br />";
$highlightPhone = 1;
}
?>

<form action="index.php" method="GET">
<table width="100%">
<tr>
<td align="left" width="30%">
<? if (($Error == 1) && ($ErrorDay_in == 1)) { echo "<font color=\"Red\">* </font>"; }?>
<? if (($Error == 1) && ($ErrorMonth_and_year_in == 1)) { echo "<font color=\"Red\">* </font>"; }?>Date in:
</td>
<td align="left" width="68%" valign="bottom">
<SELECT style="maintext" name="Day_in" onchange="Form1.Month_and_year_in.focus()">
<OPTION selected></OPTION> <OPTION>1</OPTION> <OPTION>2</OPTION> <OPTION>3</OPTION> <OPTION>4</OPTION> <OPTION>5</OPTION>
<OPTION>6</OPTION> <OPTION>7</OPTION> <OPTION>8</OPTION> <OPTION>9</OPTION>
<OPTION>10</OPTION> <OPTION>11</OPTION> <OPTION>12</OPTION> <OPTION>13</OPTION>
<OPTION>14</OPTION> <OPTION>15</OPTION> <OPTION>16</OPTION> <OPTION>17</OPTION>
<OPTION>18</OPTION> <OPTION>19</OPTION> <OPTION>20</OPTION> <OPTION>21</OPTION>
<OPTION>22</OPTION> <OPTION>23</OPTION> <OPTION>24</OPTION> <OPTION>25</OPTION>
<OPTION>26</OPTION> <OPTION>27</OPTION> <OPTION>28</OPTION> <OPTION>29</OPTION>
<OPTION>30</OPTION> <OPTION>31</OPTION></SELECT>&nbsp;
<SELECT style="maintext" name="Month_and_year_in" onchange="Form1.Day_out.focus()">
<OPTION selected></OPTION> <OPTION>December 2005</OPTION>
<OPTION>January 2006</OPTION>
<OPTION>February 2006</OPTION> <OPTION>March 2006</OPTION>
<OPTION>April 2006</OPTION> <OPTION>May 2006</OPTION>
<OPTION>June 2006</OPTION> <OPTION>July 2006</OPTION>
<OPTION>August 2006</OPTION> <OPTION>September 2006</OPTION>
<OPTION>October 2006</OPTION> <OPTION>November 2006</OPTION>
</SELECT></td></tr>
<tr>
<td align="left" width="30%">
<? if (($Error == 1) && ($ErrorDay_out == 1)) { echo "<font color=\"Red\">* </font>"; }?>
<? if (($Error == 1) && ($ErrorMonth_and_year_out == 1)) { echo "<font color=\"Red\">* </font>"; }?>Date out:</td>
<td align="left" width="68%" valign="bottom">
<SELECT style="maintext" name="Day_out" onchange="Form1.Month_and_year_out.focus()">
<OPTION selected></OPTION> <OPTION>1</OPTION>
<OPTION>2</OPTION> <OPTION>3</OPTION> <OPTION>4</OPTION> <OPTION>5</OPTION> <OPTION>6</OPTION>
<OPTION>7</OPTION> <OPTION>8</OPTION> <OPTION>9</OPTION> <OPTION>10</OPTION>
<OPTION>11</OPTION> <OPTION>12</OPTION> <OPTION>13</OPTION> <OPTION>14</OPTION>
<OPTION>15</OPTION> <OPTION>16</OPTION> <OPTION>17</OPTION> <OPTION>18</OPTION>
<OPTION>19</OPTION> <OPTION>20</OPTION> <OPTION>21</OPTION> <OPTION>22</OPTION>
<OPTION>23</OPTION> <OPTION>24</OPTION> <OPTION>25</OPTION> <OPTION>26</OPTION>
<OPTION>27</OPTION> <OPTION>28</OPTION> <OPTION>29</OPTION>
<OPTION>30</OPTION> <OPTION>31</OPTION></SELECT>&nbsp;
<SELECT style="maintext" name="Month_and_year_out" onchange="Form1.Name.focus()">
<OPTION selected></OPTION> <OPTION>December 2005</OPTION>
<OPTION>January 2006</OPTION>
<OPTION>February 2006</OPTION> <OPTION>March 2006</OPTION>
<OPTION>April 2006</OPTION> <OPTION>May 2006</OPTION>
<OPTION>June 2006</OPTION> <OPTION>July 2006</OPTION>
<OPTION>August 2006</OPTION> <OPTION>September 2006</OPTION>
<OPTION>October 2006</OPTION> <OPTION>November 2006</OPTION>
</SELECT>
</td></tr>
<tr>
<td align="left" width="30%">
<? if (($Error == 1) && ($ErrorName == 1)) { echo "<font color=\"Red\">* </font>"; }?>Name:
</td>
<td align="left" width="68%" valign="bottom"><input type="text" name="name" size="26" value="<? echo $name;?>">
</td></tr>
<tr><td align="left" width="30%">
<? if (($Error == 1) && ($ErrorPhone == 1)) { echo "<font color=\"Red\">* </font>"; }?>Telephone number:
</td>
<td align="left" width="68%"><input type="text" name="phone" size="26" value="<? echo $phone;?>">
</td></tr>
<tr><td align="left" width="30%">
<? if (($Error == 1) && ($ErrorEmail == 1) ¦¦ ($highlightEmail == 1)) { echo "<font color=\"Red\">* </font>"; }?>Email address:
</td>
<td align="left" width="68%"><input type="text" name="email" size="26" value="<? echo $email;?>">
</td></tr>
<tr><td align="left" width="30%">
<? if (($Error == 1) && ($ErrorNumber_of_people == 1)) { echo "<font color=\"Red\">* </font>"; }?>Number of people:
</td>
<td align="left" width="68%" valign="bottom"><SELECT style="maintext" name="Number_of_people" onchange="Form1.send.focus()">
<OPTION selected> </OPTION>
<OPTION>1</OPTION> <OPTION>2</OPTION><OPTION>3</OPTION>
<OPTION>4</OPTION> <OPTION>5</OPTION> <OPTION>6</OPTION>
</td></tr>
<tr><td align="left" width="30%" valign="top">
Comments:</td>
<td align="left" width="68%">
<p align="left"><textarea cols="30" rows="5" name="comments"></textarea></p>
</td>
</tr>
<tr><td align="center" width="98%" valign="top" colspan="2">
<p><input type="submit" name="submit" value="Send Mail">&nbsp;&nbsp;
<input type="reset" value="Reset">
</td>
</tr>
</table>
</form>

</BODY>
</HTML>
<? ob_flush();?>[/QUOTE]

inbound

6:52 am on Jan 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



¦¦ (numberOfIntegers($phone)) < 6) ¦¦!

There's a problem with the parenthesis (brackets), in that section.

That could be it.

Sorry about the time to answer, I occassionally look at the unanswered questions page, hence I spotted your query.

Dexie

7:16 am on Jan 3, 2006 (gmt 0)

10+ Year Member



Many thanks for that, you solved the problem.

Much appreciated.