PHP Contact Form in Meloo theme

phpscripts

#1

Hi,

I have a PHP contact form that I think must also use some ajax because it’s not working at all! I had to disable the ajax to get the page to work, and now the contact form is not working…Can you tell me if you see anything wrong with this code? And if not, how can I get it to work without ajax and just plain php.
It’s from the Meloo theme:

<?php // Get email address require_once 'config.php'; // Ensures no one loads page and does simple spam check if(isset($_POST['name']) && empty($_POST['spam-check'])) { // Declare our $errors variable we will be using later to store any errors $error = ''; // Setup our basic variables $input_name = strip_tags($_POST['name']); $input_email = strip_tags($_POST['email']); $input_subject = strip_tags($_POST['subject']); $input_message = strip_tags($_POST['message']); // We'll check and see if any of the required fields are empty if(strlen($input_name) < 2) $error['name'] = 'Please enter your name.'; if(strlen($input_message) < 5) $error['message'] = 'Please leave a message.'; // Make sure the email is valid if(!filter_var($input_email, FILTER_VALIDATE_EMAIL) ) $error['email'] = 'Please enter a valid email address.'; // Set a subject & check if custom subject exist $subject = "Message from $input_name"; if($input_subject ) $subject .= ": $input_subject"; $message = "$input_message\n"; $message .= "\n---\nThis email was sent by contact form."; // Now check to see if there are any errors if(!$error) { // No errors, send mail using conditional to ensure it was sent if(mail($your_email_address, $subject, $message, "From: $input_email")) { echo '

Your email has been sent!

'; } else { echo '

There was a problem sending your email!

'; } } else { // Errors were found, output all errors to the user $response = (isset($error['name'])) ? $error['name'] . "
\n" : null; $response .= (isset($error['email'])) ? $error['email'] . "
\n" : null; $response .= (isset($error['message'])) ? $error['message'] . "
\n" : null; echo "

$response

"; } } else { die('Direct access to this page is not allowed.'); } Thank you, Alex

#2

Hello Alex and welcome to the forums!

I do not see any errors in the code, have you tried to contact the auhor of the theme for support?

I see that the code imports a configuration file named config.php
Are you sure you have set the outgoing server settings correctly?

Most web hosting providers require now for outgoing emails the secure SSL/TLS settings, which means the outgoing port in most cases is not the default one (25), but probably the 465, 587 or it depends how they configured it…
You should find these settings in your web hosting account (email set up)

If this is not the case and outgoing server settings are correct, which is the error displayed as response? I see in the code that it displays the error message in case of any error.

All the best!


#3

HI Hevada,

Thanks for your reply! I have paid nearly $50 to 2 developers today to help me this, neither could fix it. The problem is that the header was in the mail function.Today, the developer sent me an alternative, but unfortunately that is not working. I emailed him to tell him that.

I am sure the server settings are correct because 1) the developer sent me a php-file as a server test and it worked and 2) I have a different contact form on the same domain, different page and it works and 3) both developers checked my server settings, and possible errors and there are none.

The error displayed is the default one in the code. It’s “There was a problem sending your email!”

Please if you can provide any help or contact the developer I would appreciate. I have been going back/forth with him for days on this issue, I am late getting the website to my client and this is the only unresolved issue.

Thank you for taking a look.


#4

If this is the author of the template, his response time is up to 2 business days (so it might take a bit until he replies):


#5

Hevada, I am writing in this forum to request support because I have contacted the developer and he is not responding so I’ve just filled out a refund request.