what error?

View previous topic View next topic Go down

grimofdoom
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06

Postgrimofdoom 16/4/2012, 2:53 pm

i have this code i found
Code:
<?php
  {$name = $_POST['name'];
  $visitor_email = $_POST['email'];
  $message = $_POST['message'];

    $email_from = 'mail@mail.mail';
    $email_subject = "test";
    $email_body = "You have received a new message from the user $name.\n".
                            "Here is the message:\n $message".;}
?>
to send a message from contact us page.but when i do this,it comes up with error on line 8-10.i have some basic information on php but can't find the problem.
Vanilla990
Vanilla990
Administrator
Forum Posts : 114
Member Since : 2011-10-30

PostVanilla990 16/4/2012, 3:25 pm

Have you set up a html form to collect the information for the email?

It will also encounter an error when it gets to 'mail@mail.mail' as that's an invalid email address.
grimofdoom
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06

Postgrimofdoom 16/4/2012, 3:31 pm

i know its an invalid email because i had my email and i didnt get spammed. then there is a html form
Code:
<form method="post" name="myemailform" action="http://animereject.hostei.com/send.php">
Enter Name: <input type="text" name="name"><br>
Enter Email Address:    <input type="text" name="email"><br>
Enter Message:  <textarea name="message"></textarea><br>
<input type="submit" value="Send Form">
</form>
LGforum
LGforum
Moderator
Forum Posts : 77
Member Since : 2011-11-12

PostLGforum 16/4/2012, 9:57 pm

Where are you getting these codes from? Razz

Your error is this bit: "Here is the message:\n $message".

Its just a random string in the middle of the code...
There's also no reason for the PHP to be incased in curly brackets.
grimofdoom
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06

Postgrimofdoom 18/4/2012, 2:03 pm

i gt rid of the line but still error.guess ill jsut put this to the side for now since i have another css problem
LGforum
LGforum
Moderator
Forum Posts : 77
Member Since : 2011-11-12

PostLGforum 18/4/2012, 4:08 pm

Well what does the error say..?
grimofdoom
grimofdoom
Member
Member
Forum Posts : 106
Member Since : 2012-03-06

Postgrimofdoom 18/4/2012, 5:39 pm

"Parse error: syntax error, unexpected ';' in /home/a2195800/public_html/send.php on line 8"
Vanilla990
Vanilla990
Administrator
Forum Posts : 114
Member Since : 2011-10-30

PostVanilla990 19/4/2012, 10:30 am

I'm going to guess a bit and say it has something to do with the full stop and semi-colon on this line:

Code:

$email_body = "You have received a new message from the user $name.\n".
                            "Here is the message:\n $message".;}
LGforum
LGforum
Moderator
Forum Posts : 77
Member Since : 2011-11-12

PostLGforum 20/4/2012, 3:25 pm

That is also an error... but there's load of errors in it...

Swap it all for this:
Code:

<?php
  $name = $_POST['name'];
  $visitor_email = $_POST['email'];
  $message = $_POST['message'];

    $email_from = 'mail@mail.mail';
    $email_subject = "test";
    $email_body = "You have received a new message from the user $name. \nHere is the message:\n $message. ";
?>

Your biggest issue was having that random string flailing about. Also, when you use '\n' for a new line, you don't actually need to put a new line within your string... unless you get two new lines.

One of biggest benefits of PHP strings is you don't have to specify new lines with the \n meta character.
Sponsored content

PostSponsored content

View previous topic View next topic Back to top

Similar topics

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

 
Permissions in this forum:
You cannot reply to topics in this forum