Jump to content

New to php please help :)


midgar777

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

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.