代码之家  ›  专栏  ›  技术社区  ›  Dan Ashton

PHP邮件链接

  •  1
  • Dan Ashton  · 技术社区  · 7 年前

                <form method="post">
    
                    <input type="text" name="contact-name" placeholder="Name." required>
                    <input type="email" name="contact-email" placeholder="Email." required>
                    <input type="text" name="contact-subject" placeholder="Subject." required>
                    <br><br>
                    <textarea name="contact-content"></textarea>
                    <div id="contact-btn-wrap">
                        <input type="submit" name="contact-submit" id="login-btn-signup" value="SEND EMAIL">
                    </div>
    
                </form>
                    <br><br><br><br>
                    <div class="contact-me">danashton89@gmail.com | 07714709250</div>
                </div>
            </div>
            <div class="contact-img">
                <img src="/uploads/Portfolio/Level_Design/Unreal_Engine/Ice_Cove/icecastle_3.png">
            </div>
    
    
            <?php
    
                $contact-name = "";
                $contact-email = "";
                $contact-subject = "";
                $contact-content = "";
    
                    if (isset($_POST['contact-submit'])) 
                    {
                        $contact-name = mysqli_real_escape_string($con, $_POST['contact-name']);
                        $contact-email = mysqli_real_escape_string($con, $_POST['contact-email']);
                        $contact-subject = mysqli_real_escape_string($con, $_POST['contact-subject']);
                        $contact-content = mysqli_real_escape_string($con, $_POST['contact-content']); 
    
                            $to = "danashton89@gmail.com";
                            $subject = $contact-subject;
                            $txt = $contact-content;
                            $headers = "From: " . $contact-name . "<br>" . $contact-email . "\r\n";
                            $headers.= "MIME-version: 1.0\n";
                            $headers.= "Content-type: text/html; charset= iso-8859-1\n";
    
                        mail($to,$subject,$txt,$headers);
                    }
    
            ?>
    
    2 回复  |  直到 7 年前
        1
  •  3
  •   user2976753    7 年前

    首先,不能用“-”在php中声明变量

    其次,定义了连接变量?

    最后,你能提供错误字符串吗?

        2
  •  3
  •   ctbs1    7 年前