Page 1 of 1

PHP Email

Posted: Sat Sep 10, 2011 11:04 am
by PF2G
Hi everybody!!

I'm creating a website for a Music School and i'm working on a 'Contact' page, where the user can say anything and when the message is submited, it's automatically send to my email.
But i'm having problems:

Code: Select all

<?php

include 'topo.php';

//Verifica como é que o envio é feito
if(isset($hidSubmit))
{

//Declarar variáveis
$mail_to = "paulo.devil92@gmail.com";
$name = $_POST['nome'];
$mail_from = $_POST['email'];
$mail_sub = "EMInfante";
$mail_mesg = $_POST['mensagem'];
$head = 'From: ' . $name . ' - ' . $email_from;
$head = 

//Entregue com sucesso/falhado
if(mail($name,$mail_from,$mail_sub,$mail_msg))
 {
  echo "<span class='red'>E-mail has been sent successfully from $mail_sub to $mail_to</span>";
 }
else
 {
  echo "<span class='red'>Failed to send the E-mail from $mail_sub to $mail_to</span>";
 }
 }
?>
The line

Code: Select all

if(mail($name,$mail_from,$mail_sub,$mail_msg))
it is giving an error about "unexpected T_IF".

Can someone help me?

PLEASE I NEED IT AS SOON AS POSSIBLE
Thank you

Re: PHP Email

Posted: Sat Sep 10, 2011 12:14 pm
by greip
Have a look at the statement before the if-statement.

Re: PHP Email

Posted: Sat Sep 10, 2011 12:21 pm
by PF2G
greip wrote:Have a look at the statement before the if-statement.
What a stupid i am!! i didn´t see that:

Code: Select all

$head =
I am so sorry.

But my real problem is that i don't recieve the message that is suppose to appear:

Code: Select all

echo "<span class='red'>E-mail has been sent successfully from $mail_sub to $mail_to</span>";
 }
else
 {
  echo "<span class='red'>Failed to send the E-mail from $mail_sub to $mail_to</span>";

Re: PHP Email

Posted: Sun Sep 11, 2011 12:49 am
by theyapps
First thing I noticed in the echo's was that the variable wern't escaped from the quotation.

Code: Select all

<?php
//Entregue com sucesso/falhado
if(mail($name,$mail_from,$mail_sub,$mail_msg))
 {
  echo "<span class='red'>E-mail has been sent successfully from ".$mail_sub." to ".$mail_to."</span>";
 }
else
 {
  echo "<span class='red'>Failed to send the E-mail from ".$mail_sub." to ".$mail_to."</span>";
 }
 }
?>

Re: PHP Email

Posted: Sun Sep 11, 2011 5:29 am
by PF2G
theyapps wrote:First thing I noticed in the echo's was that the variable wern't escaped from the quotation.

Code: Select all

<?php
//Entregue com sucesso/falhado
if(mail($name,$mail_from,$mail_sub,$mail_msg))
 {
  echo "<span class='red'>E-mail has been sent successfully from ".$mail_sub." to ".$mail_to."</span>";
 }
else
 {
  echo "<span class='red'>Failed to send the E-mail from ".$mail_sub." to ".$mail_to."</span>";
 }
 }
?>
Sorry but i didn't understandd. Is something wrong in the echo?

Re: PHP Email

Posted: Mon Sep 12, 2011 10:20 pm
by theyapps
In your quote the variables were inside the quotation of text to quote. Variables should be outside the quotation.

Re: PHP Email

Posted: Fri Sep 23, 2011 5:09 pm
by PF2G
After several day of hard work i now can send email 8)

But message doen't show :(

Code: Select all

if (isset($_REQUEST['email']))
{
//send email
$to = 'paulo.devil92@gmail.com' ;
$subject = "Dúvida/Comentário Escola Música VNG" ;
$email = $_REQUEST['email'] ;
$nome = $_REQUEST['nome'] ;
$msg = $_REQUEST['mensagem'] ;

if (mail($to, $subject, "From: " . $nome, $email, $msg))
{
echo "Mensagem enviada com sucesso. Obriagado!!";
header("Location: http://escolamusicavng.net16.net/contact.php");
}
else
{
echo "Envio falhado. Tente mais tarde.";