Advertisement
ReginaRay

Untitled

Jan 16th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.64 KB | None | 0 0
  1. <?php
  2. require "admin.php";
  3. ?>
  4. <?php
  5.  
  6. include ('../db.php');
  7. if(!empty($_POST['save'])) {
  8.    
  9.         $name = htmlspecialchars($_POST['name']);
  10.         $cat_id = htmlspecialchars($_POST['cat_id']);
  11.         $allcat_id = htmlspecialchars($_POST['allcat_id']);
  12.         $atribute = htmlspecialchars($_POST['atribute']);
  13.         $opis = htmlspecialchars($_POST['opis']);
  14.         $image1 = htmlspecialchars($_POST['image1']);
  15.         $image2 = htmlspecialchars($_POST['image2']);
  16.         $longopis = htmlspecialchars($_POST['longopis']);
  17.         $price = htmlspecialchars($_POST['price']);
  18.         $price1 = htmlspecialchars($_POST['price1']);
  19.         $pric2 = htmlspecialchars($_POST['price2']);
  20.         $madein = htmlspecialchars($_POST['madein']);
  21.      
  22.     $tov = $_GET['id'];
  23.     $sql = " UPDATE products SET  
  24.                       name = '$name',
  25.                       cat_id = '$cat_id',
  26.                       allcat_id = '$allcat_id',
  27.                       atribute = '$atribute',
  28.                       opis = '$opis',
  29.                       image1 = '$image1',
  30.                       image2 = '$image2',
  31.                       longopis = '$longopis',
  32.                       price = '$price',
  33.                       price1 = '$price1',
  34.                       price2 = '$price2',
  35.                       madein = '$madein'
  36.            WHERE id = '$tov'
  37.            
  38.            ";
  39.    
  40.  
  41.      $query = mysqli_query($connection, $sql);
  42.    
  43.     if ($query) { //если данные отправлены выводим:
  44.             echo 'Запись обновлена';
  45.         }
  46.         else {
  47.             echo 'Ошибка! Запись не обновлена.';
  48.         }
  49.  }
  50.  ?>
  51.  <?php
  52.     include ('../db.php');
  53.    
  54.     if(isset($_GET['red_id'])){
  55.        
  56.         $ss = 'SELECT * FROM `products` WHERE `id` = '.$_GET['red_id'];
  57.         $sql = mysqli_query($connection, $ss);
  58.         $result = mysqli_fetch_assoc($sql);    
  59.    
  60. echo '<form action="red.php?id='.$result['id'].'" method="post">';
  61.        
  62.     echo'
  63.    <table>
  64.        <tr>
  65.            <td>Наименование</td>
  66.            <td><input type="text" name="name" value="'.$result['name'].'"></td>
  67.        </tr>
  68.         <tr>
  69.            <td>id категории</td>
  70.            <td><input type="number" name="cat_id" value="'.$result['cat_id'].'"></td>
  71.        </tr>
  72.        <tr>
  73.            <td>Общая категория</td>
  74.            <td><input type="number" name="allcat_id" value="'.$result['allcat_id'].'"></td>
  75.        </tr>
  76.         <tr>
  77.            <td>Атрибут</td>
  78.            <td><input type="number" name="atribute" value="'.$result['atribute'].'"></td>
  79.        </tr>
  80.        <tr>
  81.            <td>Фото 1</td>
  82.            <td><input type="file" name="image1" value="'.$result['image1'].'"></td>
  83.        </tr>
  84.        <tr>
  85.            <td>Фото 2</td>
  86.            <td><input type="file" name="image2" value="'.$result['image2'].'"></td>
  87.        </tr>
  88.      
  89.        
  90.        <tr>
  91.            <td>Краткое описание продукта</td>
  92.            <td><textarea rows="5" cols="25" type="text"  name="opis">
  93.            '.$result['opis'].'</textarea></td>
  94.        </tr>
  95.         <tr>
  96.            <td>Описание продукта</td>
  97.            <td><textarea rows="5" cols="35" type="text"  name="longopis">'.$result['longopis'].'</textarea></td>
  98.        </tr>
  99.        <tr>
  100.            <td>Цена</td>
  101.            <td><input type="number" name="price" value="'.$result['price'].'"></td>
  102.        </tr>
  103.         <tr>
  104.            <td>Цена</td>
  105.            <td><input type="number" name="price1" value="'.$result['price1'].'"></td>
  106.        </tr>
  107.         <tr>
  108.            <td>Цена</td>
  109.            <td><input type="number" name="price2" value="'.$result['price2'].'"></td>
  110.        </tr>
  111.        <tr>
  112.            <td>производитель</td>
  113.            <td><input type="text" name="madein" value="'.$result['madein'].'"></td>
  114.        </tr>
  115.        <tr>
  116. <td><a href=""><input type="submit" name="save" value="Сохранить">   </td>
  117. </tr>
  118. </table>
  119. </form>';
  120.     }
  121.     ?>
  122.  
  123.  
  124.  
  125. <?php
  126.     /*
  127. include ('../db.php');
  128. if (isset($_POST['save'])){
  129.     $name = htmlspecialchars($_POST['name']);
  130.     $cat_id = htmlspecialchars($_POST['cat_id']);
  131.     $allcat_id = htmlspecialchars($_POST['allcat_id']);
  132.     $atribute = htmlspecialchars($_POST['atribute']);
  133.     $opis = htmlspecialchars($_POST['opis']);
  134.     $image1 = htmlspecialchars($_POST['image1']);
  135.     $image2 = htmlspecialchars($_POST['image2']);
  136.     $longopis = htmlspecialchars($_POST['longopis']);
  137.     $price = htmlspecialchars($_POST['price']);
  138.     $price1 = htmlspecialchars($_POST['price1']);
  139.     $pric2 = htmlspecialchars($_POST['pric2']);
  140.     $madein = htmlspecialchars($_POST['madein']);
  141.  
  142.     $sql = "UPDATE `products` SET
  143.                        name = '$name',
  144.                        cat_id = '$cat_id',
  145.                        allcat_id = '$allcat_id',
  146.                        atribute = '$atribute',
  147.                        opis = '$opis',
  148.                        image1 = '$image1',
  149.                        image2 = '$image2',
  150.                        longopis = '$longopis',
  151.                        price = '$price',
  152.                        price1 = '$price1',
  153.                        price2 = '$price2',
  154.                        madein = '$madein'
  155.                         ";
  156.    
  157.    
  158.     $query = mysqli_query($connection, $sql);
  159.    
  160.     if ($query) { //если данные отправлены выводим:
  161.             echo 'Запись обновлена';
  162.         }
  163.         else {
  164.             echo 'Ошибка! Запись не обновлена.';
  165.         }
  166. }*/
  167. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement