2017-05-02 48 views
0

我有一個問題,我是新手,我不認爲我很瞭解,我應該怎麼做呢?顯示從頁面的消息到另一個使用PHP和HTML表單

我有3個文件,contact.html,mail.php,afisare.php!

contact.html

<form class="uk-form uk-form-stacked" method="post" action="mail.php"> 

         <div class="uk-form-row"> 
          <label class="uk-form-label">Your Name</label> 
          <div class="uk-form-controls"> 
           <input type="text" name="nume" placeholder="" class="uk-width-1-1"> 
          </div> 
         </div> 

         <div class="uk-form-row"> 
          <label class="uk-form-label">Your Email</label> 
          <div class="uk-form-controls"> 
           <input type="text" name="email" placeholder="" class="uk-width-1-1"> 
          </div> 
         </div> 

         <div class="uk-form-row"> 
          <label class="uk-form-label">Your Message</label> 
          <div class="uk-form-controls"> 
           <textarea name="mesaj" class="uk-width-1-1" id="form-h-t" cols="100" rows="9"></textarea> 
          </div> 
         </div> 

         <div class="uk-form-row"> 
          <div class="uk-form-controls"> 
           <button class="uk-button uk-button-primary">Submit</button> 
          </div> 
         </div> 

        </form> 

mail.php

<?php 
$admin_email = "serban[email protected]"; 
$nume = $_POST['nume']; 
$email = $_POST['email']; 
$mesaj = $_POST['mesaj']; 


if (!$nume ||!$email||!$mesaj) die ("Completati toate campurile!"); 

else { 

echo "Numele: ".$nume."<br>"; 
echo "E-mail: ".$email."<br>"; 
echo "Mesaj: ".$mesaj."<br>"; 

echo "<p>Salut ".$nume."!<br>Mesajul tau: "".$mesaj."" a fost trimis la adresa ".$email.".</p>"; 

} 


mail($admin_email, "Formular contact", $mesaj, "De la".$email); 

?> 

afisare.html

<div class="uk-vertical-align uk-text-center uk-height-1-1"> 
     <div class="uk-vertical-align-middle" style="width: 250px;"> 

      <img class="uk-margin-bottom" width="140" height="120" src="images/logo.jpg" alt=""> 

      <form class="uk-panel uk-panel-box uk-form"> 
       <div class="uk-form-row"> 
        <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Nume"> 
       </div> 
       <div class="uk-form-row"> 
        <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Email"> 
       </div> 
       <div class="uk-form-row"> 
        <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Mesaj"> 
       </div> 
      </form> 

     </div> 
    </div> 

什麼,我想我做的s顯示在afisare.html,來自的信息contact.html使用mail.php

而我很困惑...我不認爲我完全理解我能做到這一點!

+0

解釋你的意思是顯示聯繫。聯繫人只是一個html文件,它不是由任何東西填充? – clearshot66

+0

Contact.html是一個頁面,我完成的信息,如發件人的電子郵件,發件人名稱和發件人的郵件,我想打印這些在afisare.html使用mail.php ... –

+0

它並不真的那樣工作...你可以將contact.html表單的行爲設置爲afisare,發送這些$ _POST變量,然後通過包含它來運行mail.php? – clearshot66

回答

0

試試這樣說: 填寫contact.html ...發送變量和數據在asfire.html

頂部asfire.html運行郵件更改您的文件擴展名.PHP

或者你也可以包括'email.php';在像<?php include 'email.php'; ?> asfire.html的頂部,而不是具有asfire.html

Contact.html頂端的碼, - > Contact.php

<form class="uk-form uk-form-stacked" method="post" action="asfire.html"> 

          <div class="uk-form-row"> 
           <label class="uk-form-label">Your Name</label> 
           <div class="uk-form-controls"> 
            <input type="text" name="nume" placeholder="" class="uk-width-1-1"> 
           </div> 
          </div> 

          <div class="uk-form-row"> 
           <label class="uk-form-label">Your Email</label> 
           <div class="uk-form-controls"> 
            <input type="text" name="email" placeholder="" class="uk-width-1-1"> 
           </div> 
          </div> 

          <div class="uk-form-row"> 
           <label class="uk-form-label">Your Message</label> 
           <div class="uk-form-controls"> 
            <textarea name="mesaj" class="uk-width-1-1" id="form-h-t" cols="100" rows="9"></textarea> 
           </div> 
          </div> 

          <div class="uk-form-row"> 
           <div class="uk-form-controls"> 
            <button class="uk-button uk-button-primary">Submit</button> 
           </div> 
          </div> 

         </form> 

asfire.html - > asfire.html

<?php 
$admin_email = "[email protected]"; 
$nume = $_POST['nume']; 
$email = $_POST['email']; 
$mesaj = $_POST['mesaj']; 


if (!$nume ||!$email||!$mesaj) die ("Completati toate campurile!"){ 

else { 

echo "Numele: ".$nume."<br>"; 
echo "E-mail: ".$email."<br>"; 
echo "Mesaj: ".$mesaj."<br>"; 

echo "<p>Salut ".$nume."!<br>Mesajul tau: "".$mesaj."" a fost trimis la adresa ".$email.".</p>"; 

} 


mail($admin_email, "Formular contact", $mesaj, "De la".$email); 

?> 
<div class="uk-vertical-align uk-text-center uk-height-1-1"> 
     <div class="uk-vertical-align-middle" style="width: 250px;"> 

      <img class="uk-margin-bottom" width="140" height="120" src="images/logo.jpg" alt=""> 

      <form class="uk-panel uk-panel-box uk-form"> 
       <div class="uk-form-row"> 
        <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Nume" value='<?php echo $nume; ?>'> 
       </div> 
       <div class="uk-form-row"> 
        <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Email" value='<?php echo $email; ?>' > 
       </div> 
       <div class="uk-form-row"> 
        <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Mesaj"value='<?php echo $mesaj; ?>'> 
       </div> 
      </form> 

     </div> 
    </div> 
+0

我還修復了{在你的if語句中,它是一個; – clearshot66

+0

That; s尷尬...我不能使用它:)它無法識別它爲我的.html文件中的PHP ... –

+0

我不會在xampp上運行它或某事,我忘了提及它 –

相關問題