猿问

在具有多个 php 版本的 centos 上安装 sqlsrv 扩展

你需要把你所有的 php 代码放在里面if (isset($_POST["submit"])),因为!isset当你load的 php 页面时条件总是为真。在您的代码中进行以下更改:


if (isset($_POST["submit"])) {

    $errName ="";

    $errEmail ="";

    $errMessage ="";

    $result="";

    $name = $_POST['name'];

    $business = $_POST['business'];

    $email = $_POST['email'];

    $message = $_POST['message'];

    $from = '------';

    $to = '-----';

    $subject = 'Message from user on website';

    $body ="-------";


// Check if name has been entered

if (!isset($_POST) || !key_exists('name', $_POST) || !filter_var($_POST['name'])) {

    $errName = 'Please enter your name';

}

// Check if email has been entered and is valid

if (!isset($_POST) || !key_exists('email', $_POST) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {

    $errEmail = 'Please enter a valid email address';

}

//Check if message has been entered

if (!isset($_POST) || !key_exists('message', $_POST) || !filter_var($_POST['message'])) {

    $errMessage = 'Please enter your message';

}

// If there are no errors, send the email

if (!isset($errName) && !isset($errEmail) && !isset($errMessage)) {

    $result .= '<br><div class="alert alert-success">Thank You! We will be in touch</div>';

} else {

    $result .= '<br><div class="alert alert-danger">Sorry there was an error sending your message. Please try again later.</div>';

}

} // end of isset


慕尼黑5688855
浏览 137回答 1
1回答

MYYA

一周前我们注意到我们缺少一些 pdo php 驱动程序,我们通过 yum 安装了它们,然后我们成功地将机器连接到了 sqlserver
随时随地看视频慕课网APP
我要回答