/    Sign up×
Community /Pin to ProfileBookmark

PHP to email.

I’m new to this forum and semi new to php. I am in need of help badly here as I have a deadline going.

I have a registry page (html) with fields for name, number, address etc.

The way I used to do php reg forms was to have a first page with fill in boxes (fields) after filling in clicking submit would link to a second page thanking people for registering…

An email would go to a specified email address displaying the information entered into the fields. Really basic script really simple but affective.

I now need to make an html email so that the field information is sent to a specific email address with html code around it to present the information to look more like a fill out card with a logo on the top right, then the basic simple text style.

I have been looking for awhile and am coming up dry for answers. Most of the tutorials I find don’t detail how to make the field information display in the html email.

Can anyone help me? Or point me in the right direction?

— Nathan

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@blue-eye-labsJan 10.2008 — use the php mail() function. look up "php mail()" for usage.

Your host must have the sendmail binary installed and must have set it up properly.

Basically, it works something like this:
[code=php]mail($to, $subject, $message, $some_other_stuff_that_you_needn't_worry_about);[/code]
Copy linkTweet thisAlerts:
@blue-eye-labsJan 10.2008 — So basically:

assuming you have a form which posts "name" "age" "password" "email"...

[code=php]
<?php
$name = $_POST['name'];
$age = $_POST['age'];
$pwd = $_POST['password'];
$eml = $_POST['email'];

$me = "[email protected]";

//now let's make the message body
$message = "***REGISTRATION INFO***
Name: " . $name . "
Age: " . $age . "
Password: " . $pwd . "
Email: " . $eml . "
***";

//now let's mail it
//I'm assuming that you want it sent to yourself, otherwise just change the $me to $eml to send it to them.

mail($me, "Registration Information for $name", $message);

//now redirect to a thank you page
header("Location: thankyou.php");
?>
[/code]
Copy linkTweet thisAlerts:
@nate51authorJan 10.2008 — Ok,

Right now I am at a point where I have the email coming to my address looking the way I want. Only 2 issues remaining are...

  • 1. The logo on the right side of the mailer is not coming in even though I have allowed images in Outlook for this address, and the code in the php is an absolute link which works in Internet Explorer.


  • 2. This is the main issue, the email I recieve the information entered into the text fields is not coming to me it is coming in like this $firstname. I have tried these two options...

    a. <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>"$firstname n"</td>


  • b. <td class=content align=left valign=middle nowrap bgcolor=#eeeeee>"$firstname"</td>

    and both options it does not bring me the data to my email.
    Copy linkTweet thisAlerts:
    @blue-eye-labsJan 10.2008 — could you post the code for the form page and the code for how you're implementing the mailer script?
    Copy linkTweet thisAlerts:
    @blue-eye-labsJan 10.2008 — oh right, ok, I see, I think I misunderstood.

    I looked around and I think you need to put the content type into the message so that the html is rendered.

    [code=php]
    <?php
    $body="<em>HTML</em> formatted <strong>Message</strong";

    $headers = "From: [email protected] rn";
    $headers.= "Content-Type: text/html; charset=ISO-8859-1 ";
    $headers .= "MIME-Version: 1.0 ";

    /*notice there aren't any rn after the second two header additions. This is what made this version work correctly*/
    mail("[email protected]", "An HTML Message", $body, $headers);

    ?>
    [/code]


    (I got this from http://uk.php.net/mail, there is veritable plethora of stuff in the comments section about sending HTML mail)
    ×

    Success!

    Help @nate51 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.17,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...