I been working on a personal website for a while now and I am just a beginner. I am currently using Bulma.io framework for css along with javascript. My current issue is that when I try running the php script (Making a contact Form) instead of sending email it just downloads the php source code. Can someone look at what is wrong? I looked at couple forums and they said host it and I host it on Firebase which doesn't make a difference. This is the php code
<?php
$name =$_REQUEST['name'];
$email =$_REQUEST['email'];
$msg =$_REQUEST['Message'];
$to = 'myemail@gmail.com';
$subject = 'Form Submission';
$message = "Name: " .$name. "\n". "email: " .$email. "\n". "Message: " .$msg;
$headers= "From: " .$email;
if (empty($name) || empty($email) || empty($msg))
{
echo "Please fill all the fields";
}
else
{
if(mail($to,$subject,$message,$headers))
{
echo "<h1> Sent Sucessfully! Thank you"." ".$name.", I will contact you shortly";
}
}
?>
This is my HTML
<form class ="Contactform" action = "contact.php">
<div class = "columns">
<div class = "column is-half">
<div class = "title is-1 ">
Contact Form
</div>
</div>
<div class = "column is-half">
<div class = "field">
<label class = "label namepart">Name</label>
<div class = "control">
<input class ="input name" type="text" placeholder = "e.g John Doe" name = "name">
<div class="field emailpart">
<label class="label">Email</label>
<div class="control has-icons-left has-icons-right">
<input class="input email" type="email" placeholder="Email input" value="name@" name = "email">
<span class="icon is-small is-left">
<i class="fas fa-envelope"></i>
</span>
<span class="icon is-small is-right">
</span>
</div>
</div>
</div>
<div class ="Messagepart">
<label class = "label">Message</label>
<textarea class="textarea" placeholder="e.g. Description" name = "msg"></textarea>
</div>
<div>
<br>
<button class= "button is-sucess "> Submit </button>
</div>
</div>
</form>
Aucun commentaire:
Enregistrer un commentaire