Jump to content

[SOLVED] mail function with multiple variables


dannau

Recommended Posts

Dear all,

 

I'm a beginner in PHP coding. I´ve made a form that connects to a Mysql database and an echo function of all the inormation. I'm tyrying to include a mail function that sends all the variables on our email address. It works flawlessly when I use only one variable, but is stuck with a T_variable message when I use more than one variable:

 

This is the code as I have it now:

$message = "Recu informations qualité de "$nom" pour le voyage effectué en "$mois" "$annee". \n\n Contact: "$contact", \n Supports: ".$supports.", \n Logements: "$logements", \n Circuit: "$circuit", \n Excursions: "$excursions", \n Guides: "$guides", \n Repas: "$repas", \n Transports: "$transports", \n Note: "$note", \n Commentaire: "$commentaire;
mail('my [email protected]', 'Retour de Questionnaire Qualite',$message);

 

This is probably a very basic and stupid mistake (I hope) but I have been working on this for a whole day.

 

Thanks,

 

Mark (Mantagua, Chile)

Your error is here: "$logements", \n Circuit: "$circuit",

 

You need to concatenate there

 

try this :

$message = "Recu informations qualité de " .$nom. " pour le voyage effectué en " .$mois. " " .$annee. ". \n\n Contact: " .$contact. ", \n Supports: " .$supports. ", \n Logements: " .$logements. ", \n Circuit: ". $circuit. ", \n Excursions: " .$excursions. ", \n Guides: " .$guides. ", \n Repas: " .$repas. ", \n Transports: " .$transports. ", \n Note: " .$note. ", \n Commentaire: " .$commentaire. "";

 

Or if you want the quotes to appear around the variables, preceed them with a backslah... example qualité de \"$nom\"

 

 

I'm very proud of myself because I found the solution on my own.

 

I've started using snippets of the message and they would all work separately. That's until I added the part where two variables are one behind the other. I just added a short word in between and it works.

 

Before:

$message = "Recu informations qualité de " .$nom. " pour le voyage effectué en " .$mois. " " .$annee. ". \n\n Contact: " .$contact. ", \n Supports: " .$supports. ", \n Logements: " .$logements. ", \n Circuit: ". $circuit. ", \n Excursions: " .$excursions. ", \n Guides: " .$guides. ", \n Repas: " .$repas. ", \n Transports: " .$transports. ", \n Note: " .$note. ", \n Commentaire: " .$commentaire. "";

 

After:

$message = "Recu informations qualité de " .$nom. " pour le voyage effectué en " .$mois. " de " .$annee. ". \n\n Contact: " .$contact. ", \n Supports: " .$supports. ", \n Logements: " .$logements. ", \n Circuit: ". $circuit. ", \n Excursions: " .$excursions. ", \n Guides: " .$guides. ", \n Repas: " .$repas. ", \n Transports: " .$transports. ", \n Note: " .$note. ", \n Commentaire: " .$commentaire. "";

 

Does someone send me a chocolate medal now?

 

Cheers,

 

Mark

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.