e-card code with PHP and MySQL

Source: Internet
Author: User
Tags php and mysql
First step: First make a form like the following: (Note: This form is in the PHP program)
<form method= "POST" action= "mailtocard.php" name= "card" onsubmit= "return Card_validator (This)" >
<table width= "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= ">"
<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= "Audition 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)
{
Determine whether to login, if you have logged on display name and email, do not fill in.
$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//judgment not logged in, need to fill in 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" > Friends 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" onclick= "previewing ()" >
<input type= "Submit" name= "submit" value= "Send" >
<input type= "reset" name= "Submit3" value= "Redo" >
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-Greeting Cards </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= "" 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" onclick= "Javascript:window.close ()" Name= "Close" value= "Close Window" >
</div>

</td>
</tr>
</table>
</form>
</body>
Step three: Send a greeting card
<?
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-min");
$roundno = Date ("Mdhis");
$fileno. = $roundno. ". HTML ";
$fileurl = $dataurl. " /". $fileno; Store the URL of the resulting greeting card

$subject = "Greeting card sent to you by friends";
$content = Eregi_replace ("<br>", "\ n", "$text");

$t _body. = "**************************************\n";
$t _body. = $f _name. "Hello: \ n";
$t _body. = $g _username. "I sent you a greeting card from http://lyjrich.oso.com.cn. \ n ";
$t _body. = $g _username. " To your message said: \ n ". $text." \ n ";
$t _body. = "Please click Http://lyjrich.oso.com.cn/card". $fileurl. "to enjoy this card \ n";
$t _body. = "The longest card will be saved for one months. \ n ";
$t _body. = "\n************************************\n";
$t _body. = "Send time $daten \ n";
$t _body. = "**************************************\n\n";
$t _body. = "Free e-Greeting card provided by your Web site \n\n\n";
$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 (\" Send success, thank you for using!! \ ");</script>";

$message = "<title> e-Greeting Cards </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= ' 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 ("Build file Error! ");;
Fwrite ($fp, $message);
Fclose ($FP);


?>

  • Related Article

    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.