Introduction: This is a detailed page of e-card code using PHP and MySQL. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 323733 'rolling = 'no'>
Step 1: first make the following form: (Note: the PHP program is added to this form)
<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>
& Lt; TD valign = "TOP" width = "143" & gt;
<Input type = "radio" name = "inout" value = "newyear" Checked>
</TD>
& Lt; TD width = "170" & gt;
<Input type = "radio" name = "inout" value = "newyear2_2">
</TD>
& Lt; TD width = "137" & gt;
<Input type = "radio" name = "inout" value = "newyear3_3">
</TD>
</Tr>
<Tr>
<TD valign = "TOP" colspan = "3">
<Textarea name = "text" rows = "7" Cols = "60" Wrap = "virtual"> Hello friend:
</Textarea>
</TD>
</Tr>
<Tr>
<TD valign = "TOP" colspan = "3">
<Select name = "Music">
<Option selected> -- card background music -- </option>
<Option value = "101marry. Mid"> One Thousand and One Nights </option>
<Option value = "Canyon. Mid"> Canyon </option>
</SELECT>
<Input onclick = playsound () type = button value = "Try Music">
</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>
& Lt; TD width = "108" & gt;
<?
If (strlen ($ g_username)> 1)
{
// Determine whether to log on. If you have logged on to the system, you do not need to enter the name and email.
$ 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 // you need to enter your name and email to determine if you have not logged on to else.
{
Echo "<Div align = 'left'> your name: </div>
</TD>
<TD width = '000000'>
<Input type = 'text' name = 'username'>
</TD>
</Tr>
<Tr>
<TD width = '000000'>
<Div align = 'left'> your email: </div>
</TD>
<TD width = '000000'>
<Input type = 'text' name = 'email '> ";
}
?>
</TD>
</Tr>
<Tr>
& Lt; TD width = "108" & gt;
<Div align = "Left"> friend name: </div>
</TD>
& Lt; TD width = "342" & gt;
<Input type = "text" name = "f_name">
</TD>
</Tr>
<Tr>
& Lt; TD width = "108" & gt;
<Div align = "Left"> friend Email: </div>
</TD>
& Lt; TD width = "342" & gt;
<Input type = "text" name = "f_email">
</TD>
</Tr>
<Tr>
<TD width = "108"> </TD>
& Lt; TD width = "342" & gt;
<Input type = "button" name = "Submit" value = "preview" onclick = "Preview ()">
<Input type = "Submit" name = "Submit" value = "send">
<Input type = "reset" name = "submit3" value = "">
Step 2: preview
<?
If (submit = "preview ")
{
Switch ($ new)
{
Case "newyear ":
$ New = "newyear.gif ";
Break;
Case "newyear2_2 ":
Optional querymedianewyear2_2.gif;
Break;
Case "newyear3_3 ":
Optional querymedianewyear3_3.gif;
Break;
}
}
?>
<HTML>
<Head>
<Title> e-cards </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 "
</Div>
</TD>
</Tr>
<Tr>
& Lt; TD width = "317" valign = "TOP" & gt;
<P> <font size = "3" color = "# ff0066"> dear friend, </font> <br>
<Br>
<Font size = "2" color = "# 3333ff">
<? Echo $ text;?>
</Font> </P>
</TD>
& Lt; TD width = "180" valign = "TOP" & gt;
<Div align = "right">
<Table width = "90%" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<TD>
<P> <font size = "3" color = "# ff0066"> sent 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"> friends: </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>
</Html>
Step 3: send greeting cards
<?
If (submit = "send ")
$ Mainurl = "http://lyjrich.oso.com.cn/card"; // The Home Directory URL of the greeting card file
$ Dataurl = "$ mainurl/Store"; // the URL of the generated greeting card.
$ Userip = getenv ("remote_addr ");
$ Daten = date ("m month D day H point I ");
$ Roundno = date ("mdhis ");
$ Fileno. = $ roundno. ". html ";
$ Fileurl = $ dataurl. "/". $ fileno; // The URL for storing the generated Greeting Card
$ Subject = "greeting cards mailed to you by a friend ";
$ Content = eregi_replace ("<br>", "\ n", "$ text ");
$ T_body. = "************************************** \ n ";
$ T_body. = $ f_name. "Hello, \ n ";
$ T_body. = $ g_username. "sent you a greeting card from the http://lyjrich.oso.com.cn. \ N ";
$ T_body. = $ g_username. "The message says \ n". $ text. "\ n ";
$ T_body. = "Please click http://lyjrich.oso.com.cn/card". $ fileurl. "To enjoy this card \ n ";
$ T_body. = "the greeting card is saved for up to one month. \ N ";
$ T_body. = "\ n ************************************ \ n ";
$ T_body. = "sending time $ Daten \ n ";
$ T_body. = "************************************** \ n ";
$ T_body. = "free e-cards are provided by the your web site \ 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 (\" sent successfully. Thank you !! \ "); </SCRIPT> ";
$ Message = "<HTML>
<Head>
<Title> e-cards </title>
<Meta http-equiv = 'content-type' content = 'text/html; charset = gb2312 '>
</Head>
<Body bgcolor = '# eeeeee'>
<Table width = '000000' border = '0' cellspacing = '0' cellpadding = '0' align = 'center' Height = '20150'>
<Tr>
<TD colspan = '2'>
<Div align = 'center'>
</Div>
</TD>
</Tr>
<Tr>
<TD width = '000000' valign = 'top'>
<P> <font size = '3' color = '# ff0066'> dear friend, </font> <br>
<Br>
<Font size = '2' color = '# 3333ff'>
$ Text
</Font> </P>
</TD>
<TD width = '000000' valign = 'top'>
<Div align = 'right'>
<Table width = '000000' border = '0' cellspacing = '0' cellpadding = '0'>
<Tr>
<TD>
<P> <font size = '3' color = '# ff0066'> sent 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 friends: </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/export roundno.html", "W +") or die ("file creation error! ");;
Fwrite ($ FP, $ message );
Fclose ($ FP );
?>
Run the program in my website http://lyjrich.oso.com.cn, if you have any questions about the program can mail me: lyjrich@sina.com
More articles on "using PHP and MySQL e-card code"
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/323733.html pageno: 16.