麻辣家族討論版版's Archiver

小誌 發表於 2011-4-24 15:12

13-2-2 程式完整列表

[color=DarkRed][size=4][b]13-2-2   程式完整列表[/b][/size][/color]
Index.htm[code]<html>

<head>
<title>電子賀卡-來站取卡</title>
</head>

<body background=bg.gif>

<p><font color=#800000 size=4><b>電子賀卡</b></font>-來站取卡</p>
<hr>
<form method=POST action=viewcard.php>
<div align=center>
<table border=0 id=table1 style=font-size: 10pt>
<tr>
<td>寄件人:</td>
<td><input type=text name=fromname size=20></td>
<td>寄件信箱:</td>
<td><input type=text name=fromemail size=40></td>
</tr>
<tr>
<td>收件人:</td>
<td><input type=text name=toname size=20></td>
<td>收件信箱:</td>
<td><input type=text name=toemail size=40></td>
</tr>
<tr>
<td>訊息:</td>
<td colspan=3><textarea rows=6 name=message cols=71></textarea></td>
</tr>
<tr>
<td>賀卡:</td>
<td colspan=3> <table border=0 width=100% id=table2>
<tr>
<td>
<input type=radio value=2.jpg name=card checked>
<img border=0 src=2.jpg width=180 height=133 align=left>
</td>
<td>
<input type=radio value=9.jpg name=card>
<img border=0 src=9.jpg width=180 height=134 align=left>
</td>
<td>
<input type=radio name=card value=16.jpg>
<img border=0 src=16.jpg width=180 height=134 align=left>
</td>
</tr>
<tr>
<td>
<input type=radio name=card value=11.gif>
<img border=0 src=11.gif width=180 height=136 align=left>
</td>
<td>
<input type=radio name=card value=12.jpg>
<img border=0 src=12.jpg width=180 height=134 align=left>
</td>
<td>
<input type=radio name=crad value=20.jpg>
<img border=0 src=20.jpg width=180 height=134 align=left>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan=4><input type=submit value=預覽卡片 name=B1></td>
</tr>
</table>
</div>
</form>

</body>

</html>[/code]

小誌 發表於 2011-4-24 15:13

viewcard.php[code]<?
//接收來自表單的欄位資訊
$fromName=$_REQUEST["fromName"];
$fromEmail=$_REQUEST["fromEmail"];
$toName=$_REQUEST["toName"];
$toEmail=$_REQUEST["toEmail"];
$Message=$_REQUEST["message"];
$Card=$_REQUEST["card"];

//簡易驗證收件與寄件信箱是否正確
If ((!(strpos($fromEmail,'@'))) || (!(strpos($toEmail,'@'))))
{
//Email不正確出現一個錯誤提示的JavaScript訊息視窗
      echo "<script>\n";
      echo "alert('Sorry!!Email郵件信箱填寫有誤喔!!');\n";
      echo "window.history.go(-1);\n";
      echo "</script>";
}
Else
{
?>
<html>

<head>
<title>電子賀卡-預覽賀卡</title>
</head>

<body background=bg.gif>

<p><font color=#800000 size=4><b>電子賀卡</b></font>-預覽賀卡</p>
<hr>
<!--顯示賀卡的內容供使用者確認-->
        <div align=center>
                <table border=1 id=table1 style="font-size:10pt; border-collapse:collapse" bordercolor="#000080">
                        <tr>
                                <td>收件人:<B><?=$toName;?></B><Br>
                                收件信箱:<B><?=$toEmail;?></B></td>
                        </tr>
                        <tr>
                                <td><img src="<?=$Card;?>"></td>
                        </tr>
                        <tr>
                                <td bgcolor="#CCFFFF"><?=nl2br($Message);?></td>
                        </tr>
                </table>
        </div>
<!------------------------------>
       
        <form method=POST action=ecard.php>
        <p align=center>
        <!--寄送賀卡用的隱藏欄位-->
        <input type=hidden name=fromName value="<?=$fromName;?>">
        <input type=hidden name=fromEmail value="<?=$fromEmail;?>">
        <input type=hidden name=toName value="<?=$toName;?>">
        <input type=hidden name=toEmail value="<?=$toEmail;?>">
        <input type=hidden name=message value="<?=$Message;?>">
        <input type=hidden name=card value="<?=$Card;?>">
        <!---------------------------------------->
        <input type=submit value=寄出卡片>
        <input type=button value=修改賀卡 onclick='window.history.go(-1);'></p>
        </form>

</body>

</html>
<?
}
?>[/code]

小誌 發表於 2011-4-24 15:13

ecard.php[code]<?
//接收來自表單的欄位資訊
$fromName=$_REQUEST["fromName"];
$fromEmail=$_REQUEST["fromEmail"];
$toName=$_REQUEST["toName"];
$toEmail=$_REQUEST["toEmail"];
$Message=$_REQUEST["message"];
$Card=$_REQUEST["card"];

//連結MySQL Server
    $conn = mysql_connect("localhost", "root", "12345a");
//選擇資料庫
    mysql_select_db("ecard", $conn);
//指定提取資料的校對字元表
    mysql_query("set character set big5");
//將賀卡資料寫入資料庫
$SQL="Insert Into cardinfo (fromname,fromemail,toname,toemail,message,card) values(
'$fromName','$fromEmail','$toName','$toEmail','$Message','$Card')";
mysql_query($SQL);


//設定來站取得卡片的網頁網址位置
$httpUrl=$_SERVER["SERVER_NAME"];
$basUrl=$_SERVER["PHP_SELF"];
$Pos=strrpos($basUrl,'/');
$basUrl=substr($basUrl,0,$Pos);
$CardID=mysql_insert_id($conn);
$CardUrl="http://" . $httpUrl . $basUrl ."/getcard.php?CardID=" . $CardID;

//讀取卡片領取通知的網頁內容
$fs=fopen("mail.htm","r");
$body=fread($fs,filesize("mail.htm"));
fclose($fs);

//置換卡片領取通知信件的內容
$body=str_replace("{name}", $toName, $body);
$body=str_replace("{email}", $toEmail, $body);
$body=str_replace("{url}", $CardUrl, $body);

//建一個名為$Mail的Message物件
$Mail = new COM("CDONTS.NewMail");

//設定信件內容
$Mail->From=$fromEmail;
$Mail->To=$toName . "<" . $toEmail . ">";
$Mail->Subject=$fromName . "挑了一張卡片寄給你,快看喔!";
$Mail->Body=$body;
$Mail->BodyFormat=0;
$Mail->MailFormat=0;

//送出信件
$Mail->Send();
       
        //告知賀卡已經寄出,返回賀卡選擇頁面       
      echo "<script>\n";
      echo "alert('恭喜你!!賀卡已經順利寄出!!');\n";
      echo "window.location='index.htm';\n";
      echo "</script>\n";
               
?>[/code]

小誌 發表於 2011-4-24 15:14

getcard.php[code]<?
$CardID=$_REQUEST["CardID"];

//連結MySQL Server
    $conn = mysql_connect("localhost", "root", "12345a");
//選擇資料庫
    mysql_select_db("ecard", $conn);
//指定提取資料的校對字元表
    mysql_query("set character set big5");
//提取資料
$SQL="Select * from cardinfo where cardid=" . $CardID;
$RS=mysql_query($SQL);
?>
<html>

<head>
<title>電子賀卡-領取賀卡</title>
</head>

<body background=bg.gif>

<p><font color=#800000 size=4><b>電子賀卡</b></font>-領取賀卡</p>
<hr><Center>
<?
if ($cardinfo=mysql_fetch_array($RS))
{
?>
        <div align=center>
                <table border=1 id=table1 style="font-size:10pt; border-collapse:collapse" bordercolor="#000080">
                        <tr>
                                <td>寄件人:<B><?=$cardinfo["fromname"];?></B><Br>
                                寄件信箱:<B><?=$cardinfo["fromemail"];?></B></td>
                        </tr>
                        <tr>
                                <td><img src="<?=$cardinfo["card"];?>"></td>
                        </tr>
                        <tr>
                                <td bgcolor="#CCFFFF"><?=nl2br($cardinfo["message"]);?></td>
                        </tr>
                </table>
        </div>
<?
}
Else
{
?>
<p align="center"><font color="#FF0000"><b>找不到卡片,此賀卡可能已經被刪除了!!</b></font></p>
<?
}
?>       

        <input type=button value=我也要寄賀卡 onclick="window.location='index.htm'"></p>

</body>

</html>[/code]

頁: [1]

麻辣家族討論版版為 麻辣學園 網站成員  由 昱得資訊工作室 © Since 1993 所提供