Jump to content

Basic PHP mail $_POST help Plz


OrganikComp

Recommended Posts

Hey everyone,

 

I'm terrible at PHP and need help quick

 

I have a website and part of it is a function where people fill out a survey and click submit so their answers are emailed to me

 

My old way of them filling out the survey was to send them to a third party but recently i decided to do some coding myself mostly using tutorials and other people for help

 

heres the code

 

<html>

<head>

<title></title>

</head>

 

 

<?php $hello = $_POST['one'];

$myemail = '[email protected]';

$subject = 'Question One';

mail($myemail, $subject, $hello); ?>

 

<?php $hello = $_POST['two'];

$myemail = '[email protected]';

$subject = 'Question Two';

mail($myemail, $subject, $hello); ?>

 

<?php $hello = $_POST['three'];

$myemail = '[email protected]';

$subject = 'Question Three';

mail($myemail, $subject, $hello); ?>

 

<?php $hello = $_POST['four'];

$myemail = '[email protected]';

$subject = 'Question Four';

mail($myemail, $subject, $hello); ?>

 

 

</body>

 

 

</html>

 

It sends me four separate emails containing a single answer thats in correspondance to the POST question

 

Can anyone give me a code so i can incorporate all the questions but get every single answer in a single email instead of the way it is working currently

 

Someone suggested a loop but i'm not sure how to do that or if it will work

 

Thanks for the help

Link to comment
https://forums.phpfreaks.com/topic/81957-basic-php-mail-_post-help-plz/
Share on other sites

<html>

<head>

<title></title>

</head>

 

 

<?php

$hello = $_POST['one'];

$myemail = '[email protected]';

$subject = 'Question';

$message = $_POST['one'] . "\n" $_POST['two'] . "\n" . $_POST['three'] . "\n" . $_POST['four'];

mail($myemail, $subject, $message); ?>

</body>

 

 

</html>

oops i forgot to enter the period,

here it is with the period

 

<html>
<head>
<title></title>
</head>

<body>
<?php
$hello = $_POST['one'];
$myemail = '[email protected]';
$subject = 'Question';
$message = $_POST['one'] . "\n" $_POST['two'] . "\n" . $_POST['three'] . "\n" . $_POST['four'];
mail($myemail, $subject, $message); ?>
</body>


</html>

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.