How can I set $to of mailer class as a variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mt68
Forum Newbie
Posts: 5
Joined: Wed Aug 05, 2009 10:06 am

How can I set $to of mailer class as a variable

Post by mt68 »

I'm experiencing alot of issues trying to create the $to field as a variable, PHP is reporting Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /home/shhdcouk/public_html/PHP/class_vcard.php on line 2 and I'm not sure why.... my code is.

$send = $_POST['email1'];
$to = $send;
$subject = "Registered for xxxx";
$body="Thank you for registering your details xxxx\n\n";
$headers= "From: xxxx Web Site\r\n";

if(mail($to, $subject, $body, $headers)) {
include ("OK.htm");
}
else {
include("Error.htm");
}

Can anyone help a frustrated newcomer?
User avatar
turbolemon
Forum Commoner
Posts: 70
Joined: Tue Jul 14, 2009 6:45 am
Location: Preston, UK

Re: How can I set $to of mailer class as a variable

Post by turbolemon »

Is that the code listing of class_vcard.php?
mt68
Forum Newbie
Posts: 5
Joined: Wed Aug 05, 2009 10:06 am

Re: How can I set $to of mailer class as a variable

Post by mt68 »

Apologies of the error is misleading....The file is named vcard_class, however I have adapted the code to send the details as an email. You have however, pointed me to the right answer, there is nothing wrong with my code, I just didn't close the previous argument, hence the error.

many thanks
Post Reply