我使用jquery serialize发送表单数据,如下所示:
Parse error: syntax error, unexpected '$name' (T_VARIABLE) in C:\Users\Jberke\Documents\Projects\theRetros\src\process.php on line 10
这已成功传递到PHP脚本,但我在PHP中收到以下错误。
<?php
$autoResponse = true; //if set to true auto response email will be sent, if you don't want autoresponse set it to false
$autoResponseSubject = "Demo Contact Form";
$autoResponseMessage = "Hi, thank you testing the JQuery Contact Form Demo.";
$autoResponseHeaders = "From: email_from@yourWebsite.com";
//we need to get our variables first
$email_to = 'jamie_b25@hotmail.com';
$subject = 'A enquiry for The Retros!'
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name \r\nMessage: \r\n$message";
/*the $header variable is for the additional headers in the mail function,
we are asigning 2 values, first one is FROM and the second one is REPLY-TO.
That way when we want to reply the email gmail(or yahoo or hotmail...) will know
who are we replying to. */
$headers = "From: $email\r\n";
$headers .= "CC: test@test.com\r\n";
$headers .= "Reply-To: $email\r\n";
if(mail($email_to, $subject, $body, $headers)){
if($autoResponse === true){
mail($email, $autoResponseSubject, $autoResponseMessage, $autoResponseHeaders);
}
echo 'success'; // we are sending this text to the ajax request telling it that the mail is sent..
}else{
echo 'error';// ... or this one to tell it that it wasn't sent
}
我的PHP脚本如下:
name=Jamie+Berke&email=jamie_b25%40hotmail.com&message=testing+123
&GT;
我不确定这里发生了什么,但似乎没有正确访问序列化数据。这是我的序列化数据的控制台日志片段。
Observable<Integer> source = Observable.range(0, 100);
source
.groupBy(k -> k / 10)
.publish(groups -> groups
.map(g -> Pair.of(g.getKey(), g.takeUntil(groups)))
.flatMap(kv ->
kv.second
.doOnNext(v -> System.out.println(kv.first + " value " + v))
.doOnCompleted(() -> System.out.println(kv.first + " done"))
))
.subscribe()
;
答案 0 :(得分:0)
您在PHP脚本中缺少一个分号,该行位于出现错误的行上方。
quarter
通常,当您收到类似这样的语法错误时,它实际上在上面的行中(有时甚至更高)。 PHP解析器认为前一个语句没有完成(因为缺少分号),并继续解析相同的语句。在那一点上,它被下一个语句的意外开始搞糊涂了。因此,当您收到第10行的消息时,请务必查看第9行或第8行。
答案 1 :(得分:0)
很简单,你在这里忘了一个semikolon:
$subject = 'A enquiry for The Retros!'
应该是:
$subject = 'A enquiry for The Retros!';