addemail.php
<! DOCTYPE HTML> <HTML lang = "CN" the dir = "LTR"> <head> <Meta charset = "UTF-. 8"> <title> Elvis Stores - add a mailbox </ title> <Link the rel = "this stylesheet "the href =" the style.css "> </ head> <body> <IMG the src =" blankface.jpg "width =" 161 "height =" 350 "Alt =" "style =" a float: right "> <IMG name = "elvislogo" src = "elvislogo.gif" width = "229" height = "32" border = "0" alt = "the Make Me Elvis"> <the p-> E-mail and add your name to the <strong> Elvis stores </ strong> email list. </ P> < = $_POST['email']; $output_form = 'no'; if (empty($name) || empty($email)) { echo '请完整填写要求的内容.<br />'; $output_form = 'yes'; } } else { $output_form = 'yes'; } if(!empty($name)&&!empty($email)){ $dbc = mysqli_connect( '127.0.0.1', 'root', '', 'elvis_store' ) or Die ( 'MySQL link failure.' ); $ Query . = "INSERT INTO EMAIL_LIST (name, Email)" "VALUES ( ' $ name ' , ' $ Email ') " ; mysqli_query ( $ DBC , $ Query ) or Die ( 'failure to add data.' ); echo 'customer information is added to complete. ' ; Mysqli_close ( $ DBC ); } IF ( $ output_form ==' Yes' ) { ?> ['PHP_SELF'] ?>" method="post"> <label for="NAME">姓名:</label> <input type="text" name="name" id="name"><br> <label for="email">邮箱地址:</label> <input type="text" name="email" id="name"><br> <input type="submit" name="submit" value="提交"> </form> <?php } ?> </body> </html>
sendemail.php
<! DOCTYPE HTML> <HTML lang = "CN" the dir = "LTR"> <head> <Meta charset = "UTF-. 8"> <title> Elvis Stores - E-mail </ title> << Link the rel = " this stylesheet "the href =" the style.css "> </ head> <body> <IMG the src =" blankface.jpg "Alt =" cop "width =" 161 "height = " 350 "style =" float: right "> <img src = "elvislogo.gif" alt = " Elvis store" name = "elvislogo" width = "229" height = "32" border = "0"> <P> <strong> private: </ strong> Elmer use only <br> write and send e-mail to members of the list of mailboxes. </ p>; $subject = $_POST['subject']; $text = $_POST['elvismail']; $output_form = false; if (empty($subject) && empty($text)) { // We know both $subject AND $text are blank echo '你忘记输入邮件的标题和内容。<br>'; $output_form = true; } if (empty($subject) && (!empty(text $ ))) { echo 'you forget to enter the message header <br>' ; $ output_form = to true ; } IF ! (( empty ( $ Subject )) && empty ( $ text )) { echo 'you forget to enter the message body. <br> ' ; $ output_form = to true ; } } the else { $ output_form = to true ; } IF ! (( empty ( $ Subject !)) && ( empty (text $ ))) { $ DBC = mysqli_connect ( '127.0.0.1', 'the root', '', 'elvis_store' ) or Die ( 'MySQL link failure'. ); $ Query = "the FROM EMAIL_LIST the SELECT *" ; $ Result = the mysqli_query ( $ DBC , $ query ) or Die ( 'queries the database failed.' ); the while ( $ Row = mysqli_fetch_array ( $ Result )) { $ name = $ Row [ 'name' ]; $ MSG = "Dear$name ,\n $text"; $to = $row['email']; mail($to, $subject, $msg, 'From:'.$from); echo '邮件发送到了:'.$to.'<br>'; } mysqli_close($dbc); } if ($output_form) { ?> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> <label = "Subject"> e-mail title: </ label> <br>for <input type="text" name="subject" id="subject" size="30"><br> <label for="elvismail">邮件的内容:</label><br> <textarea name="elvismail" id="elvismail" rows="8" cols="40"></textarea><br> <input type="submit" name="Submit" value="提交"> </form> <?php } ?> </body> </html>
removeemail.php
<!DOCTYPE html> <html lang="cn" dir="ltr"> <head> <meta charset="utf-8"> <title>猫王商店 - 删除邮箱</title> <link rel="stylesheet" href="style.css"> </head> <body> <img src="blankface.jpg" alt="黑脸" width="161" height="350" style="float:right"> <img src="elvislogo.gif" alt="猫王logo" width="229" height="32" name="elvislogo" border="0"> <p>输入你想要移除的邮箱。</p> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <?php $dbc = mysqli_connect('127.0.0.1','root','','elvis_store') or die( 'Link MySQL fail.' ); IF ( isset ( $ _POST [ 'Submit' ])) { the foreach ( $ _POST [ 'todelete'] AS $ $ Delete ) { $ Query = "the DELETE the FROM EMAIL_LIST the WHERE ID = $ delete_id0 " ; mysqli_query ( $ DBC , $ query ) or Die ( 'failed to query the database.' ); } echo " customer mailbox've done <br>. " ; } $ query =" the FROM EMAIL_LIST the SELECT * " ; $result = mysqli_query($dbc, $query) or die('查询数据库失败。'); while($row = mysqli_fetch_array($result)){ echo '<input type="checkbox" value="' .$row['id']. '" name="todelete[]">'; echo "$row['name']"; echo "$row['email']"; echo "<br>"; } mysqli_close($dbc); ?> <input type="submit" name="submit" value="Remove" /> </form> </body> </html>