提交时的SMTP联系人表单空白屏幕 [英] SMTP Contact Form blank screen on Submit

查看:77
本文介绍了提交时的SMTP联系人表单空白屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在联系表单上遇到了很多问题,有人知道我为什么在我的表单上按Submit时,我的代码只是显示一个带有((URL)/mail.php)的空白屏幕.

I've been having alot of issues with contact form, does anyone know why my code is just bringing up a blank screen with "(URL)/mail.php when i press Submit on my form.

这是我的代码

 <h2 class="formhead">Contact Form</h2>
<br>
  <form class="form" action="mail.php" method="post">

    <p class="name">
        <input type="text" name="name" id="name" placeholder="John Doe" />
        <label for="name">Name</label>
    </p>
<br>
    <p class="email">
        <input type="text" name="email" id="email" placeholder="mail@example.com" />
        <label for="email">Email</label>
    </p>
<br>
    <p class="number">
        <input type="text" name="number" id="number" placeholder="0774XXXXXXX" />
        <label for="name">Contact Number</label>
    </p>
<br>
    <p class="web">
        <input type="text" name="web" id="web" placeholder="www.example.co.uk" />
        <label for="name">Website</label>
    </p>
<br>
    <p class="query">
        <textarea name="query" id="query" placeholder="Write something to us" /> </textarea>
    </p>
<br>
    <p class="submit">
        <input name="btnSubmit" type="submit" onclick="javascript: return validate();"  value="Send" />
    </p>
  </form>

PHP

<?
ob_start();
if(isset($_POST['btnSubmit']))
{
require("class.phpmailer.php");

$mail = new PHPMailer();

//Your SMTP servers details

$mail->IsSMTP();               // set mailer to use SMTP
$mail->Host = "localhost";  // specify main and backup server or localhost
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username = "supp0rt@c(hidden)y.co.uk";  // SMTP username
$mail->Password = "DQ(hidden)"; // SMTP password
//It should be same as that of the SMTP user

$redirect_url = "http://".$_SERVER['SERVER_NAME']; //Redirect URL after submit the form

$mail->From = $mail->Username;  //Default From email same as smtp user
$mail->FromName = "Display Name";

$mail->AddAddress("enquiries@c(hidden)y.co.uk", "chapnolo"); //Email address where you wish to receive/collect those emails.

$mail->WordWrap = 50;                                 // set word wrap to 50 characters
$mail->IsHTML(true);                                  // set email format to HTML


$mail->Subject = $_POST['email'];
$message = "Name of the requestor :".$_POST['name']." \r\n <br>Email Adrress :".$_POST['email']." \r\n <br> Phone number :".$_POST['number']."\r\n <br> Message: ".$_POST['query']."\r\n <br> Website: ".$_POST['web'];
$mail->Body    = $message;

if(!$mail->Send())
{
   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}

echo "Message has been sent";
header("Location: $redirect_url");
}
?>

任何见解将不胜感激,我是PHP的新手.

Any insights would be greatly appreciated, I'm new to PHP.

推荐答案

它找不到php mailer类class.phpmailer.php.它与其余文件位于同一目录中吗??

It's not able to find the php mailer class class.phpmailer.php. Is it in the same directory as as the rest of the files..?

这篇关于提交时的SMTP联系人表单空白屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆