2015-08-21 100 views
-1

我是PHP的新手,我使用「save Form」按鈕創建了表。我無法將表數據保存到數據庫。當我單擊「保存表單「按鈕沒有動作表演。請幫助我。如何將html表添加到數據庫並保存

這是我Form.phtml

<div> 
    <b> Hello <?php echo $_POST["name"]; ?>!</b><br> 
    <b>Email :</b> <?php echo $_POST["email"]; ?>.<br> 
    <b>Gender :</b> <?php echo $_POST["gender"]; ?>.<br> 
    <b>Birthday :</b> 
    <?php 
    $day = $_POST['day']; 
    $month = $_POST['month']; 
    $year = $_POST['year']; 
    $date = $day."-".$month."-".$year; 
    $myDate = date("d F Y", strtotime($date)); 
    echo $myDate; 
    ?> 
    </div> 


    <form action="sendmail.php" method="post" id="vaccination-form"> 
    <div> 
<table border="1" style="width:100%"> 

    <tr> 
    <th id= "sno" style="font-family: sans-serif; font-size: 100%; font-weight: bold;" class="bg-color" width="5%">S.No</th> 
<th id= "vaccine" style="font-family: sans-serif; font-size: 100%; font-weight: bold;" class="bg-color center" width="32%">Vaccine</th>  
<th id="decsription" style="font-family: sans-serif; font-size: 100%; font-weight: bold;">Description</th> 
<th id="duedate" style="font-family: sans-serif; font-size: 100%; font-weight: bold;" class ="bg-color" width="15%">Due Date</th> 

    </tr> 
    <tr> 
    <td>1</td> 
    <tr> 
</table> 
</form> 
    <div> 
     <button type="submit" name="submit" style="margin-top: 1cm;"title="<?php echo $this->__('Save Form') ?>" value="submit "class="button"><span><span><?php echo $this->__('Save Form')?></span> </span> </button> 
</div> 

sendmail.php

<?php 
    //due dates 
    $myDate=$_POST['myDate']; 
    $dueDate=$_POST['dueDate']; 
    $rodueDate=$_POST['rodueDate']; 
    $didueDate=$_POST['didueDate']; 
    $pdueDate=$_POST['pdueDate']; 
    $hadueDate=$_POST['hadueDate']; 
    $indueDate=$_POST['indueDate']; 
    $idueDate=$_POST['idueDate']; 
    $rdueDate=$_POST['rdueDate']; 
    $vdueDate=$_POST['vdueDate']; 
    $tdueDate=$_POST['tdueDate']; 
    $hdueDate=$_POST['hdueDate']; 
    $mdueDate=$_POST['mdueDate']; 

    $email=$_POST['email']; 
    $name=$_POST['name']; 
    $to=$email; 
    $subject= "Vaccination Schedule For ".$name; 
    $message= 
    ' 
</table>'; 

// To send HTML mail, the Content-type header must be set 
    $headers = 'MIME-Version: 1.0' . "\r\n"; 
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

    $headers.= "From: [email protected]" . "\r\n" ; 
    if(mail($to, $subject, $message, $headers)) 
    { 
      echo 'Your mail has been sent successfully'; 
    } 
    else 
    { 
     echo 'Unable to send email. Please try again.'; 
    } 

?> 
+0

其中'sendmail.php'? –

+0

它位於同一文件夾中的另一個文件中。 – Mouni

+0

告訴我們你如何存儲數據? –

回答

0

我不認爲是正確的事情,但仍然認爲你需要把標籤之間的提交按鈕

+0

如果您看到代碼,您可以在代碼中找到提交按鈕。 – Mouni

+0

把它

標籤 –

+0

之間。如果我在它被重定向到sendmail.php文件表單標籤添加它。 – Mouni

1

我們展示您的sendmail.php。

主要是你需要得到POST變量到sendmail.php,然後創建一個數據插入SQL語句從POST變量了..

怎麼做上面的東西是完全以你的,有很多種方法,但是我們不能告訴你,因爲你沒有給我們足夠的關於你的系統的信息。

+0

附加sendmail.php並用於發送郵件。 – Mouni

+0

使用你的sendmail.php存儲發送的數據到數據庫。 http://www.w3schools.com/php/php_mysql_insert.asp – SubjectX

+0

我需要寫這個(或)一個新的文件,我需要在sendmail.php file.Please添加此建議我。 – Mouni

相關問題