如何定制php脚本,使反馈与用户在表单中输入的完全相同?
有没有人知道如何定制php页面,以便用户可以看到他已经填写的内容的反馈?我注意到很多php脚本都有“谢谢”的反馈,但我想要的不仅仅是这些。php的代码如下所示:如何定制php脚本,使反馈与用户在表单中输入的完全相同?,php,forms,Php,Forms,有没有人知道如何定制php页面,以便用户可以看到他已经填写的内容的反馈?我注意到很多php脚本都有“谢谢”的反馈,但我想要的不仅仅是这些。php的代码如下所示: <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "james@ace.com.sg"; $email_subject = "Photography Courses that
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "james@ace.com.sg";
$email_subject = "Photography Courses that I want to sign up";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['tel']) ||
/*!isset($_POST['basic']) ||
!isset($_POST['advanced']) ||
!isset($_POST['raw']) ||
!isset($_POST['lightroom']) ||*/
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['tel']; // required
$basic = $_POST['basic']; // not required
$advanced = $_POST['advanced']; // not required
$raw = $_POST['raw']; // not required
$lightroom = $_POST['lightroom']; // not required
$comments = $_POST['comments']; // not required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
/*if(!preg_match($string_exp,$telephone)) {
$error_message .= 'You need to insert the telephone number.<br />';
}*/
/* if(strlen($comments) < 2) {
$error_message .= 'Insufficient Words for comments! <br />';
}*/
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "\n Name: ".clean_string($name)."\n\n";
$email_message .= "Email: ".clean_string($email_from)."\n\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n\n";
$email_message .= "Courses Taking: \n\n".clean_string($basic)."\n\n" .clean_string($advanced)."\n\n" .clean_string($raw)."\n\n" .clean_string($lightroom)."\n\n";
$email_message .= "Comments: ".clean_string($comments)."\n\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
<?php
echo '<h2>Thanks for filling up this form, We will get back to you by next Monday (29 Sep). Have a terrific weekend!</h2>';
echo '<p>**How do I feedback of what the user has already filled in the form here?** </p>';
?>
<?php
$redirect = 'http://www.acetraining.com.sg';
?>
<?php
}
?>
<SCRIPT LANGUAGE="JavaScript">
redirTime = "4000";
redirURL = "<?php echo $redirect ?>";
function redirTimer() {
self.setTimeout("self.location.href=redirURL;",redirTime);}
</script>
<BODY onLoad="redirTimer()">
redirTime=“4000”;
redirURL=“”;
函数redirTimer(){
self.setTimeout(“self.location.href=redirl;”,redirTime);}
谢谢 在
if(isset)
条件中为日期创建一个变量。在这条线之后
if(isset($_POST['submit'])){
$date=date("j M \(D\)");
$date2=date("l \(j D)", strtotime($Date. ' + 3 days'));
//I added Three days. You can its +3, you can add any number of days. its up to you
读了你的最后一封信,是根据那封信写的
我希望结果看起来像这样
echo 'Thanks for filling up the form This is the confiermation what had filled up:' .
'<br/>'. 'Name: '.$name.' Email: ' .$email_from.' Tel: '. $telephone .' Courses: '.
$advanced. ' '.' - '.$date.' Right Now';
谢谢你的帮助。我设法解决了这个问题。这就是我在php页面中所做的
echo '<h2>Thanks for filling up the form. This is the confirmation of what you had filled up:<br/><br/>' .'<br/>'. 'Name: '.$name.'<br/><br/>'.' Email: '.$email_from.'<br/><br/>'.'Tel: '.$telephone.'<br/><br/>'.' Courses: '.$basic.'<br/><br/>'.$advanced.'<br/><br/>'.$raw.'<br/><br/>'.$lightroom.'<br/><br/>'.' Comments: '.$comments.'<h2>';
echo'谢谢您填写表格。这是对您所填写内容的确认:
。
。'姓名:'.$Name'.
'.'Email:'.$Email_from'.
'.'Tel:'.$tell'.$telephone'.
.'Courses:'.$basic'.
.$advanced'.
.$raw'.$lightroom.
.';
它现在工作得很好 谢谢你的及时回复。事实上,我希望受访者的详细信息在成功HTML部分:谢谢!好啊我希望结果是这样的:谢谢你填写表格。这是对您填写内容的确认:姓名:James电子邮件:clavin007@gmail.com电话:612233445课程:面向摄影师的高级Photoshop CC-11月14日(星期五)现在,用户在填写后看到的反馈是“感谢您填写此表格。我们将在下周一(9月29日)前回复您”祝你周末愉快。我不要这个。我希望我清楚。再次感谢您的及时回复。我不想自定义错误消息。例如,如果此人填写表格时姓名为James,电子邮件为clavin007@gmail.com. 单击send按钮后,我希望php表单输出为他的名字James和emailclavin007@gmail.com. 这是一种确认,而不仅仅是显示感谢信息。对不起,我对php不是很在行,我不太懂代码。不管怎样,你能帮我处理我提供的现有代码吗?干杯对我成功地编辑了。非常感谢您的及时回复。你帮了大忙!干杯嗨,你怎么接受这个答案?有没有我点击的特殊按钮?
echo '<h2>Thanks for filling up the form. This is the confirmation of what you had filled up:<br/><br/>' .'<br/>'. 'Name: '.$name.'<br/><br/>'.' Email: '.$email_from.'<br/><br/>'.'Tel: '.$telephone.'<br/><br/>'.' Courses: '.$basic.'<br/><br/>'.$advanced.'<br/><br/>'.$raw.'<br/><br/>'.$lightroom.'<br/><br/>'.' Comments: '.$comments.'<h2>';