[SOLVED] New form issue. Original post solved.
Posted: Fri May 30, 2008 3:50 pm
I apologize if I'm posting in the wrong place, but I didn't know whether to reply to my original post with a new issue or start over. Obviously, I chose to start over. I solved my original issue, which was a "whitespace" issue and being new to PHP and Swift, quite an accomplishment for me.
My new problem is the following error message upon submitting my form:
Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/bullzico/public_html/bullzi_swift/Swift.php on line 36
I looked in Swift.php and don't have a clue to what this is relating to other than it is line 36 and "version number". I haven't seen any instruction to make additions or changes in Swift.php.
My handler code is attached:
I hope there's help out there, as this is out of my reach. Happy to provide more information if needed.
Thanks
PS - Should I mark a previous post as solved in some way?
My new problem is the following error message upon submitting my form:
Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/bullzico/public_html/bullzi_swift/Swift.php on line 36
I looked in Swift.php and don't have a clue to what this is relating to other than it is line 36 and "version number". I haven't seen any instruction to make additions or changes in Swift.php.
My handler code is attached:
Code: Select all
<?php
//Check if the required fields were sent
// Redirect back to the form if not
if (empty($_POST["name"]) || empty($_POST["email"]) || empty($_POST["organization"]) || empty($_POST["phone"]))
{
//redirect back to form
header("Location: support.php?error=not_enough_info"); //This should really be an absolute URL if you know it
exit();
}
//Copy into global variables
$name = $_POST["name"];
$organization = $_POST["organization"];
$phone = $_POST["phone"];
$email = $_POST["email"];
$fax = $_POST["fax"];
$address = $_POST["address"];
$city = $_POST["city"];
$state = $_POST["state"];
$zip = $_POST["zip"];
$body = $_POST["comments"];
$title = $_POST["subject"];
//Validate the email address using a regex
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email))
{
header("Location: /support.php?error=invalid_email");
exit();
}
//Check if an attachment was uploaded
$file_path = false;
$file_name = false;
$file_type = false;
if (!empty($_FILES["attachment"]["tmp_name"]))
{
if ($_FILES["attachment"]["error"])
{
//Redirect if the upload has failed
header("Location: /support.php?error=upload_failed");
exit();
}
$file_path = $_FILES["attachment"]["tmp_name"];
$file_name = $_FILES["attachment"]["name"];
$file_type = $_FILES["attachment"]["type"];
}
//Everything looks ok, we can start Swift
require_once "bullzi_swift/Swift.php";
require_once "bullzi_swift/Swift/Connection/Sendmail.php";
//Enable disk caching if we can
if (is_writable("/tmp"))
{
Swift_CacheFactory::setClassName("Swift_Cache_Disk");
Swift_Cache_Disk::setSavePath("/tmp");
}
//Try to connect using /usr/sbin/sendmail -bs
$swift = new Swift(new Swift_Connection_Sendmail());
//Create the sender from the details we've been given
$sender = new Swift_Address($email, $name);
//Create the message to send
$message = new Swift_Message($title);
$message->attach(new Swift_Message_Part($name));
$message->attach(new Swift_Message_Part($organization));
$message->attach(new Swift_Message_Part($phone));
$message->attach(new Swift_Message_Part($fax));
$message->attach(new Swift_Message_Part($address));
$message->attach(new Swift_Message_Part($city));
$message->attach(new Swift_Message_Part($state));
$message->attach(new Swift_Message_Part($zip));
$message->attach(new Swift_Message_Part($body));
//If an attachment was sent, attach it
if ($file_path && $file_name && $file_type)
{
$message->attach(
new Swift_Message_Attachment(new Swift_File($file_path), $file_name, $file_type));
}
//Try sending the email
$sent = $swift->send($message, "me@mycompany.tlb", $sender);
//Disconnect from SMTP, we're done
$swift->disconnect();
if ($sent)
{
header("Location: /thanks.html");
exit();
}
else
{
header("Location: /support.php?error=sending_failed");
exit();
}
?>Thanks
PS - Should I mark a previous post as solved in some way?