Quantcast
Viewing all articles
Browse latest Browse all 5994

rubyannrsls on "How to execute form action in wordpress?"

<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="<?php echo get_bloginfo('template_directory');?>/php/submitform.php">

I've tried different method to execute the form action but I failed to make my form working. I don't know what's wrong. Is it my hosting (godaddy)? Conflict in wordpress coding? Hope you could help me with this. Thanks!

Here's my php code

<?php
if(isset($_POST['submit'])) {
header('Content-type: application/json');
$status = array(
	'type'=>'success',
	'message'=>'Thank you for contacting us. We will reply as early as possible.  '
);

$name = @trim(stripslashes($_POST['name']));
$email = @trim(stripslashes($_POST['email']));
$subject = @trim(stripslashes($_POST['subject']));
$message = @trim(stripslashes($_POST['message']));

$email_from = $email;
$email_to = 'rubyannrsls@gmail.com';//replace with your email

$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;

$success = mail($email_to, $subject, $body, 'From: <'.$email_from.'>');

echo json_encode($status);
die;
}
?>

Viewing all articles
Browse latest Browse all 5994

Trending Articles