donglu9896 2016-08-08 02: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 03:21
    关注
    change the action of the form 
    add this action=<?php bloginfo('template_url'); ?>/process.php"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部