knowj
03-07-2006, 08:45 AM
i managed to get it to compile using .$cli_name['title']. but i got a sql error about there not being enough values or something.
also i dont know if its bypassing the isset on the address as it seems to go through still.
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/mediatec/public_html/jrknowles/dow/assignment1/includes/register.php on line 69
<?
//registration form and script
//data on the web assignment 1
//john knowles 053934031
//email validation script
/*function validate_email() {
return (ereg("^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'. '@'. '{-
!#$%&\'+\\/0-9=?A-Z^_`a-z{|}~]+\.' . '[-!#$%&\'*+\\./0-9=?A-
Z^_`a-z{|}~]+$'", $cli_email));
}*/
// the full name of the client: title, First Name, Last Name
$cli_name = array(
"title" => $_POST['title'],
"fname" => $_POST['fname'],
"lname" => $_POST['lname']
);
// the email of the client
$cli_email = $_POST['email'];
//reentered email
$cli_reemail = $_POST['reemail'];
// the address of the client: House Number, Street Name, City, County, Postcode, Country
$cli_address = array(
"houseno" => $_POST['houseno'],
"street" => $_POST['street'],
"city" => $_POST['city'],
"county" => $_POST['county'],
"postcode" => $_POST['postcode'],
"country" => $_POST['country']
);
// check if the form has been submitted
if ($_POST['action'] == 'submitted')
{
if (preg_match('/[^a-z]/i', $cli_name['title'] . $cli_name['fname'] . $cli_name['lname']))
{
//echo that the form contains invalid characters
echo "Some of the form contains invalid characters please remove them";
die;
}
//check all the name sections are filled
if (!isset($cli_name['title'], $cli_name['fname'], $cli_name['lname']))
{
//echo that the client didnt fill in some of the fields in the name section
echo "<h1>You missed some fields which need to be filed in in the names section</h1>";
//end the script
die;
}
//check if the email entered contains an @ and that the 2 email addresses match
/*if (!validate_email($cli_email) && (!$cli_email == $cli_reemail));
{
//echo that the client didnt fill in a valid email address
echo "<h1>You didnt enter a valid email address or the email addresses didn't match</h1>";
//end the script
die;
}*/
//check if the address fields have been filled
if (isset($cli_address['houseno'], $cli_address['street'], $cli_address['city'], $cli_address['county'], $cli_address['postcode'], $cli_address['country']))
{
$cli_address['postcode'] = ereg_replace(" ", "", $cli_address['postcode']);
if (strlen($cli_address['postcode']) == 6 || 7)
{
$query = "INSERT INTO `assi1` (title , first_name, last_name, email, house_number,
street, city, county, postcode, country) VALUES (`$cli_name['title']`, `$cli_name['fname']`,
`$cli_name['lname']`, `$cli_email`, `$cli_address['houseno']`, `$cli_address['street']`,
`$cli_address['city']`, `$cli_address['county']`, `$cli_address['postcode']`, `$cli_address['country']`)";
mysql_query($query) or die(mysql_error());
echo "<h1>Thank you for registering with Blake and the Tyger</h1>";
}
}
else
//echo the input form for registration
{
?>
<h1>Registration:</h1>
Please register to Blake and the Tyger Online using the form below.
<form name="form" method="post" action="?id=2" onsubmit="return validate(this)">
<fieldset>
<legend>Title</legend>
<label>Mr</label>
<input name="title" type="radio" value="Mr">
<label>Mrs</label>
<input name="title" type="radio" value="Mrs">
<label>Miss</label>
<input name="title" type="radio" value="Miss">
<label>Ms</label>
<input name="title" type="radio" value="Ms">
<label>Other</label>
<input name="title" type="radio" value="Other">
</fieldset>
<fieldset>
<legend>Names</legend>
<label for="fname">First Name:</label><br>
<input type="text" name="fname" size="50" id="fname">
<br>
<label for="lname">Last Name:</label><br>
<input type="text" name="lname" size="50" id="lname">
</fieldset>
<fieldset>
<legend>Email Address</legend>
<label>Email:</label><br>
<input type="text" name="email" size="50" id="email">
<br>
<label>Retype Email:</label><br>
<input type="text" name="reemail" size="50" id="remail">
</fieldset>
<fieldset>
<legend>Home Address</legend>
<label>House Number/Name:</label><br>
<input type="text" name="houseno" size="50"><br>
<label>Street Name:</label><br>
<input type="text" name="street" size="50"><br>
<label>City/Town:</label><br>
<input type="text" name="city" size="50"><br>
<label>County:</label><br>
<input type="text" name="county" size="50"><br>
<label>Postcode:</label><br>
<input type="text" name="postcode"><br>
<label>Country:</label><br>
<input type="text" name="country">
</fieldset>
<p><input type="hidden" name="action" value="submitted"><br><input type="submit" name="Submit" value="Submit" class="float-right" style="font-size:1em;">
<input type="reset" name="Reset" value="Clear" class="float-right" style="font-size:1em;"></p>
</form>
<?
}
?>
also i dont know if its bypassing the isset on the address as it seems to go through still.
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/mediatec/public_html/jrknowles/dow/assignment1/includes/register.php on line 69
<?
//registration form and script
//data on the web assignment 1
//john knowles 053934031
//email validation script
/*function validate_email() {
return (ereg("^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'. '@'. '{-
!#$%&\'+\\/0-9=?A-Z^_`a-z{|}~]+\.' . '[-!#$%&\'*+\\./0-9=?A-
Z^_`a-z{|}~]+$'", $cli_email));
}*/
// the full name of the client: title, First Name, Last Name
$cli_name = array(
"title" => $_POST['title'],
"fname" => $_POST['fname'],
"lname" => $_POST['lname']
);
// the email of the client
$cli_email = $_POST['email'];
//reentered email
$cli_reemail = $_POST['reemail'];
// the address of the client: House Number, Street Name, City, County, Postcode, Country
$cli_address = array(
"houseno" => $_POST['houseno'],
"street" => $_POST['street'],
"city" => $_POST['city'],
"county" => $_POST['county'],
"postcode" => $_POST['postcode'],
"country" => $_POST['country']
);
// check if the form has been submitted
if ($_POST['action'] == 'submitted')
{
if (preg_match('/[^a-z]/i', $cli_name['title'] . $cli_name['fname'] . $cli_name['lname']))
{
//echo that the form contains invalid characters
echo "Some of the form contains invalid characters please remove them";
die;
}
//check all the name sections are filled
if (!isset($cli_name['title'], $cli_name['fname'], $cli_name['lname']))
{
//echo that the client didnt fill in some of the fields in the name section
echo "<h1>You missed some fields which need to be filed in in the names section</h1>";
//end the script
die;
}
//check if the email entered contains an @ and that the 2 email addresses match
/*if (!validate_email($cli_email) && (!$cli_email == $cli_reemail));
{
//echo that the client didnt fill in a valid email address
echo "<h1>You didnt enter a valid email address or the email addresses didn't match</h1>";
//end the script
die;
}*/
//check if the address fields have been filled
if (isset($cli_address['houseno'], $cli_address['street'], $cli_address['city'], $cli_address['county'], $cli_address['postcode'], $cli_address['country']))
{
$cli_address['postcode'] = ereg_replace(" ", "", $cli_address['postcode']);
if (strlen($cli_address['postcode']) == 6 || 7)
{
$query = "INSERT INTO `assi1` (title , first_name, last_name, email, house_number,
street, city, county, postcode, country) VALUES (`$cli_name['title']`, `$cli_name['fname']`,
`$cli_name['lname']`, `$cli_email`, `$cli_address['houseno']`, `$cli_address['street']`,
`$cli_address['city']`, `$cli_address['county']`, `$cli_address['postcode']`, `$cli_address['country']`)";
mysql_query($query) or die(mysql_error());
echo "<h1>Thank you for registering with Blake and the Tyger</h1>";
}
}
else
//echo the input form for registration
{
?>
<h1>Registration:</h1>
Please register to Blake and the Tyger Online using the form below.
<form name="form" method="post" action="?id=2" onsubmit="return validate(this)">
<fieldset>
<legend>Title</legend>
<label>Mr</label>
<input name="title" type="radio" value="Mr">
<label>Mrs</label>
<input name="title" type="radio" value="Mrs">
<label>Miss</label>
<input name="title" type="radio" value="Miss">
<label>Ms</label>
<input name="title" type="radio" value="Ms">
<label>Other</label>
<input name="title" type="radio" value="Other">
</fieldset>
<fieldset>
<legend>Names</legend>
<label for="fname">First Name:</label><br>
<input type="text" name="fname" size="50" id="fname">
<br>
<label for="lname">Last Name:</label><br>
<input type="text" name="lname" size="50" id="lname">
</fieldset>
<fieldset>
<legend>Email Address</legend>
<label>Email:</label><br>
<input type="text" name="email" size="50" id="email">
<br>
<label>Retype Email:</label><br>
<input type="text" name="reemail" size="50" id="remail">
</fieldset>
<fieldset>
<legend>Home Address</legend>
<label>House Number/Name:</label><br>
<input type="text" name="houseno" size="50"><br>
<label>Street Name:</label><br>
<input type="text" name="street" size="50"><br>
<label>City/Town:</label><br>
<input type="text" name="city" size="50"><br>
<label>County:</label><br>
<input type="text" name="county" size="50"><br>
<label>Postcode:</label><br>
<input type="text" name="postcode"><br>
<label>Country:</label><br>
<input type="text" name="country">
</fieldset>
<p><input type="hidden" name="action" value="submitted"><br><input type="submit" name="Submit" value="Submit" class="float-right" style="font-size:1em;">
<input type="reset" name="Reset" value="Clear" class="float-right" style="font-size:1em;"></p>
</form>
<?
}
?>