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 = 'organikcomputers@yahoo.com';

$subject = 'Question One';

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

 

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

$myemail = 'organikcomputers@yahoo.com';

$subject = 'Question Two';

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

 

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

$myemail = 'organikcomputers@yahoo.com';

$subject = 'Question Three';

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

 

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

$myemail = 'organikcomputers@yahoo.com';

$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
Share on other sites

oops i forgot to enter the period,

here it is with the period

 

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

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


</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.