用php与mysql的电子贺卡程序

  • 作者:未知 来源:未知 添加时间:2006年7月2日 字体:

  • 第一步:首先作一个如下面的表单:(注:这个表单里加了php程序)

    <form method="post" action="mailtocard.php" name="card" onsubmit="return card_validator(this)">

    <table width="450" border="0" cellspacing="0" cellpadding="0" align="center">

    <tr>

    <td valign="top" width="143">

    <input type="radio" name="inout" &#118alue="newyear" checked>

    <img src="http://www.1fanwen.com/files/beyondpic/2005-12/8/0512815375690054.gif"; width="75" height="75"> </td>

    <td width="170">

    <input type="radio" name="inout" &#118alue="newyear2_2">

    <img src="http://www.1fanwen.com/files/beyondpic/2005-12/8/0512815375656548.gif"; width="75" height="75"> </td>

    <td width="137">

    <input type="radio" name="inout" &#118alue="newyear3_3">

    <img src="http://www.1fanwen.com/files/beyondpic/2005-12/8/0512815375690054.gif"; width="75" height="75"> </td>

    </tr>

    <tr>

    <td valign="top" colspan="3">

    <textarea name="text" rows="7" cols="60" wrap="virtual">你好朋友:

    </textarea>

    </td>

    </tr>

    <tr>

    <td valign="top" colspan="3">

    <select name="music">

    <option selected>--卡片背景音乐--</option>

    <option &#118alue="101marry.mid">一千零一夜</option>

    <option &#118alue="canyon.mid">canyon</option>

    </select>

    <input &#111nclick=playsound() type=button &#118alue="试听音乐">

    </td>

    </tr>

    <tr>

    <td valign="top" colspan="3"> </td>

    </tr>

    <tr>

    <td valign="top" colspan="3">

    <table width="370" border="0" cellspacing="0" cellpadding="0" align="center" class="p11">

    <tr>

    <td width="108">



    <@



    if (strlen($g_username) > 1)

    {

    /判断是否登陆,若已登陆显示姓名及email,不用填写。

    $db=mysql_connect("localhost","root","");

    $result=mysql_db_query("数据库名","select email,http from 数据库表名 where username='$g_username'");



    $row=mysql_fetch_array($result);

    $bbs_email=$row[email;



    echo "<div align='left'>您的姓名:</div>

    </td>

    <td width=342>

    $g_username

    <input type=hidden name=username &#118alue=$g_username>

    </td>

    </tr>

    <tr>

    <td width=108>

    <div align=hidden>您的email:</div>

    </td>

    <td width=342>

    $bbs_email

    <input type=hidden name=email &#118alue=$bbs_email>



    ";

    }

    /if (strlen($g_username) < 0)

    else /判断没有登陆,需要填写姓名及email。

    {

    echo "<div align='left'>您的姓名:</div>

    </td>

    <td width='342'>



    <input type='text' name='username'>

    </td>

    </tr>

    <tr>

    <td width='108'>

    <div align='left'>您的email:</div>

    </td>

    <td width='342'>



    <input type='text' name='email'>";

    }

    @>

    </td>

    </tr>

    <tr>



    <td width="108">

    <div align="left">朋友姓名:</div>

    </td>

    <td width="342">

    <input type="text" name="f_name">

    </td>

    </tr>

    <tr>

    <td width="108">

    <div align="left">朋友email:</div>

    </td>

    <td width="342">

    <input type="text" name="f_email">

    </td>

    </tr>

    <tr>

    <td width="108"> </td>

    <td width="342">



    <input type="button" name="submit" &#118alue="预览" &#111nclick="preview()">

    <input type="submit" name="submit" &#118alue="发送">

    <input type="reset" name="submit3" &#118alue="重来">

    第二步:预览

    <@



    if (submit=="预览")

    {

    switch($new)

    {

    case "newyear":



    $new="newyear.gif";

    break;



    case "newyear2_2":



    $query=newyear2_2.gif;

    break;



    case "newyear3_3":

    $query=newyear3_3.gif;

    break;



    }

    }

    @>

    <html>

    <head>

    <title>电子贺卡</title>

    <meta http-equiv="content-type" content="text/html; charset=gb2312">

    </head>



    <body bgcolor="#eeeeee">

    <form method="post" action="mailtocard.php">

    <table width="497" border="0" cellspacing="0" cellpadding="0" align="center" height="310">

    <tr>

    <td colspan="2">

    <div align="center">



    <@ echo "<img src="http://www.1fanwen.com/files/beyondpic/2005-12/8/0512815375685627.gif";>"; @>





    </div>

    </td>

    </tr>

    <tr>

    <td width="317" valign="top">

    <p><font size="3" color="#ff0066">您好朋友:</font>





    <font size="2" color="#3333ff">



    <@ echo $text; @>

    </font></p>



    </td>

    <td width="180" valign="top">

    <div align="right">

    <table width="90%" border="0" cellspacing="0" cellpadding="0">

    <tr>

    <td>

    <p><font size="3" color="#ff0066">寄卡给:</font><font size="2">


    </font></p>

    <p><font color="#3300cc" size="2"><@ echo $f_name; @>

    <input type=hidden name=f_name &#118alue=$f_name>

    </font></p>

    <p><font size="3" color="#ff0066">您的朋友:</font></p>

    <p><font size="2" color="#3300cc">

    <@ echo $g_username; @>

    <input type=hidden name=username>

    <input type=hidden name=f_email &#118alue="$femail">

    <input type=hidden name=email>



    </font></p>

    </td>

    </tr>

    </table>

    </div>

    </td>

    </tr>

    <tr>

    <td colspan="2" valign="top">



    <div align="center">

    <input type="submit" name="submit" &#118alue="发送">

    <input type="button" &#111nclick="javascript:window.close()" name="close" &#118alue="关闭窗口">

    </div>



    </td>

    </tr>

    </table>

    </form>

    </body>

    </html>

    第三步:发送贺卡

    <@

    if(submit=="发送")



    $mainurl = "http://lyjrich.oso.com.cn/card";; /该贺卡文件主目录url

    $dataurl = "$mainurl/store"; /存放产生的贺卡的url

    $userip = getenv("remote_addr");

    $daten = date("m月d日h点i分");

    $roundno = date("mdhis");

    $fileno .=$roundno.".html";

    $fileurl = $dataurl."/".$fileno; /存放产生的贺卡的url



    $subject="朋友给你邮的贺卡";

    $content = eregi_replace("
    ","\n","$text");



    $t_body .= "**************************************\n";

    $t_body .= $f_name." 您好:\n";

    $t_body .= $g_username." 从http://lyjrich.oso.com.cn 寄了一张贺卡给你。\n";

    $t_body .= $g_username."给您的留言上说:\n".$text ."\n\n";

    $t_body .= "请你点击http://lyjrich.oso.com.cn/card";.$fileurl." 来欣赏这张贺卡\n";

    $t_body .= "贺卡最长将为你保存一个月。\n\n";

    $t_body .= "\n************************************\n";

    $t_body .= "发送时间 $daten\n";

    $t_body .= "**************************************\n\n";

    $t_body .= "免费电子贺卡由 your web 网站提供\n\n\n";

    $t_body .= "程序制作:lyjrich(http://lyjrich.oso.com.cn)\n";





    mail($f_email,$subject,$t_body,"from: ".$email."\n");



    echo "<script language=\"javascript\">history.back();alert(\"发送成功,谢谢使用!!\");</script>";



    $message ="<html>

    <head>

    <title>电子贺卡</title>

    <meta http-equiv='content-type' content='text/html; charset=gb2312'>

    </head>



    <body bgcolor='#eeeeee'>

    <table width='497' border='0' cellspacing='0' cellpadding='0' align='center' height='310'>

    <tr>

    <td colspan='2'>

    <div align='center'>



    <img src="http://www.1fanwen.com/files/beyondpic/2005-12/8/0512815375648370.gif";>





    </div>

    </td>

    </tr>

    <tr>

    <td width='317' valign='top'>

    <p><font size='3' color='#ff0066'>您好朋友:</font>





    <font size='2' color='#3333ff'>



    $text

    </font></p>



    </td>

    <td width='180' valign='top'>

    <div align='right'>

    <table width='90%' border='0' cellspacing='0' cellpadding='0'>

    <tr>

    <td>

    <p><font size='3' color='#ff0066'>寄卡给:</font><font size='2'>


    </font></p>

    <p><font color='#3300cc' size='2'>$f_name

    <input type=hidden name=f_name &#118alue=$f_name>

    </font></p>

    <p><font size='3' color='#ff0066'>您的朋友:</font></p>

    <p><font size='2' color='#3300cc'>

    $g_username

    <input type=hidden name=username>

    <input type=hidden name=f_email &#118alue='$femail'>

    <input type=hidden name=email>



    </font></p>

    </td>

    </tr>

    </table>

    </div>

    </td>

    </tr>

    <tr>

    <td colspan='2' valign='top'>





    </td>



    </table>



    </body>

    </html>";



    $mydir=dir("./store/");

    $fp = fopen ("store/$roundno.html","w+") or die("建立文件错误!");;

    fwrite ($fp, $message);

    fclose ($fp);





    @>

    运行程序可在本人网站http://lyjrich.oso.com.cn,若对程序有疑问可发mail给我:lyjrich@sina.com

  • 上一篇:挑战最棒的留言本的源码(一)
  • 下一篇:浅谈Windows下 PHP4.0与oracle 8的连接设置
  • 最后更新时间:2024年12月22日
  • 返回页面顶端
ppdesk