English 中文(简体)
联系形式 php 帮助
原标题:contact form php help
  • 时间:2012-01-13 04:53:57
  •  标签:
  • php
  • contacts

奥基我有我们的联系形式,能够充分运作和正确处理。 我有两个问题:

  1. on the contact form page , I wish to add a checkbox for user to tick to send copy of the email to them aswell.

  2. 在程序上,如果所有错误都非常错误,我就希望改用错误页。

目前,我提出,我会采取行动感谢你们。 php

我的形式是,在感谢者.php网页上添加了内容,但在必要时可以单独删除。

iii

我的形式进程如下(非常简单)

<?php

$youremail = "[email protected]";

$yourname    = $_POST[ yourname ];
$email   = $_POST[ email ];
$location = $_POST[ location ];
$textarea = $_POST[ textarea ];

 $headers = "From: $email";

$content = "Hello there! This is a message from your contact form.





Name: $yourname



E-mail: $email



Location: $location



Message: $textarea

";

$send = mail($youremail,  Message from your conatct form , $content, $headers);

 if($send)
 {
echo "ok";
 }

不要与营地进行钻探,因此得到任何帮助

最佳回答
<?php
$youremail  = "[email protected]";
$yourname   = $_POST[ yourname ];
$email      = $_POST[ email ];
$location   = $_POST[ location ];
$textarea   = $_POST[ textarea ];
$ReceiveMail= $_POST[ txtReceive ];

if($ReceiveMail == "yes") {
    $content    = "";
    $headers    = "From: $email";
    @mail($email,  Mail Notification , $content, $headers);
}
    $headers    = "From: $email";
    $content = "Hello there! This is a message from your contact form.

    

    

    Name: $yourname

    

    E-mail: $email

    

    Location: $location

    

    Message: $textarea

";
    $send = mail($youremail,  Message from your conatct form , $content, $headers);
    if($send)    {
        header("location:thankyou.php");
        exit;
    }
    else {
        header("location:error.php");
        exit;
    }
?>

I have added one checkbox in form and check the value in server side. Try this. Hope it will help

问题回答

如果你要寄送邮件副本,那么你需要增加适当的邮寄人,例如:


$headers  =  MIME-Version: 1.0  . "
";
$headers .=  Content-type: text/html; charset=iso-8859-1  . "
";
$headers .=  To: Somename <[email protected]>  . "
";
$headers .=  Cc:  .$yourCopyMail . "
"; // this is for copy
//then
if(mail(....)) {
  echo "sent";
}
else {
  header("Location: url_to_your_error_page");
  exit;
}

关于你的第一个问题:

This page gives a quick tutorial on how to add a checkbox to your form and receive the value on the following page. When you re processing the form submission, just look at the variable $_POST["checkboxname"] and see if it s set to the value you gave to the checkbox (or if it s set at all, really). If it is, then just repeat the command to send the email, with the user s email as the recipient.

如果是的话,它想到的是$send=mail($email), 页: 1

我不知道如何回答你的第二个问题,因为“如果一切都发生可怕的错误”,就没有特别有意义的条件。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...