douzhu1188
douzhu1188
2011-12-01 09:30

使用require字段从电子邮件发送所有数据

  • php
  • email

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:

<?php

  $to = "test@networkers.in";
  $subject = "a new requiremnet come!";
  $message = "Hi,

you get a new require";

  $headers = "MIME-Version: 1.0" . "
";
  $headers .= "Content-type:text/html;charset=iso-8859-1" . "
";
  $headers .= "Sender-IP: " . $_SERVER["SERVER_ADDR"] . "
";
  $headers .= "From: " . stripslashes($name) . " <" . $email . ">" . "
";
  $headers .= "Priority: normal" . "
";
  $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'];
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答