PHP Email

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
PF2G
Forum Newbie
Posts: 13
Joined: Sat Sep 10, 2011 10:51 am

PHP Email

Post 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
greip
Forum Commoner
Posts: 39
Joined: Tue Aug 23, 2011 8:23 am
Location: Oslo, Norway

Re: PHP Email

Post by greip »

Have a look at the statement before the if-statement.
PF2G
Forum Newbie
Posts: 13
Joined: Sat Sep 10, 2011 10:51 am

Re: PHP Email

Post 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>";
theyapps
Forum Newbie
Posts: 8
Joined: Tue Sep 06, 2011 12:47 am

Re: PHP Email

Post 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>";
 }
 }
?>
PF2G
Forum Newbie
Posts: 13
Joined: Sat Sep 10, 2011 10:51 am

Re: PHP Email

Post 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?
theyapps
Forum Newbie
Posts: 8
Joined: Tue Sep 06, 2011 12:47 am

Re: PHP Email

Post by theyapps »

In your quote the variables were inside the quotation of text to quote. Variables should be outside the quotation.
PF2G
Forum Newbie
Posts: 13
Joined: Sat Sep 10, 2011 10:51 am

Re: PHP Email

Post 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.";
Post Reply