• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

My PHP Code cannot submit my online webform.

Community Beginner ,
Oct 18, 2017 Oct 18, 2017

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>";

  }

}

?>

Views

679

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 18, 2017 Oct 18, 2017

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

...

Votes

Translate

Translate
LEGEND ,
Oct 18, 2017 Oct 18, 2017

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 18, 2017 Oct 18, 2017

Copy link to clipboard

Copied

LATEST

Thank you. At least someone (you) has a brain around here. At least I'm not being stupid either.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 18, 2017 Oct 18, 2017

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 18, 2017 Oct 18, 2017

Copy link to clipboard

Copied

I've just asked. They do 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 18, 2017 Oct 18, 2017

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 18, 2017 Oct 18, 2017

Copy link to clipboard

Copied

That's fine, I've added in the code now.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines