0

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!

Alok Patel
  • 7,842
  • 5
  • 31
  • 47

1 Answers1

0
change the action of the form 
add this action=<?php bloginfo('template_url'); ?>/process.php"
mollie
  • 140
  • 1
  • 16
  • Does not seem to work, bring up a blank page of the file path and the email does not send? –  Aug 08 '16 at 11:52
  • you put the comment that file not found. now page form redirected well. Now you need to check your mail function. if live working Please print the function and check PHP mail function. – mollie Aug 08 '16 at 12:08
  • also put the mail function in if(mail(mail($to, $subject, $message, $headers))){echo "mail send";}else{ echo "mail not send";} – mollie Aug 08 '16 at 12:09
  • It comes up with "Mail not sent" - when looking at the PHP varibles on PHPINFO it says "submit" has no value, does it need one? –  Aug 08 '16 at 12:51
  • ok check in phpinfo that mail enable and also why the mail not send, and please accept my answer. – mollie Aug 08 '16 at 12:59
  • I think you add wrong header Please check http://stackoverflow.com/questions/5335273/how-to-send-an-email-using-php – mollie Aug 08 '16 at 13:13