php ile benim db olarak çoğaltılması kullanıcıların önlemek için nasıl

0 Cevap php

Nasıl tüm vardır,

, burada her biri Tamam umut

şimdi ben yönetici kullanıcılar yaratabilirsiniz bir form var ve beni ilk kodunu görüntülemek izin gibi o kullanıcıları silebilirsiniz

Bu benim kodudur

> > <?php error_reporting(E_ALL);
> 
> session_start();
>   if(!isset($_SESSION['login']) ||
> $_SESSION['login']!='1' )         {
>       header("Location:loginpage.php");
>       } ?>
> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD
> XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html
> xmlns="http://www.w3.org/1999/xhtml">
> <head> <meta http-equiv="Content-Type"
> content="text/html; charset=utf-8" />
> <title>My Control panel</title> <link
> href="../css_style.css"
> rel="stylesheet" type="text/css" />
> </head>
> 
> 
> 
> <body> <div id="werpper"> <div
> id="content">
> 
> <div id="header">My control -
> Panel</div> <div id="body_cntent">  
> <div id="left_side">   <p>Home and
> instructions</p>   <p><a
> href="../control_panel.php">main
> directory</a></p>   <p><a
> href="add_event.php">Add new
> event</a></p>   <p><a
> href="../editoccasion.php">Control
> Occasion's</a></p>   <p><a
> href="add_photos_and_occasion.php">Add
> Photos_occasion</a></p>   <p><a
> href="../signout.php">Sign out</a></p>
> </div> <div id="right_side">
> 
> <h2>Add new user</h2>
> 
> <form action="" method="post">
> 
> <table width="600" border="0"
> cellpadding="5" cellspacing="0">  
> <tr>
>     <td width="78">User name</td>
>     <td width="2">&nbsp;</td>
>     <td width="149"><input type="text" name="uname" value="" /></td>
>     <td width="332" rowspan="5" align="left" valign="top"><p
> class="red">For Administration use
> only.</p>
>       <p>You can add or delete users from <a
> href="edit_users.php">here</a><br />
>         You can't edit any user if you like to change any user account you
> can delete the user and create it
> again with the new
> information.</p></td>   </tr>   <tr>
>     <td>Password</td>
>     <td>&nbsp;</td>
>     <td><input type="text" name="pass" value="" /></td>
>     </tr>   <tr>
>     <td>&nbsp;</td>
>     <td>&nbsp;</td>
>     <td><input type="submit" name="submit" value="Add user" /></td>
>     </tr>   <tr>
>     <td>&nbsp;</td>
>     <td>&nbsp;</td>
>     <td>&nbsp;</td>
>     </tr>   <tr>
>     <td>&nbsp;</td>
>     <td>&nbsp;</td>
>     <td align="right">&nbsp;</td>
>     </tr> </table> </form>
> 
> </div> </div>
> 
> <div id="footer"></div> </div> </div>
> 
> <?php
>       if (isset($_POST['submit'])) {
>               include_once "../config/config.php";
>               $uname = $_POST['uname'];       $pass =$_POST['pass'];
>               $check = "select * from users where id = {$uname}";         $result_check
> = $db->query($check)or die($db->error);
>       
>               while ($row = $result_check -> fetch_object()) {
>                       if(num_rows == 1){
>               
>               echo "error";
>               
>               }else{
>               $add_user = "insert into users (id, uname, pass) values ('',
> '$uname', '$pass')";
>               $result = $db -> query($add_user) or die ("$db->error");
>               if ($result) {
>                       echo "user added successfuly";
>                       }else{
>               
>               echo "There was an error please try again later";
>               
>               }           }       }   } ?>
> 
> </body> </html>

Bilmem burada gereken bu kod sorunu çözmek için nasıl

$check = "select * from users where id = {$uname}";
        $result_check = $db->query($check)or die($db->error);


        while ($row = $result_check -> fetch_object()) {

            if(num_rows == 1){

                echo "error";

                }

nasıl benim db çoğaltılması kullanıcıları önleyebilirsiniz

0 Cevap