<?php
session_start() ;
if(!session_is_registered("login_true_admin")) {
echo "<meta http-equiv='refresh' content='0 ;url=index.php'>" ;
exit() ;
}
	
	include("../config.inc.php");
mysql_select_db($db) ;
$sql = "select * from mail" ;
$result = mysql_query($sql) ;
$row = mysql_num_rows($result) ;
$dbarr = mysql_fetch_array($result) ;

?>


<html>
<head>
<title>Mail for member</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>

<body bgcolor="#000000" link="#FF9900" vlink="#FFCC00" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<p>&nbsp;</p>
<p align="center"><img src="../image/admin.gif" width="200" height="50"></p>
<p align="center"><font size="3" face="MS Sans Serif, Tahoma, sans-serif"><strong><img src="../image/sendmail.gif" width="17" height="15" border="0" align="absmiddle">&nbsp;<font color="#FFCC00">Email 
  for member &nbsp;</font></strong></font></p>
<table width="400" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#9999FF">
  <tr bgcolor="#9933CC"> 
    <td colspan="2" bgcolor="#FF9900"> 
    <div align="center"><font color="#000000" size="3" face="MS Sans Serif, Tahoma, sans-serif"><strong>อีเมล์อวยพรวันเกิด</strong></font></div></td>
  </tr>
<tr> 
    <td bgcolor="#FFCC00"><font size="3" face="MS Sans Serif, Tahoma, sans-serif">หัวข้อ</font></td>
    <td bgcolor="#FFCC00"> <font size="3" face="MS Sans Serif, Tahoma, sans-serif"> 
      <?php
if($row==0) {
echo "<center>ยังไม่มีข้อความอยู่ในฐานข้อมูลครับ</center>" ;
}

else {
echo $dbarr['subject'] ;
}

?>
      </font></td>
  </tr>

  <tr> 
    <td bgcolor="#FFCC00"><font size="3" face="MS Sans Serif, Tahoma, sans-serif">ข้อความ</font></td>
    <td bgcolor="#FFCC00"> <font size="3" face="MS Sans Serif, Tahoma, sans-serif"> 
      <?php
if($row==0) {
echo "<center>ยังไม่มีข้อความอยู่ในฐานข้อมูลครับ</center>" ;
}
else {
echo $dbarr['form_mail'] ;
}


?>
      </font></td>
  </tr>
  <tr>     <form name="form1" method="post" action="program_mail.php">
    <td colspan="2" bgcolor="#FFCC00"><div align="center">
    
          <input name="sendmail" type="submit" id="sendmail" value="ส่งอีเมล์">
          &nbsp; 
          <input name="edit" type="submit" id="edit" value="แก้ไข,เพิ่มเติม">
          <input name="click" type="hidden" id="click" value="click">
       
      </div></td>
  </form> </tr>
</table>
<p align="center"><font color="#666600" size="2" face="MS Sans Serif, Tahoma, sans-serif">...................................................................................................................................................................<br>
  </font></p>
<form action="program_mail.php" method="post" name="checkForm2" onSubmit="return check()">
  <table width="450" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CC99FF">
    <tr bgcolor="#66CC99"> 
      <td colspan="2" bgcolor="#669900"> 
        <div align="center"><font color="#000000" size="3" face="MS Sans Serif, Tahoma, sans-serif"><strong><img src="../image/member.gif" width="24" height="24" border="0" align="absmiddle">&nbsp;ส่งอีเมล์หาสมาชิกทุกคน 
          <font size="2">(ข้อความทั่วไป)</font></strong></font></div></td>
    </tr>
    <tr bgcolor="#FFECFF"> 
      <td valign="middle" bgcolor="#D7FF82"><font size="3" face="MS Sans Serif, Tahoma, sans-serif">หัวข้อ 
        </font></td>
      <td bgcolor="#D7FF82"> 
        <input name="subject_total" type="text" id="subject_total" size="50" maxlength="120">      </td>
    </tr>
    <tr bgcolor="#FFECFF"> 
      <td bgcolor="#D7FF82"><font size="3" face="MS Sans Serif, Tahoma, sans-serif">ข้อความ</font></td>
      <td bgcolor="#D7FF82"><font size="3" face="MS Sans Serif, Tahoma, sans-serif">
        <textarea name="message_total" cols="55" rows="10" id="message_total"></textarea>
      </font></td>
    </tr>
    <tr> 
      <td colspan="2" bgcolor="#66CC00"><div align="center">
          <input type="submit" name="Submit" value="ส่งอีเมล์">
          &nbsp;
          <input type="reset" name="Submit2" value=" เคลียร์ ">
          <input name="click" type="hidden" id="click" value="click">
        </div></td>
    </tr>
  </table>
<script language="javascript">
function check() {
var v1 = document.checkForm2.subject_total.value ;
var v2 = document.checkForm2.message_total.value ;
if(v1.length == 0) {
alert("กรุณากรอกหัวข้อของอีเมล์ด้วยครับ") ;
document.checkForm2.subject_total.focus();
return false ;
}
else if(v2.length==0) {
alert("กรุณากรอกข้อความที่ต้องการส่งด้วยครับ") ;
document.checkForm2.message_total.focus() ;
return false ;
}
else 
return true ;
}

</script>
</form>
<p align="center"><font size="2" face="MS Sans Serif, Tahoma, sans-serif"></font><font size="3" face="MS Sans Serif, Tahoma, sans-serif"><a href="menu.php">กลับสู่หน้าหลัก</a></font></p>
<p align="center">&nbsp;</p>

</body>
</html>
