e-card program with PHP and MySQL

Source: Internet
Author: User
mysql| Program

The first step: Make a form like the following: (Note: This form has a PHP program added)
<form method= "POST" action= "mailtocard.php" name= "card" >
<table width= "450" border= "0" cellspacing= "0" cellpadding= "0" align= "center" >
<tr>
&LT;TD valign= "Top" width= "143" >
<input type= "Radio" name= "InOut" value= "NewYear" checked>
</td>
&LT;TD width= "170" >
<input type= "Radio" name= "InOut" value= "Newyear2_2" >
</td>
&LT;TD width= "137" >
<input type= "Radio" name= "InOut" value= "Newyear3_3" >
</td>
</tr>
<tr>
&LT;TD valign= "Top" colspan= "3" >
<textarea name= "Text" rows= "7" cols= "wrap=" "VIRTUAL" > Hello friends:
</textarea>
</td>
</tr>
<tr>
&LT;TD valign= "Top" colspan= "3" >
<select name= "Music" >
<option selected>--card background music--</option>
<option value= "101marry.mid" > 1001 Nights </option>
<option value= "Canyon.mid" >canyon</option>
</select>
<input onclick=playsound () Type=button value= "Listening to music" >
</td>
</tr>
<tr>
&LT;TD valign= "Top" colspan= "3" > </td>
</tr>
<tr>
&LT;TD valign= "Top" colspan= "3" >
<table width= "370" border= "0" cellspacing= "0" cellpadding= "0" align= "center" class= "P11" >
<tr>
&LT;TD width= "108" >

?

if (strlen ($g _username) > 1)
{
To determine whether to log in, if you have landed display name and email, do not fill out.
$db =mysql_connect ("localhost", "root", "");
$result =mysql_db_query ("Database name", "Select Email,http from database table name where username= ' $g _username '");

$row =mysql_fetch_array ($result);
$bbs _email= $row [email];

echo "<div align= ' left ' > your name:</div>
</td>
<TD width=342>
$g _username
<input type=hidden name=username value= $g _username>
</td>
</tr>
<tr>
<TD width=108>
<div align=hidden> your email:</div>.
</td>
<TD width=342>
$bbs _email
<input type=hidden name=email value= $bbs _email>

";
}
if (strlen ($g _username) < 0)
else//judge does not login, need to fill in the name and email.
{
echo "<div align= ' left ' > your name:</div>
</td>
<TD width= ' 342 ' >

<input type= ' text ' name= ' username ' >
</td>
</tr>
<tr>
<TD width= ' 108 ' >
<div align= ' left ' > your email:</div>
</td>
<TD width= ' 342 ' >

<input type= ' text ' name= ' email ' > ';
}
?>
</td>
</tr>
<tr>

<TD width= "108" >
<div align= "left" > friend name:</div>
</td>
<TD width= "342" >
<input type= "text" name= "F_name" >
</td>
</tr>
<tr>
<TD width= "108" >
<div align= "left" > Friend 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= "Preview" >
<input type= "Submit" name= "submit" value= "Send" >
<input type= "reset" name= "Submit3" value= "Again" >
Step Two: Preview
?

if (submit== "preview")
{
Switch ($new)
{
Case "NewYear":

$new = "Newyear.gif";
Break

Case "Newyear2_2":

$query =newyear2_2.gif;
Break

Case "Newyear3_3":
$query =newyear3_3.gif;
Break

}
}
?>
<title> e-card </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">

<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 " ";?>


</div>
</td>
</tr>
<tr>
<TD width= "317" valign= "Top" >
<p><font size= "3" color= "#FF0066" > Hello friend:</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" > Send card to: </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" > Your friend:</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= "Send" >
<input type= "button" name= "Close" value= "Closing Window" >
</div>

</td>
</tr>
</table>
</form>
</body>
Step three: Send greeting cards
?
if (submit== "send")

$mainurl = "Http://lyjrich.oso.com.cn/card"; The Greeting card file home directory URL
$dataurl = "$mainurl/store"; Store the URL of the resulting greeting card
$userip = getenv ("REMOTE_ADDR");
$daten = Date ("M-month D-day H point I-points");
$roundno = Date ("Mdhis");
$fileno. = $roundno. " HTML ";
$fileurl = $dataurl. " /". $fileno; Store the URL of the resulting greeting card

$subject = "Friends send you a greeting card";
$content = Eregi_replace ("<br>", "\ n", "$text");

$t _body. = "**************************************\n";
$t _body. = $f _name. "Hello: \ n";
$t _body. = $g _username. "A greeting card was sent to you from http://lyjrich.oso.com.cn. \ n ";
$t _body. = $g _username. " I said to your message: \ n ". $text." \ n ';
$t _body. = "Please click Http://lyjrich.oso.com.cn/card". $fileurl. "To appreciate this card \ n";
$t _body. = "The longest greeting card will be kept for you for one months." \ n ';
$t _body. = "\n************************************\n";
$t _body. = "Send time $daten \ n";
$t _body. = "**************************************\n\n";
$t _body. = "Free E-card provided \n\n\n by your Web site";
$t _body. = "Program production: Lyjrich (http://lyjrich.oso.com.cn) \ n";


Mail ($f _email, $subject, $t _body, "from:" $email. " \ n ");

echo "<script language=\" javascript\ ">history.back (); alert (\" sent successfully, thanks for using!! \ ");</script>";

$message = "<title> e-card </title>
<meta http-equiv= ' content-type ' content= ' text/html; charset=gb2312 ' >

<body bgcolor= ' #eeeeee ' >
<table width= ' 497 ' border= ' 0 ' cellspacing= ' 0 ' cellpadding= ' 0 ' align= ' center ' height= ' 310 ' >
<tr>
<TD colspan= ' 2 ' >
<div align= ' center ' >


</div>
</td>
</tr>
<tr>
<TD width= ' 317 ' valign= ' top ' >
<p><font size= ' 3 ' color= ' #FF0066 ' > Hello friend:</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 ' > Send card to: </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 ' > Your friend:</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>

$mydir =dir ("./store/");
$fp = fopen ("store/$roundno. html", "w+") or Die ("Create file Error!") ");;
Fwrite ($fp, $message);
Fclose ($FP);


?>




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.