2017-04-03 45 views
0

我正在一個聯繫表格的網站上工作,但即時通訊想知道如何我可以收到表中的信息。下面的代碼是當用戶點擊發布按鈕時發生的情況。 ,我接受它像receiving mail發送信息從一個表中的網站

if($_SERVER['REQUEST_METHOD'] == 'POST') { 
if($_POST['template-contactform-email'] != '') { 

    $name = isset($_POST['template-contactform-name']) ? $_POST['template-contactform-name'] : ''; //navn 
    $email = isset($_POST['template-contactform-email']) ? $_POST['template-contactform-email'] : ''; //epost 
    $adress = isset($_POST['template-contactform-email']) ? $_POST['template-contactform-email'] : ''; //epost adresse 
    $phone = isset($_POST['template-contactform-phone']) ? $_POST['template-contactform-phone'] : ''; //telefonnummer 
    $datetime1 = isset($_POST['template-contactform-datetime']) ? $_POST['template-contactform-datetime'] : ''; //dato og tid 


    $service = isset($_POST['template-contactform-service']) ? $_POST['template-contactform-service'] : ''; //1 
    $service1 = isset($_POST['template-contactform-service1']) ? $_POST['template-contactform-service1'] : ''; //2 
    $service2 = isset($_POST['template-contactform-service2']) ? $_POST['template-contactform-service2'] : '';//3 
    $message = isset($_POST['template-contactform-message']) ? $_POST['template-contactform-message'] : '';//kundemeldinger. 
    //avhukningsbokser 
    $checkbox1 = isset($_POST['checkbox-1']) ? $_POST['checkbox-1'] : ''; 
    $checkbox2 = isset($_POST['checkbox-2']) ? $_POST['checkbox-2'] : ''; 

    $subject = isset($subject) ? $subject : 'New Message From Contact Form'; 

    $botcheck = $_POST['template-contactform-botcheck']; 

    if($botcheck == '') { 

     $mail->SetFrom($email , $name); 
     $mail->AddReplyTo($email , $name); 
     foreach($toemails as $toemail) { 
      $mail->AddAddress($toemail['email'] , $toemail['name']); 
     } 
     $mail->Subject = "Bestilling fra hjemmeside"; 

     $name = isset($name) ? "Name: $name<br><br>" : ''; 
      $adress = isset($adress) ? "Adress:  $adress<br><br>" : ''; 
     $email = isset($email) ? "Phone:      $email<br><br>" : ''; 
     $phone = isset($phone) ? "Telefon:      $phone<br><br>" : ''; 
     $datetime1 = isset($datetime1) ? "Dato og tidspunkt: $datetime1<br><br>" : ''; 
     $service = isset($service) ? "Additional people:  $service<br><br>" : ''; 
     $service1 = isset($service1) ? "Sorted waste:   $service1<br><br>" : ''; 
     $service2 = isset($service2) ? "Payment method:   $service2<br><br>" : ''; 

     //avhukning start 
     $checkbox1 = isset($checkbox1) ? "Papp og tekstil: $checkbox1<br><br>" : ''; 
     $checkbox2 = isset($checkbox2) ? "Metaller og ror og tilsvarende: $checkbox2<br><br>" : ''; 

     //avhukning stopp 
     $message = isset($message) ? "Additional info:   $message<br><br>" : ''; 

     $referrer = $_SERVER['HTTP_REFERER'] ? '<br><br><br>Denne eposten kommer fra bestillingskjema via ' . $_SERVER['HTTP_REFERER'] : ''; 

     $body = "$name $email $phone $datetime1 $service $service1 $service2 $info $checkbox1 $checkbox2<br>$message $referrer"; 

回答

0

你必須建立一個表像這樣..

對於每個變量環繞在td的價值觀和tr像下面

$name = isset($name) ? "<tr><td>Name</td><td>$name</td></tr>" : ''; 
    $email = isset($email) ? "<tr><td>Phone</td><td>$email</td></tr>" : ''; 

終於成立在table內部的tr以上版本,你很好去。如果您需要款式,請爲table設置inline款式。

$body = "<table>$name $email ...</table>"; 
+0

非常感謝您的幫助,似乎是工作,去看看如何了一下後做的樣式:) – Andreas