-5
請問我是網絡開發和PHP編程的新手,我有一個PHP表單代碼和一個表單,但每當我測試它在一個服務器此錯誤消息我得到:
FATAL ERROR syntax error, unexpected T_STRING, expecting T_VARIABLE or '$' on line number 18
,代碼如下:
<?php
/* Set e-mail recipient */
$myemail = "[email protected]";
/* Check all form inputs using check_input
function */
$yourname = check_input($_POST['yourname'],
"Enter your name");
$subject = check_input($_POST['subject'],
"Write a subject");
$email = check_input($_POST['email']);
$website = check_input($_POST['website']);
$likeit = check_input($_POST['likeit']);
$how_find = check_input($_POST['how']);
$comments = check_input($_POST['comments'],
"Write your comments");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $
email))
{
show_error("E-mail address not valid");
}
/* If URL is not valid set $website to empty */
if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/
i", $website))
{
$website = '';
}
/* Let's prepare the message for the e-mail */
$message = "Hello!
Your contact form has been submitted by:
Name: $yourname
E-mail: $email
URL: $website
Like the website? $likeit
How did he/she find it? $how_find
Comments:
$comments
End of message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header('Location: thanks.html');
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
<html>
<body>
<b>Please correct the following error:</b>
<br />
echo $myError;
</body>
</html>
exit();
}
你有電子郵件,擺在面前 – Goikiu
感謝很多形式現在的工作,悲傷,我錯過了線,雖然行,應該使用一種編程IDE而不是繞過這種模糊。 SALUTE! – Jones