English 中文(简体)
访问者在接触表后的姓名
原标题:Addressing visitor by name after contact form submision
  • 时间:2011-10-06 07:29:25
  •  标签:
  • php
  • redirect

我的“接触网页”上有以下编码线,我还要以访问者的名义,在他们改用“你网页”时,感谢他们的讲话,但“你”网页只显示“你”与我们联系。

<?
   $mailto =  info@siteripe.com ; // insert the email address you want the form sent to
    $returnpage =  thanks.php ; // insert the name of the page/location you want the user to be returned to
    $sitename =  [siteripe.com] ; // insert the site name here, it will appear in the subject of your email



$name = $_POST[ name ];
  $email = $_POST[ email ] ;
   $subject = $_POST[ subject ];
   $message = $_POST[ message ];
    $phone = $_POST[ phone ];





if (!$name) {
        print("<strong>Error:</strong> Please provide your name.<br/><br/><a href= javascript:history.go(-1) >Back</a>");
         exit;


}
    if (!$email) {
        print("<strong>Error:</strong> Please provide an email address.<br/><br/><a href= javascript:history.go(-1) >Back</a>");
         exit;
    }



if (!$subject) {
        print("<strong>Error:</strong> Please provide a subject.<br/><br/><a href= javascript:history.go(-1) >Back</a>");
         exit;
    }



if (!$phone) {
        print("<strong>Error:</strong> Please provide a Phone number<br/><br/><a href= javascript:history.go(-1) >Back</a>");
         exit;
    }



if (!$message) {
        print("<strong>Error:</strong> Please provide a Message<br/><br/><a href= javascript:history.go(-1) >Back</a>");
         exit;
    }


if (!eregi("^[a-z0-9]+([-_.]?[a-z0-9])+@[a-z0-9]+([-_.]?[a-z0-9])+.[a-z]{2,4}", $email)){
    print("<strong>Error:</strong> this email address is not in a valid format.<br/><br/><a href= javascript:history.go(-1) >Back</a>");
         exit;
    }   




$message = "
$name submitted the following message:

$message

Sender s contact details are as follows:

Name: $name
Phone Number: $phone
Email Address: $email
";

  mail($mailto, "$subject", $message, "From: $email");
    header("Location: " . $returnpage);
?>

谢谢你,我有以下守则:

    <?php echo $_POST["name"]; ?> 增 编for contacting us<br />

增 编

最佳回答

The reason that the name is not showing up is that you are not passing any data to it. You can update your send php file using the codes below:

header( Location:http://www.domain.com/感谢you.php?name= .$name);

感谢you.php

<?php echo $_GET[ name ]; ?> Thanks for contacting us
问题回答

$_POST lives only for the current request, so if you change page the array will be gone.
You could use $_SESSIONS instead to store more persistent datas.
Be careful of having session_start() called at the top of your page when using $_SESSIONS.

$_SESSION[ name ] = $_POST[ name ];

谢谢你。

<?php echo isset($_SESSION[ name ]) ? $_SESSION[ name ] :   ;?> Thanks for contacting us<br />




相关问题
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 ...

热门标签