2015-08-21 97 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

相关问题