send_mail.php 3.61 KB
<?PHP 
//*****************************************************************************
//* 
//* プログラム名:め〜るNiポン
//* プログラムID:menu.php
//* 機能        :ASP管理用メニュー(ユーザー一覧)
//* 作成者      :Y.Hamaya(MTC)
//* 
//*****************************************************************************

  header("Content-type: text/html; charset=EUC-JP");
  include("include/allinc.inc");
  
  $sql = "SELECT * FROM mail_body_tbl ";
  $sql .= "ORDER BY seq";
  $rtn = pg_exec($pg_con, $sql);
  if($rtn == false){
    echo "SQLの実行に失敗しました。(#1)";
    exit;
  }
  $num = pg_numrows($rtn);
?>
<HTML>
<HEAD>
<META name="GENERATOR" content="Microsoft FrontPage 4.0">
<META http-equiv="Content-Type" content="text/html; charset=EUC-JP">
<META http-equiv="Content-Style-Type" content="text/css">
<TITLE>め〜るNiポン 〜ASP管理〜</TITLE>
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function View(flg){
	//window.open('./mail_body.php?seq='+document.forms[0].mail_body[document.forms[0].mail_body.selectedIndex].value , '' , '');
	if(flg==2){
		document.forms[0].action = "mail_body.php?seq="+document.forms[0].mail_body[document.forms[0].mail_body.selectedIndex].value;
	}else{
		document.forms[0].action = "mail_body.php?seq=0";
	}
	document.forms[0].method="POST";
	document.forms[0].submit();
}

function reView(){
	document.forms[0].action = "send_mail.php?seq="+document.forms[0].mail_body[document.forms[0].mail_body.selectedIndex].value+"&select="+document.forms[0].select[document.forms[0].select.selectedIndex].value;
	document.forms[0].method="POST";
	document.forms[0].submit();
}

-->
</SCRIPT>
</HEAD>
<body>
<div align="center"><strong><font color="blue" size="5">お知らせメール送信</font></strong></div>
<HR>
<div align="center"><br>
  <br>
<form action="send_mail2.php" method="POST">
  <table border="1">
    <tr>
      <th  scope="col">送信先一覧方法*</th>
      <th  scope="col"><div align="left">
        <select name="select">
            <option value="1" <?PHP  if($select==1){echo "selected";}?>>ユーザー登録数1名以下</option>
            <option value="2" <?PHP  if($select==2){echo "selected";}?>>1ヶ月間未ログイン者</option>
            <option value="3" <?PHP  if($select==3){echo "selected";}?>>全件</option>
        </select>
      </div></th>
    </tr>
    <tr>
      <th scope="col">メール本文*</th>
      <th scope="col"><div align="left">
        <select name="mail_body" onChange="reView();">
<?PHP     
  for ($i = 0; $i < $num; $i++){
    $data = pg_fetch_object($rtn, $i);
?>
          <option value=<?PHP  echo $data->seq;?> <?PHP  if($data->seq==$seq){echo "selected";} ?>><?PHP  echo $data->name; ?></option>
<?PHP  } 

  if($seq==""){$seq=1;}
  $sql2 = "SELECT * FROM mail_body_tbl ";
  $sql2.= "where seq=".$seq;
  $rtn2 = pg_exec($pg_con, $sql2);
  if($rtn2 == false){
    echo "SQLの実行に失敗しました。(#1)";
    exit;
  }
  $data2 = pg_fetch_object($rtn2, 0);	 

?>
        </select>
        <input type="button" name="Mail_View" value="修正" onclick="return View(2)">
        <input type="button" name="Mail_View" value="追加" onclick="return View(1)">
      </div></th>
    </tr>
    <tr>
      <th height="17" scope="col">タイトル</th>
      <th align="left" scope="col"><input name="title" type="text" size="50" value="<?PHP  echo $data2->title; ?>" readonly></th>
    </tr>
    <tr>
      <th valign="top" scope="col">本文</th>
      <th valign="top" align="left" scope="col"><textarea name="body" cols="80" rows="20" readonly><?PHP  echo $data2->body; ?></textarea><div align="left">
</div></th>
    </tr>
    </table>
</div>
<p align="center">
  <input type="submit" name="Submit" value="次へ">
</p>
</form>
</body>
</HTML>