...

View Full Version : unexpected $end ERROR



ajetrumpet
02-11-2010, 07:19 AM
all,

I can't seem to figure this one out. I am getting this error after adding the section that is between the seperators. but...this section is not the problem, as I put a small string as a substitute for the send_body variable, and it still results in the same error. can anyone spot the error in this rather large file? thank you so much!
<?

//THIS IS WHERE WE CONTINUE ON TO CHECK IF THERE ARE CORRECT FORMATS FOR SOME FIELDS THAT SHOULD BE FILLED IN...
if (! $_POST["name"] || ! $_POST["lname"] || ! $_POST["email"] || ! $_POST["phone"])
{
echo '<script language="javascript">alert("Please fill in all required fields...");history.back();</script>';
}
else
{
if (strpos($_POST["email"], "@")) {
//DO NOTHING
}
else {
echo '<script language="javascript">alert("Please provide a valid email address...");history.back();</script>';
exit;
}

if (strlen($_POST["phone"]) != 12)
{
echo '<script language="javascript">alert("Please provide a valid phone number...");history.back();</script>';
exit;
}
else
{
for ($i = 0; $i <= 11; $i++) {
if ($i == 3 || $i == 7) {
if (substr($_POST["phone"], $i, 1) == "-") {
//DO NOTHING
}
else {
echo '<script language="javascript">alert("Please provide a valid phone number...");history.back();</script>';
exit;
}
}
else {
if (is_numeric(substr($_POST["phone"], $i, 1))) {
//DO NOTHING
}
else {
echo '<script language="javascript">alert("Please provide a valid phone number...");history.back();</script>';
exit;
}
}
}
}

//THIS SECTION IS FOR SETTING THE PRODUCTS OF INTEREST...
$send_product = '';

if ($_POST["listencheck"] == 'on') {
$send_product = $send_product . 'Listening Skill Builder, ';
}
if ($_POST["wordcheck"] == 'on') {
$send_product = $send_product . 'Word Sequencer, ';

if ($send_product == '') {
$send_product = 'Not Provided ';
}

if ($send_product == 'Not Provided ') {
echo '<script language="javascript">alert("Please specify a product...");history.back();</script>';
exit;
}

//This is for the access version
$send_version = $_POST["ver"];


$to = $_POST["email"];
$subject = "company: Submission Confirmation";

$body = '
<html>

<head>
</head>

<body>

Dear ' . $_POST["name"] . ',

<br><br>

Your application will be ready for download within the next hour.
If you have any difficulty downloading or installing our applications,
please do not hesitate to give me a call at 000 000 0000.
You can also reach me by email at: adam@COMPANY.com.
Below are the instructions for downloading your trial system.

<br><br>

1a) Listening skill applications will be located at the following URL:
<a>http://www.COMPANY.com/trials/listen/' . $_POST["name"] . $_POST["lname"] . '/TRIAL.zip
<br>
1b) Word Sequence skill applications will be located at the following URL:
<a>http://www.COMPANY.com/trials/word/' . $_POST["name"] . $_POST["lname"] . '/TRIAL.zip
<br>
2) Save the file to a location that you can later locate with ease.
<br>
3) Right click on the file and choose "Extract All" to unzip the file
<br>
4) Once you have extracted the files, choose the "setup" file that is located inside the folder
<br>
5) The rest is simple. All you need to do is locate the file on your desktop!

<br><br><br>

<strong>PLEASE NOTE: you may wish to keep the downloaded file at your fingertips
so you can uninstall the program once it has expired. <em><u>simply deleting the
folders and files manually from your directories will NOT unregister the product from
your system.</em></u> To uninstall our products without future issues, please click
the "setup" file, as you used in step number 4 above (choose the "remove" option) to
unregister the product from your system and to ensure that all necessary files are deleted.</strong>

<br><br><br>

Once again, thank you for your interest, and we hope that you can see the benefit
of having our systems available for your clients in the future!

<br><br><br>

Sincerely,

<br><br>

Adam
<br>
Chief Technology Officer
<br>
COMPANY
<br>
CITY
<br>
<a>http://www.COMPANY.com</a>

</body>

</html>';


$headers = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=iso-8859-1' .
"\r\n" . 'From: adam@COMPANY.com' . "\r\n" . 'Reply-To: adam@COMPANY.com';

if (mail($to, $subject, $body, $headers)) {
//echo("<p>Message successfully sent!</p>");
} else {
//echo("<p>Message delivery failed...</p>");
}

// First we set up some parameters for the receiver
$receiver_name = 'COMPANY';
$receiver_email = 'corp@COMPANY.com, adam@COMPANY.com';
$mydomain = 'COMPANY.com';

// This is for the sender's name - NAME OF THE SENDER
$send_from = $_POST["name"].' '.$_POST["lname"];

// This is for the sender's email - EMAIL ADDRESS OF THE SENDER
$send_from_email = $_POST["email"];

// This is for the message phone - PHONE NUMBER
$send_phone = $_POST["phone"];

//This gives the receiver the SENDER'S NAME and EMAIL ADDRESS
$send_header = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=iso-8859-1' .
"\r\n" . 'From: ' . $_POST["email"] . "\r\n" . 'Reply-To: ' . $_POST["email"];

$send_title = 'Demo Request From: '.$_POST["name"].' '.$_POST["lname"];


//********THIS IS THE NEW SECTION I ADDED BEFORE I STARTED GETTING THE ERROR
$send_body = '
<html>

<head>
</head>

<body>

Sender: ' . $send_from . '<br><br>Email: ' . $send_from_email . '<br><br>Phone: ' .
$send_phone . '<br><br>Requested: ' . substr($send_product, 0, strlen($send_product) - 2) .
'<br><br>Access Version: ' . $send_version . '<br><br><br><br>The following message was sent to: '
. $_POST["email"] . '<br><br>

</body>

</html>' . $body;

//*************END OF THE NEW SECTION HERE


// Now we need to send the message
$deliver = mail($receiver_email, $send_title, $send_body, $send_header);

$path = "Logs/demoreqs.txt";

$s_name = $_POST["name"] . " " . $_POST["lname"];
$s_email = $_POST["email"];
$s_phone = $_POST["phone"];
$s_requested = $send_product;
$s_version = $send_version;
$s_date = date(DATE_COOKIE);
$Content = $s_name . "|" . $s_email . "|" . $s_phone . "|" . $s_requested . "|" . $s_version . "|" . $s_date;

$fh = @fopen($path,"a");
fputs($fh, $Content . "<br>");
fclose ($fh);

if ($deliver == true) {
header("Location: http://www.COMPANY.com/TSubmissionReq.php");
} else {
echo '<p>We had a problem sending your request. Please e-mail your message directly to us at: corp@COMPANY.com';
}
}

?>

abduraooft
02-11-2010, 07:46 AM
if ($_POST["wordcheck"] == 'on') {
$send_product = $send_product . 'Word Sequencer, ';

Looks like you missed a } after the above.

ajetrumpet
02-11-2010, 11:22 AM
if ($_POST["wordcheck"] == 'on') {
$send_product = $send_product . 'Word Sequencer, ';

Looks like you missed a } after the above.

nice job. thanks a bunch!

masterofollies
02-11-2010, 03:24 PM
$end usually always every time means you are missing a closing bracket }

abduraooft
02-11-2010, 04:26 PM
Hi ajetrumpet,

I observe a lot of drawbacks in your code.

Usage of short open tags <? may make your code non portable since your code won't work on a server where you can't turn on short_open_tags

if (! $_POST["name"] || ! $_POST["lname"] || ! $_POST["email"] || ! $_POST["phone"])
{
echo '<script language="javascript">alert("Please fill in all required fields...");history.back();</script>';
} What if there's no javascript support? And what if the user enter just a blank space to anyone of the above fields?

if (strpos($_POST["email"], "@"))
Users can easily bypass the above by entering just an '@'. Search for the manual pages of preg_match() to see some email validation snippets.

ajetrumpet
02-12-2010, 04:37 AM
Hi ajetrumpet,

I observe a lot of drawbacks in your code.

Usage of short open tags <? may make your code non portable since your code won't work on a server where you can't turn on short_open_tags
What if there's no javascript support? And what if the user enter just a blank space to anyone of the above fields?

Users can easily bypass the above by entering just an '@'. Search for the manual pages of preg_match() to see some email validation snippets.


abdura,

I really do appreciate your feedback on my code. but i am not even close to understanding this language, but fortunately for me, none of the people that would fill out forms on my website would be joking about wanting information, and most of them will not be computer literate anyway.

I would very concerned about what you have mentioned if i was running a social networking website, but since I am in private business and most communication is not sent in a joking manner, I really don't have much to worry about. thanks though!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum