I have an issue with PHP's mail() function. I'm not on the localhost, I'm not using a local server or something of this kind.
I'm just doing a plain website with HTML/CSS and I'm on Windows.
Basically, I made a contact form in HTML and I want it to send me an email on my Gmail address with the information filled by the user. I have re-used an old piece of PHP code that I already used before and that worked (one year ago).
However, when I fill the form and submit it (with the code below), I get nothing in my inbox.
Moreover, when I click on the send button ("J'envoie!"), it redirects me to the contactform.php file (a blank page where I see the php code of this file).
I checked that it was the right address, check if the name ("UName1", "UName2", "btn-send") matched the names I put in the PHP file but still, I can't find where is my error...
Can you please help me with that? I have no clue where the error is...
So here are my 2 files:
- submit.html (the form part only)
<form class="part" action="contactform.php" method="post">
<br>
<div class="input-wrapper">
<input type="text" name="UName1" placeholder="Mon nom"></input>
</div>
<br><br>
<div class="input-wrapper">
<input type="text" name="UName2" placeholder="Le titre de mes notes"></input>
</div>
<br><br>
<a href="arigato.html" style="text-decoration: none;">
<button type="submit" name="btn-send" class="input-wrapper2">J'envoie!</button>
</a>
</form>
- contactform.php
<?php
if(isset($_POST['btn-send']))
{
$UserName = $_POST['UName1'];
$UserAccount = $_POST['UName2'];
if(empty($UserName) || empty($UserAccount))
{
header('location:submit.html?error');
}
else
{
$to = "santoshpassoubady@gmail.com";
if(mail($to,$UserName,$UserAccount))
{
header("location:submit.html?success");
}
}
}
else
{
header("location:submit.html");
}
?>
Please tell, if there is any other thing information I should give!