【发布时间】:2021-12-31 04:59:28
【问题描述】:
我在 联系表单 的 php 脚本中创建了一个代码 sn-p(如下所示)。当控制台中没有显示错误时,表单不会自行显示。提出了一个问题,即“审核 navigator.userAgent、navigator.appVersion 和 navigator.platform 的使用情况”。 我正在使用 Windows 10 和 sublime 文本编辑器。 React JS 也安装在我的电脑上。 请帮我解决问题。
<?php
if(isset($_POST['send'])) {
$to_mail = $_POST['tomail'] ;
$subject = $_POST['subject'] ;
$body = $_POST['message'] ;
$from_mail = $_POST['frommail'];
$header = "From: $from_mail" ;
mail($to_mail, $subject, $body, $header) ;
if(mail($to_mail, $subject, $body, $header)){
echo "We have sent a mail to your mail id. Kindly check and confirm." ;
}else{
echo "No mail could be sent to you." ;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include 'header.php' ; ?>
</head>
<body>
<div class="container-fluid" id="container-contact">
<div class="row">
<div class="col col-12">
<form class="cform" action="<?php echo htmlentities($_SERVER('PHP_SELF')) ;?>" method = "POST">
<div class="form-group">
<label>To</label>
<input type="email" class="form-control" name="tomail"> <br><br>
<label>Subject</label>
<input type="text" class="form-control" name="subject"> <br><br>
<label>Message</label>
<textarea type="text" class="form-control" name="message" `enter code here`cols="40" rows="15"></textarea> <br><br>
<label>From</label>
<input type="email" class="form-control" name="frommail"> <br><br>
<button><input type="submit" name="send" value="Send"></button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
【问题讨论】:
-
查看生成页面的源代码,我敢打赌您会看到类似的错误...“未捕获的错误:函数名称必须是(您的文件名)中的字符串”。跨度>