如何使用php

时间:2016-10-24 15:40:25

标签: php bootstrap-modal

我试图从数据库中获取两个字段并在我的模态上解析它们。我正在使用boostrap v3.3.6。这就是我想要的:

$hosp_id = $_GET['hosp_id'];
$hosp_email = $_GET['hosp_email'];

这是我的HTML代码

echo '<div class="col-md-6">';
      $hosp_id = $row3['hosp_id'];
      $hosp_email = $row3['hosp_email'];
      echo '<a href="#sendMessage" data-userid="'. $hosp_id . $hosp_email .'" class="consult-online" data-toggle="modal" role="button"> Send Message </a>';
 echo '</div>';

然后在我的PHP代码中提交模式我使用此代码;

<?php
    $error ="";  
    require '../script.php';


    if (isset($_POST['msgsubmit'])){

    $hosp_id = $_GET['hosp_id'];
    $hosp_email = $_GET['hosp_email'];

    $msgname = $_POST["msgname"];
    $msgphone = $_POST["msgphone"];
    $msgmail = $_POST["msgmail"];
    $msg = $_POST["msg"];



    $msgname = pg_escape_string($db, $msgname);
    $msgphone = pg_escape_string($db, $msgphone);
    $msgmail = pg_escape_string($db, $msgmail);
    $msg = pg_escape_string($db, $msg);

    echo $msg;

    date_default_timezone_set('UTC');
    $date = date("Y-m-d");

        if(!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/", $msgmail)){
        // Return Error - Invalid Email
        $error = 'The email you have entered is invalid, please try again.';
    } else
      {

    $sql ="INSERT INTO js_core.m_hospital_messages (hm_name, hm_phone, hm_email, hm_message, hm_date, hm_hp_id)VALUES 
    ('$msgname', '$msgphone', '$msgmail', '$msg', '$date' '$hosp_id')";

    $query = pg_query($db,$sql);

    if($query){

    $to      = $hosp_email; // Send email to our user
    $subject = 'Daktari247 | Hospital Message'; // Give the email a subject 
    $message = $msg . "\r\n" . "from:" . $msgname . "\r\n" . "Phone No:" .  $msgphone . "\r\n" . "Email Adrress:" . $msgmail; // Our message above including the link

    $headers = $msgmail . "\r\n"; // Set from headers
    mail($to, $subject, $message, $headers); // Send our email
    }

     }
}

?>

0 个答案:

没有答案