php - 有人可以帮我修复我的联系表 PHP 代码吗?
问题描述
我在 PHP 中编写了一个联系表单,但出现错误,请您帮帮我吗?
php表单代码:
<form class="contact-form" action="submit.php" method="post">
<div class="row">
<!--Name-->
<div class="col-md-6">
<input name="name" class="form-inp" type="text" placeholder="Name">
</div>
<!--Email-->
<div class="col-md-6">
<input name="email" class="form-inp" type="text" placeholder="Email">
</div>
<div class="col-md-12">
<!--Message-->
<textarea name="message" placeholder="How can I help you?" rows="7"></textarea>
<button name="submit" class="site-btn top_45 pull-right" type="submit">SUBMIT</button>
</div>
</div>
</form>
提交.php代码
<?php
if (isset($_POST['submit']){
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$mailTo = "info@xxxx.com";
$headers = "From: ".$email;
$txt = "You have received an email from ".$name.".\n\n".$message;
mail($mailTo, $email, $message);
header("Location: index.php?mailsend");
}
警告:未知:依赖系统的时区设置是不安全的。您需要使用 date.timezone 设置或 date_default_timezone_set() 函数。如果您使用了这些方法中的任何一种,但仍然收到此警告,您很可能拼错了时区标识符。我们现在选择时区“UTC”,但请设置 date.timezone 以选择您的时区。在 /home/brukitup/public_html/submit.php 第 2 行
解析错误:语法错误,第 2 行 /home/brukitup/public_html/submit.php 中的意外“{”
解决方案
解析错误:语法错误,第 2 行 /home/brukitup/public_html/submit.php 中的意外“{”
此错误是因为您缺少一个)
in
if (isset($_POST['submit']){
^^
至于您的其他警告,可能是由于 php 设置。在你的php.ini
,设置这个
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = <whatever timezone you want to use>
(来源)
推荐阅读
- java - RegEx 匹配 $1 代币
- pythonpath - 包的虚拟环境方法
- c# - 目标框架在 VS2019 中无效
- laravel-livewire - 如何在 Laravel Livewire 类中重用方法
- amazon-web-services - splunk 搜索查询中的日期时间格式搜索
- visual-studio - 意外撤销了“Github for Visual Studio”应用程序的身份验证,将其添加回来,现在我无法在 VS 中登录 git hub
- spring-boot - Stomp 客户端没有收到来自 Spring 的消息
- javascript - 猫鼬居住
- python - 我在 Python 中收到 Foursquare API 的关键错误消息
- c++ - 在不使用成员函数和友元函数的情况下实现运算符重载