【发布时间】:2019-08-07 16:03:27
【问题描述】:
我正在使用 materialize css html 构建一个站点,我想激活此表单,以便它发送信息但与成功消息保持在同一页面上。
由于某种原因,它重定向到不同的页面并给我以下 php 语法错误消息。
致命错误:未捕获的错误:调用未定义函数 Contact Form Submit() in 26 Stack trace: #0 {main} throw in on line 26
HTML
<form id="form" method="post" action="contact.php" class="contact-form" novalidate="novalidate">
<div class="card-panel grey lighten-4">
<h5>Please fill out this form</h5>
<div class="input-field">
<input id="name" name="name" type="text" class="validate" required="" aria-required="true">
<label for="name">Full Name</label>
<span class="helper-text" data-error="Please enter name" data-success=""></span>
</div>
<div class="input-field">
<input id="email" type="text" class="validate" required="" aria-required="true">
<label for="email">Email</label>
<span class="helper-text" data-error="Please enter email" data-success=""></span>
</div>
<div class="input-field">
<input id="phone" type="text" class="validate" required="" aria-required="true">
<label for="phone">Phone</label>
<span class="helper-text" data-error="Please enter phone number" data-success=""></span>
</div>
<div class="input-field">
<textarea id="textarea1" class="materialize-textarea" cols="30" rows="10"></textarea>
<label for="textarea1">Message</label>
</div>
<!--<input type="submit" value="Submit" class="btn blue white-text waves-effect waves-light">-->
<button class="btn blue waves-effect waves-light" type="submit" name="action">Submit
<i class="material-icons right">send</i>
</button>
</form>
PHP
<?php
$prenom = !empty($_POST['first_name']) ? $_POST['first_name'] : NULL;
$nom = !empty($_POST['last_name']) ? $_POST['last_name'] : NULL;
$from = !empty($_POST['email']) ? $_POST['email'] : NULL;
$msg = !empty($_POST['message']) ? $_POST['message'] : NULL;
$tel = !empty($_POST['phone']) ? $_POST['phone'] : NULL;
$headers = 'From: WEBSITE E-MAIL';
// echo "$msg" . "$nom" . "$from";
if(empty($prenom) || empty($nom) || empty($from) || empty($msg))
{
}
elseif(mail('EMAIL ADRESS', "Commande Amarrex de $prenom $nom", "$prenom $nom a ecrit : $msg \n\n\n E-mail de contact : $from\n\n Telephone : $tel", "$headers"))
{
echo 'Mail sent.';
}
else
{
echo 'mail not sent, unexpected error';
}
$to = 'test@localhost';
$subject = 'Contact Form Submit'
($to,$subject,$message){
$success = "Message sent, thank you for contacting us!"
}
?>
【问题讨论】:
-
您好,欢迎来到 Stack Overflow,请包含 PHP 生成的确切错误消息。谢谢
标签: php css forms materialize contacts