News System (Publish, delete, modify)

Source: Internet
Author: User

1. Registration Form and verification

<form action= "login.php" method= "POST" > user name:<input type= "text" name= "uname"/> <br> Password: <input type= "password" name= "pwd"/> <br> <input type= "Submit" Name= "sub" value= "User Login"/> <inp UT type= "Submit" Name= "Sub1" value= "admin login"/> <input type= "Submit" Name= "Sub2" value= "register"/></form>

Login Verification

<?PHPHeader("Content-type:text/html;charset=utf-8");if(isset($_post["Sub"])){Try {@$pdo=NewPDO ("Mysql:hostname=localhost;dbname=news", "root", "123456");//it was a mistake.}Catch(Exception $e) {Echo"Connection failed."$e-getMessage ();}Try {$name=$_post[' uname '];$pwd=MD5($_post[' pwd ']);//$STATM = $pdo->prepare ("INSERT into login (uname,pwd) value (' 222 ', ' 222 ')");$STATM=$pdo->prepare ("SELECT * from login where uname=:name and pwd=:p WD");$STATM->bindparam (': Name ',$name);$STATM->bindparam (':p wd ',$pwd);$STATM-execute ();$c=$STATM-RowCount ();if($c>=1){Header(' Location:kehu.php ');}Else {Echo"<script type= ' text/javascript ' >alert (' Login failed! ');</script> ";}} Catch(Exception $e) {Echo"Login failed."$e-getMessage ();}}

Registered users

1 if(isset($_post["Sub2"])){2 Try {3@$pdo=NewPDO ("Mysql:hostname=localhost;dbname=news", "root", "123456");//it was a mistake.4}Catch(Exception $e) {5 Echo"Connection failed."$e-getMessage ();6 }7 Try {8 $name=$_post[' uname '];9 $pwd=MD5($_post[' pwd ']);Ten $STATM=$pdo->prepare ("INSERT INTO Login" (uname,pwd) value (: Name,:p wd) "); One $STATM->bindparam (': Name ',$name); A $STATM->bindparam (':p wd ',$pwd); - $c=$STATM-execute (); - if($c){ the Echo"<script type= ' text/javascript ' >alert (' registered success! ');</script> "; - } -}Catch(Exception $e) { - Echo"Registration failed."$e-getMessage (); + } -}

Delete:

if($_get[' Del ']){                Try {                    @$pdo=NewPDO ("Mysql:hostname=localhost;dbname=news", "root", "123456");//it was a mistake.}Catch(Exception $e) {                    Echo"Connection failed."$e-GetMessage (); }                Try {                    $STATM 4=$pdo->prepare ("SELECT * from WZ"); $STATM 4-execute (); $c=$STATM 4-Fetchall (); foreach($c  as $k=$v){                        Echo"<li>"; Echo"<a href= ' http://192.168.20.200/news/kehu.php?bs=$v[id] ' >{$v[Biaot]} </a> "; Echo"<a href= ' http://192.168.20.200/news/home1.php?del=4&deli=$v[id] ' >&nbsp; delete! </a> "; Echo"</li>"; }                } Catch(Exception $e) {                    Echo"Query failed."$e-GetMessage (); }                if($_get[' Deli ']){                    Try {                        $id=$_get[' Deli ']; $STATM 5=$pdo->prepare ("Delete from wz where id=:i"); $STATM 5->bindparam (': I ',$id); $c=$STATM 5-execute (); } Catch(Exception $e) {                        Echo"Failed".$e-GetMessage (); }                }            }

Release:

if($_get[' Add ']){                Echo"<form action= ' home1.php ' method= ' post ' ><br>"; Echo"Title: <input name= ' title ' type= ' text '/><br><br>"; Echo"<textarea name= ' content ' style= ' width:300px;height:300px;border:1px solid black ' ></textarea><br ><br> "; Echo"<input name= ' Sub ' type= ' Submit '/>"; Echo"</form>"; }            if(isset($_post[' Sub '])){                Try {                    @$pdo=NewPDO ("Mysql:hostname=localhost;dbname=news", "root", "123456");//it was a mistake.}Catch(Exception $e) {                    Echo"Connection failed."$e-GetMessage (); }                Try {                    $title=$_post[' title ']; $content=$_post[' Content ']; $STATM 1=$pdo->prepare ("INSERT into WZ (biaot,wcontent) value (: B,:C)"); $STATM 1->bindparam (': B ',$title); $STATM 1->bindparam (': C ',$content); $c=$STATM 1-execute (); } Catch(Exception $e) {                    Echo"Failed".$e-GetMessage (); }            }

News System (Publish, delete, modify)

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.