|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
学习了六个多月PHP了,还是个新手,在这里受到了很多人的帮助,谢谢你们!mysql|法式 第一步:起首作一个以下面的表单:(注:这个表单里加了php法式)
<form method="post" action="mailtocard.php" name="card" >
<table width="450" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top" width="143">
<input type="radio" name="inout" value="newyear" checked>
<img src="http://www.pushad.com/images/newyear1.gif" width="75" height="75"> </td>
<td width="170">
<input type="radio" name="inout" value="newyear2_2">
<img src="http://www.pushad.com/images/newyear2.gif" width="75" height="75"> </td>
<td width="137">
<input type="radio" name="inout" value="newyear3_3">
<img src="http://www.pushad.com/images/newyear1.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 value="101marry.mid">一千零一夜</option>
<option value="canyon.mid">canyon</option>
</select>
<input onclick=playSound() type=button value="试听音乐">
</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 value=$g_username>
</td>
</tr>
<tr>
<td width=108>
<div align=hidden>您的Email:</div>
</td>
<td width=342>
$bbs_email
<input type=hidden name=email value=$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" value="预览" >
<input type="submit" name="submit" value="发送">
<input type="reset" name="Submit3" value="重来">
第二步:预览
<?
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=/images/".$new.".gif>"; ?>
</div>
</td>
</tr>
<tr>
<td width="317" valign="top">
<p><font size="3" color="#FF0066">您好伴侣:</font><br>
<br>
<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"><br>
</font></p>
<p><font color="#3300CC" size="2"><? echo $f_name; ?>
<input type=hidden name=f_name value=$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 value="$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" value="发送">
<input type="button" name="close" value="封闭窗口">
</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("<br>","\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.pushad.com/images/$inout.gif>
</div>
</td>
</tr>
<tr>
<td width='317' valign='top'>
<p><font size='3' color='#FF0066'>您好伴侣:</font><br>
<br>
<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'><br>
</font></p>
<p><font color='#3300CC' size='2'>$f_name
<input type=hidden name=f_name value=$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 value='$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);
?>
只要实现最基本的功能就可以了 就是可以添加留言 然后可以显示留言,然后加入管理功能 |
|