donglu9896 2016-08-08 10:59
浏览 25
已采纳

PHP联系页面不在Wordpress网站上发送

I'm creating a custom Wordpress theme and the contact page template wont process my process.php file to send mail.

The file is inside the theme folder.

However, on submission it redirects to the home page with the title of the page being file not found.

I also get this error in my MAMP access logs file:

127.0.0.1 - - [08/Aug/2016:11:55:31 +0100] "POST /wordpress-4.5.3/wordpress/contact/process.php HTTP/1.1" 404 3384

The code that is within the process.php file looks like this:

$to = "myemail@gmail.com";

$subject = htmlspecialchars($_POST['name']);

$email = htmlspecialchars($_POST['email']);

$number = htmlspecialchars($_POST['number']);

$message = htmlspecialchars($_POST['message']);

$headers = "Senders email addresS: " . $email;
$headers .= "Senders number: " . $number;

mail($to, $subject, $message, $headers);

and the template contact file looks like this:

        <form method="post" action="process.php">

            <p> Name: * </p> 

            <input type="text" name="name" required> <br>

            <p> Email: * </p> 

            <input type="email" name="email"> <br>

            <p> Phone Number: * </p> 
            <input type="number" name="number"> <br>

            <p> Message: * </p> 

            <textarea name="message" required>  

            </textarea> <br> 

            <button type="submit" name="submit"> Send </button>             

        </form>

If anyone has any suggestions to help me fix this, I would greatly appreciate it, plus if you need any more information, let me know!

Many Thanks!

  • 写回答

1条回答 默认 最新

  • douxiao0400 2016-08-08 11:21
    关注
    change the action of the form 
    add this action=<?php bloginfo('template_url'); ?>/process.php"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?