在同一页面上激活materialize css表单?

问题描述 投票:0回答:1

我正在使用materialize css html构建一个站点,我想激活这个表单,以便它发送信息但是在成功消息的同一页面上。

由于某种原因,它重定向到不同的页面,并给我以下PHP语法错误消息。

致命错误:未捕获错误:调用未定义的函数联系表单提交()26堆栈跟踪:#0 {main}在第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!"

}


?>
php css forms materialize contacts
1个回答
0
投票
$subject = 'Contact Form Submit'
($to,$subject,$message){

这两行被窃听。

你在第一个结尾处缺少一个分号,所以

$subject = 'Contact Form Submit';

而另一个根本没有意义? 我猜你的意思

if(mail($to,$subject,$message)) {
© www.soinside.com 2019 - 2024. All rights reserved.