5 Replies - 677 Views - Last Post: 22 April 2016 - 02:55 PM Rate Topic: -----

#1 Andy123   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 54
  • Joined: 24-February 14

PHP FORM NOT WORKING

Posted 22 April 2016 - 01:00 PM

PHP form isnt working and not sending the data to my email. the HTMl is correct, I feel there is a problem in the PHP

myemail is actually my email, but I replaced it here.

<?php

$to = 'myemail';

//grabs what user types in subject field
if(isset($_POST['subject'])){
    $subject = $_POST['subject'];
}

//grabs what user types in name field
if(isset($_POST['name'])){
    $name = $_POST['name'];
}

//grabs what user types in email field
if (isset($_POST['email'])) {
    $email = $_POST['email'];
}

//grabs what user types in message field
if(isset($_POST['message'])){
    $message = $_POST['message'];
}

//only runs if press submit button
if($_POST){
    mail($to, $subject, $message);
}

//bool mail ($to , $subject ,$message, $additional_headers )
?>



Is This A Good Question/Topic? 0
  • +

Replies To: PHP FORM NOT WORKING

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6888
  • View blog
  • Posts: 31,696
  • Joined: 10-May 07

Re: PHP FORM NOT WORKING

Posted 22 April 2016 - 01:19 PM

As with all mail questions from php :

a.) Does your ISP (or server) allow you to send mail?
b.) Is a mail program installed?
c.) Is email in your junk folder?

You can't "force" email to send with code. Calling mail does whatever you tell it to & PHP isn't an MTA, it just simply sends the mail as requested.
Was This Post Helpful? 0
  • +
  • -

#3 Andy123   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 54
  • Joined: 24-February 14

Re: PHP FORM NOT WORKING

Posted 22 April 2016 - 01:40 PM

Thanks for your answer.

1. How do I check if my hosting website allows me to send mail?
2. I'm sending the mail to my gmail
3. Its not in my junk
Was This Post Helpful? 0
  • +
  • -

#4 astonecipher   User is offline

  • Enterprise Software Architect
  • member icon

Reputation: 3169
  • View blog
  • Posts: 11,984
  • Joined: 03-December 12

Re: PHP FORM NOT WORKING

Posted 22 April 2016 - 01:41 PM

Let me also point out, your method call will send regardless... So, if someone just presses a submit button, and the form method is post, the method gets called.
Was This Post Helpful? 0
  • +
  • -

#5 Andy123   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 54
  • Joined: 24-February 14

Re: PHP FORM NOT WORKING

Posted 22 April 2016 - 01:42 PM

Ya I have no errors, but im just not receiving the mail on the other end

This post has been edited by Dormilich: 25 April 2016 - 03:20 AM

Was This Post Helpful? 0
  • +
  • -

#6 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6888
  • View blog
  • Posts: 31,696
  • Joined: 10-May 07

Re: PHP FORM NOT WORKING

Posted 22 April 2016 - 02:55 PM

View PostAndy123, on 22 April 2016 - 04:40 PM, said:

1. How do I check if my hosting website allows me to send mail?

Call their customer support.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1