Website source:http://www.salefee.com/
Please check out this website. I have made a form to enter email address under "To recieve the salefee story ebook,submit your email id". This form will redirect to php file named as story.php file. This php file is programmed to send email to admin.
The problem is that when user clicks submit button it is redirected to url http://www.salefee.com/story.php
and a blank page appears and I am not getting automated mail.
My story.php file is as follows:
<?php
if ($_POST) {
$to_email = "salefee12@gmail.com" //Recipient email, Replace with own email here
//Sanitize input data using PHP filter_var().
$user_trial_email = filter_var($_POST["trial-email"], FILTER_SANITIZE_EMAIL);
//additional php validation
if (!filter_var($user_trial_email, FILTER_VALIDATE_EMAIL)) { //email validation
$output = json_encode(array('type'=>'error', 'text' => 'Please enter a valid email.'));
die($output);
}
//subject
$subject = "The Story";
$user_trial_name = "salefee12@gmail.com"
$user_trial_phone = "1234567890"
//email body
$message_body = "Name : ".$user_trial_name."
Email : ".$user_trial_email."
Phone : ".$user_trial_phone."
App link:https://play.google.com/apps/testing/com.salefee.salefee.salefee";
//proceed with PHP email.
$headers = 'From: '.$user_trial_name.''."
".
'Reply-To: '.$user_trial_email.''."
".
'X-Mailer: PHP/'.phpversion();
$send_mail = mail($to_email, $subject, $message_body, $headers);
if (!$send_mail)
{
//If mail couldn't be sent output error. Check your PHP email configuration (if it ever happens)
$output = json_encode(array('type'=>'error', 'text' => 'Could not send mail! Please check your PHP mail configuration.'));
die($output);
} else {
$output = json_encode(array('type'=>'message', 'text' => 'Hi '.$user_trial_name.', Thank you for subscribing. You will soon get a link to download app.'));
die($output);
}
}
?>
My form in html file is as follows:
<!-- Mailchimp Newsletter -->
<div class="newsletter-wrapper animateblock rtl-2 speed-1">
<form action="story.php" method="post">
<div class="form-group input-group input-newsletter" style="width:400px;margin: 0 auto;">
<input class="form-control" id="trial-email" name="trial-email" type="email" required autocomplete="on" placeholder="Enter email" style="border-color:#D9534F;">
<div class="input-group-btn">
<button class="btn btn-danger" type="submit">click me</button>
</div>
</div>
</form>
</div>
</div>
<!-- End Mailchimp Newsletter -->
I have used similar php code in other 2 forms on my website. Those other 2 forms are working properly(I am getting mail). But this php code is not working.
Please help me this code. Guide me how to debug this code or how to print a message on browser so that I can understand till where my code is running properly. Thanks in advance.!!