我正在尝试为现有的html表单创建php代码。当我尝试创建代码时,它似乎有关闭括号的问题,任何人都可以帮忙吗?
<?php
if (isset($_POST['your_name'])) {
$your_name = $_POST['your_name'];
if (isset($_POST['your_email'])) {
$your_email = $_POST['your_email'];
if (isset($_POST['subject'])) ;
$subject = $_POST['subject'];
if (isset($_POST['message'])) ;
$message = $_POST['message'];
$to = "email.co.uk";
$subject = "New Message";
mail ($to, $subject, $message, "From: " . $your_name);
echo "Your message has been sent";
?>
由于
答案 0 :(得分:-1)
这是因为您在每个;
语句中使用if
而不是if { .. }
语句尝试此代码
<?php
if (isset($_POST['your_name'])) {
$your_name = $_POST['your_name'];
}
if (isset($_POST['your_email'])) {
$your_email = $_POST['your_email'];
}
if (isset($_POST['subject'])) {
$subject = $_POST['subject'];
}
if (isset($_POST['message'])) {
$message = $_POST['message'];
}
$to = "email.co.uk";
$subject = "New Message";
mail ($to, $subject, $message, "From: " . $your_name);
echo "Your message has been sent";
?>