Copy link to clipboard
Copied
I cannot submit my contact form using my PHP code, along with my HTML form to my email when I execute this code? All I get is the "echo" of "there is an error" when submitting the form
Everything has been uploaded onto my Azure Remote Server and both documents below are in the root director
To be honest, my patience is running very thin with this. I'm so sick to death of ripping my hair out trying to work out why this is deciding to act like a disobedient child and now like a piece of software. Nothing I do ever works and I'm about to throw this computer against the wall. So save a computer from getting destroyed.
Thanks
<form action="/handler_mail.php" method="post">
<div class="formHeader textBlock">Book a casting</div>
<div class="formCaption textBlock">Please use this form to book a casting with me. </div>
<hr>
<label for="firstName">Firstname</label>
<input class="formInput" type="text" name="firstName" placeholder="First Name"/><br>
<label for="surname">Surname</label>
<input class="formInput" type="text" name="surname" placeholder="Surnames"/><br>
<label for="yourEmail">Your Email</label>
<input class="formInput" type="email" name="yourEmail" placeholder="Email address"/><br>
<br>
<textarea class="formInput" style="width: 500px; height: 300px;" placeholder="Please specify the particulars">
</textarea><br>
</form>
<?php
if(isset($_POST{"formSubmit"})){
$name=$_POST["firstName"];
$surname=$_POST["surname"];
$email=$_POST["yourEmail"];
$to ="example@example.com";
$subject="Form Submission";
$message="Name: ".$name."\n"."Surname: ".$surname;
$headers="From: ".$email;
if(mail($to, $name, $surname, $email)){
echo "Success" . " -" . "<a href='Pages/bookacasting.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
}
else{
echo "Error" . " -" . "<a href='Pages/bookacasting.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
}
}
?>
toddg10857565 wrote
I cannot submit my contact form using my PHP code, along with my HTML form to my email when I execute this code?
- Everything has been uploaded onto my Azure Remote Server and both documents below are in the root director
Thanks
Things to check. I suspect Microsoft Azure does NOT support the php mail function, which I assume you are using?
Normally I would not advise to use a Microsoft server to do anything with php as its not its native environment and more often than not leads to
...Copy link to clipboard
Copied
toddg10857565 wrote
I cannot submit my contact form using my PHP code, along with my HTML form to my email when I execute this code?
- Everything has been uploaded onto my Azure Remote Server and both documents below are in the root director
Thanks
Things to check. I suspect Microsoft Azure does NOT support the php mail function, which I assume you are using?
Normally I would not advise to use a Microsoft server to do anything with php as its not its native environment and more often than not leads to problems.
I think you will have to use another method to send the mail if you insist on using php. Double check with your provider and see what mail functions are available for php and if they have a specific php script they can recommend.
I can tell you your form code DOES work to a point that you will get an email response - so all indications are the problem lies with your Micosoft server set up.
Copy link to clipboard
Copied
Thank you. At least someone (you) has a brain around here. At least I'm not being stupid either.
Copy link to clipboard
Copied
If i remember correctly, the Azure web server whils supporting php, does not allow mail to be sent using a php script.
A C# mail script should work, but check with MS.
Copy link to clipboard
Copied
I've just asked. They do 🙂
Copy link to clipboard
Copied
I'm afraid that in order for anyone to help you debug here, you're going to need to share the html and php code. Unless it can be scrutinized line by line, no one can point you in the right direction for solving your problem.
Chris
Copy link to clipboard
Copied
That's fine, I've added in the code now.