sending all data from email with require field

I'm creating a user require form in my site. For this I put some validation on compulsory fields, and when a user fills in the form and presses submit and validation is correct then I receive a email on my email address.

But now I would like all user information in the email, like name, city, budget etc... so what changes do I need to make in my email.php script?

If some fields are not compulsory and the user doesn't fill them in, can they affect my script?

My script is:


  $to = "";
  $subject = "a new requiremnet come!";
  $message = "Hi,\n\nyou get a new require";

  $headers = "MIME-Version: 1.0" . "\r\n";
  $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
  $headers .= "Sender-IP: " . $_SERVER["SERVER_ADDR"] . "\r\n";
  $headers .= "From: " . stripslashes($name) . " <" . $email . ">" . "\r\n";
  $headers .= "Priority: normal" . "\r\n";
  $headers .= "X-Mailer: PHP/" . phpversion();

  $sent = mail($to, $subject, $message, $headers) ;

  if ($sent) {
    echo "Your mail was sent successfully";
  } else {
    echo "We encountered an error sending your mail";


and the data I recieve is:

$name = $_POST['fname'].' '.$_POST['lname'];
$email = $_POST['mail'];
$phone = $_POST['ph'];
$country = $_POST['country'];
$pt = $_POST['pt'];
$cwl = $_POST['cwl'];
$dyhyows = $_POST['dyhyows'];
$pb = $_POST['pb'];
$bpd = $_POST['bpd'];
$hdyhau = $_POST['hdyhau'];


You can add fields to the message body by concatenating them like so:

$message = "Hi,\n\nyou get a new require";
$message .= "\n Name:    " . $name;
$message .= "\n Email:   " . $email;
$message .= "\n Phone:   " . $phone;
$message .= "\n Country: " . $country;
$message .= "\n pt:      " . $pt;
$message .= "\n cwl:     " . $cwl;
$message .= "\n dyhyows: " . $dyhyows;
$message .= "\n pb:      " . $pb;
$message .= "\n bpd:     " . $bpd;
$message .= "\n hdyhau:  " . $hdyhau

Any fields that weren’t filled in by the user will simply be blank.

Need Your Help

How do I check State Code if it has four characters and then transform it to 2 character code?

xml xslt

What I am trying to do is check in the XML document for the element

Why is my Select Case not working select case

Okay my question goes as follows; I think i coded everything right execpt for the part where i do my select case, I want the first 3 Flavours to only cost 55 cents but when I do my code it always m...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.