ReginaRay

Untitled

Jan 16th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.30 KB | None | 0 0
  1. <?php
  2. require "admin.php";
  3. ?>
  4.  
  5.  
  6. <?php
  7.  
  8. include ('../db.php');
  9. if(!empty($_POST['save'])) {
  10.    
  11.         $about = htmlspecialchars($_POST['about']);
  12.         $phone1 = htmlspecialchars($_POST['phone1']);
  13.         $phone2 = htmlspecialchars($_POST['phone2']);
  14.         $open = htmlspecialchars($_POST['open']);
  15.         $close = htmlspecialchars($_POST['close']);
  16.         $mail = htmlspecialchars($_POST['mail']);
  17.      
  18.    
  19.     $sql = " UPDATE contacts SET  
  20.                       about = '$about',
  21.                       phone1 = '$phone1',
  22.                       phone2 = '$phone2',
  23.                       open = '$open',
  24.                       close = '$close',
  25.                       mail = '$mail'
  26.                ";
  27.      
  28.      $query = mysqli_query($connection, $sql);
  29.    
  30.     if ($query) { //если данные отправлены выводим:
  31.             echo 'Запись обновлена';
  32.         }
  33.         else {
  34.             echo 'Ошибка! Запись не обновлена.';
  35.         }
  36.  }
  37.  ?>
  38.  
  39. <form action="contactsred.php" method="post">
  40.     <?php
  41.     include ('../db.php');
  42.    
  43.     if(isset($_GET['redid_id'])){
  44.        
  45.         $ss = 'SELECT * FROM `contacts` WHERE `id` = '.$_GET['redid_id'];
  46.         $sql = mysqli_query($connection, $ss);
  47.         $result = mysqli_fetch_assoc($sql);    
  48.        
  49.     echo'
  50.    <table>
  51.        <tr>
  52.            <td>about</td>
  53.            <td><input type="text" name="about" value="'.$result['about'].'"></td>
  54.        </tr>
  55.         <tr>
  56.            <td>phone1</td>
  57.            <td><input type="tel" name="phone1" value="'.$result['phone1'].'"></td>
  58.        </tr>
  59.        <tr>
  60.            <td>phone2</td>
  61.            <td><input type="tel" name="phone2" value="'.$result['phone2'].'"></td>
  62.        </tr>
  63.         <tr>
  64.            <td>open</td>
  65.            <td><input type="time" name="open" value="'.$result['open'].'"></td>
  66.        </tr>
  67.        <tr>
  68.            <td>close</td>
  69.            <td><input type="time" name="close" value="'.$result['close'].'"></td>
  70.        </tr>
  71.        <tr>
  72.            <td>mail</td>
  73.            <td><input type="email" name="mail" value="'.$result['mail'].'"></td>
  74.        </tr>
  75.      
  76.        <tr>
  77. <td><input type="submit" name="save" value="Сохранить">   </td>
  78. </tr>
  79. </table>
  80. </form>';
  81.     }
  82.     ?>
Add Comment
Please, Sign In to add comment