PHP Contact Form

Hi All,
I have been struggling with running a php file for an html form I have on a website.
I built a similar php file for another website, and it works great, but for some reason this one is just not working. I get:
This page isn’t working is currently unable to handle this request.


I know this is something simple, I’m just at a dead end right now.


$nameFirst = $_POST['nameFirst'];
$nameLast = $_POST['nameLast'];
$email = $_POST['email'];
$website = $_POST['website'];
//$service = $_POST['service'];
$message = $_POST['message'];

$formcontent = "Sender name: $nameFirst $nameLast\n
Email: $email \n
Website: $website \n
Message: $message";

$recipient = "";
$subject = "Web submission from $email";
$mailheader = "For My Company \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");

<title>Contact ZS | Thank You</title>
<link href="css_zs_master.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
<div class="container">
<h5 class="form-data">Thank You <? php echo "$nameFirst"; ?>!</h5>
<h6 class="form-data">Your request has been sent and you will receive a follow up email shortly.</h6>
<a href="index-home.html"><button class="plain-button"><i class="fa fa-home"></i></i> Home</button></a>


Did you check the error log?

Ghost love,

No I have not, how do I do that?

You need to locate the error_log file. Location may vary depending on your config.

You could try <?php phpinfo(); ?> and look for error_log.

This file contains all errors encountered when running your scripts.

Don’t you want to do some validation, though?
Also this script looks like it will attempt to send an email on page load.

  # Do some validation

  mail($recipient, $subject, $formcontent, $mailheader);

I admit, I’m a novice when it comes to validating forms.
Working on it but I need to read more on how to do the validation properly.

Right now the submissions are sent to my email, the goal is to have the data sent to an sql database. But that comes after I learn how to do that :slight_smile:

Does that mean it’s now working, or is that the expected result? :slight_smile:

I got the php log to work, and there was an invalid syntax on line 29 … <? php and not <?php

Submission works!!!

Now I need to work on the validation.

Thanks for pointing out the error log, that really helped, and I’ll use it a lot in the future.

Yes, it’s really helpful! Glad that you got it to work :slight_smile:

Feel free to come back here if you run into any more issues, always happy to help.

For sure, great support in this community. I like it a lot more than stackoverflow!!!

1 Like