I know how to code well in HTML and CSS. I learnt a bit of Javascript and added it to my website( www.udichi.in). It is all set except for the contact form (at the bottom of the page) which unfortunately I am stuck at!
I followed YouTube tutorials for the required PHP and linked it to my HTML. But it is sending me an HTTP error 500. I spoke to GoDaddy for 3 hours but they said the issue is with the code. So I tried some other tutorials as well. Also downloaded and tried a form from GitHub. In the other options, there was no error 500 but something else which made me think that maybe my code only has errors.
Anyway, that was too much code for me to understand and I would be grateful to solve the simple bit that I had tried previously following the YouTube tutorial. Please help me out, I have worked for three works making a beautiful website and now I am losing on time as I cannot upload it without the contact form. I am uploading my HTML here:
<div class="text">
<h1>We are Listening!</h1>
<p>Fill up the form and we will get in touch with you shortly</p>
<div class="contact_form">
<form action="contactform.php" method="POST">
<input type="text" id="name" name="name" placeholder="Name*">
<input type="text" id="email" name="email" placeholder="Email id*" class="contact_even">
<input type="text" id="phone" name="phone" placeholder="Phone No.">
<input type="text" id="city" name="city" placeholder="City" class="contact_even">
<textarea id="message" name="message" placeholder="How Can We Help You?" style="height:200px"></textarea>
<button type="submit" name="submit">Send Message</button>
</form>
</div>
</div>
And here is the PHP code in the contactform.php file:
(The professional email id mentioned in the script is also on GoDaddy as the tutorial I followed mentioned that gmail ids won’t work here. Also, I added the headers at the bottom about the MIME version and content-type after watching other videos explaining that it is important to write that)
<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$mailFrom = $_POST['email'];
$phone = $_POST['phone'];
$city = $_POST['city'];
$message = $_POST['message'];
$mailTo = "[email protected]";
$headers = "From: ".$mailFrom;
$txt = .$name."(".$phone") from ".$city" says:nn".$message;
$headers = "MIME-VERSION: 1.0" . "rn";
$headers .= "Content-type:text/html;charset=UTF-8" . "rn";
mail($mailTo, $headers, $txt);
?>
Also, if the code is right and I have to speak to GoDaddy regarding some server issue, what should I ask them for? I have no knowledge of PHP. Thank you very much!
2
Answers
Your are missing the closing braces for the
if
in your PHP code it should bemultiple concat error in $txt = .$name."(".$phone") from ".$city" says:nn".$message; and forgot to close if