Jump to content

Recommended Posts

Hello everyone at phpFreaks,

 

I'm working on a simple form that emails the form data to an email address.

 

I have this working with the following code

 

<?php
  $email = $_REQUEST['email'] ;
  $name = $_REQUEST['name'] ;
  $country = $_REQUEST['country'] ;
  mail( "[email protected]", "New Mailing List Subscriber!", $country, "From: $email" );
  header( "Location: http://www.myspace.com/mercurialuk" );
?>

 

i removed my real email address to avoid spam ;) but in the real thing i have my email :) this [email protected] is just for this post

 

and the email output is: 

 

japan

 

lol!

 

I can see how it is doing this but the problem is, I want the email to be a little more detailed so how would i replace the $country to reflect something like:

 

$name from $country wants to join your mailing list! Their email is $email

 

Any ideas guys im really stuck with this ¬_¬

 

The closest i got is using '.' to add them together like this

 

$name . $email . $country

 

but that gave me an email that was

 

[email protected]

 

??

 

Thanks in advance!

 

Pete

Link to comment
https://forums.phpfreaks.com/topic/114519-new-to-php-please-help/
Share on other sites

You can only use specific parameters inside mail(); :)

 

Use an additional variable to hold your custom ones instead, so something like this:

 

 $email = $_REQUEST['email'] ;
 $name = $_REQUEST['name'] ;
 $country = $_REQUEST['country'] ;

$msg .= $name;
$msg .= " from ";
$msg .= $country;
$msg .= " wants to join your mailing list  Their email is: ";
$msg .= $email;

 mail( "[email protected]", "New Mailing List Subscriber!", $msg, "From: $email" );

 

Edit: Posted at the same time as Wildteen - his version's more visually compact and tidier :P

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.