PHP Contact Form Not Sending Email

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 22:34:41
<input type="submit" name="submit" value="submit" />

You have to change this line to:

<input type="submit" name="send" value="submit" />



  if($_POST['send']){ 

actually checking if submit button is clicked...

And, yes - if html and php are on different pages, you have to set proper form action link...

konnection

Before you continue anything, I think you shold take a look at this or this, be awere that despite W3Schools may serve as a basics tutorial because of the friendly-user examples, always complement with other resources look here why.

Then you can take a look at this answers, this is just because you need some more basis to understand everything you are doing.

I can't see your $_POST['send'] name in the form, or it's just too late and I'm tired:

Don't know, but maybe, you want this in your form before the submit:

<input type="hidden" name="send" >

Then:

I already posted this answer HERE, but here it is:

First i think your missing some headers look at those

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

2nd check if its true or false when calling the mail function

if( mail($email_to, $email_subject, $email_message, $headers)!==true)
    {
        die('Fail to send');


    }
    die('Sucess');

    }

You shold take a look at the isset() function to make sure all your variables are set from the form.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!