Advertisement
Guest User

Untitled

a guest
Jun 6th, 2015
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.19 KB | None | 0 0
  1. <?
  2.  
  3.     include "init.php";
  4.  
  5.     $id = trim( $_POST["id"] );
  6.  
  7.     if( $id != "" )
  8.     {
  9.         // Is postback
  10.  
  11.         $name    = trim( $_POST["name"] );
  12.         $address = trim( $_POST["address"] );
  13.         $email   = trim( $_POST["email"]   );
  14.         $phone   = trim( $_POST["phone"]   );
  15.        
  16.         $name    = utf8_encode($name);
  17.         $address = utf8_encode($address);
  18.         $email   = utf8_encode($email);
  19.         $phone   = utf8_encode($phone);
  20.        
  21.         $name    = $conn->real_escape_string($name);
  22.         $address = $conn->real_escape_string($address);
  23.         $email   = $conn->real_escape_string($email);
  24.         $phone   = $conn->real_escape_string($phone);
  25.        
  26.         $sql = "UPDATE sct_schools SET name='".$name."', address='".$address."', email='".$email."', phone='".$phone."' WHERE id=".$id.";";
  27.         //echo $sql;
  28.         if( $conn->query($sql) === TRUE )
  29.         {
  30.             header('Location: showschool.php?id='.$id);
  31.             die();
  32.         }
  33.         else
  34.         {
  35.             die("Error in update school information query: ".$sql);
  36.         }
  37.     }
  38.  
  39.     include "header.php";
  40.     ?><h1>Rediger skole</h1><?
  41.  
  42.     $sql = "SELECT * FROM sct_schools WHERE id=".$_GET["id"].";";
  43.     $result = $conn->query($sql);
  44.     if( $result->num_rows > 0 )
  45.     {
  46.         $school = $result->fetch_assoc();
  47. ?>
  48.     <form action="editschool.php" method="post">
  49.         <input type="hidden" name="id" id="id" value="<? echo $_GET["id"]; ?>"/>
  50.         <table class="form">
  51.             <tr>
  52.                 <th>Skole/institution</th>
  53.                 <td><input type="text" name="name" id="name" value="<? echo htmlspecialchars(utf8_decode($school["name"])); ?>"/></td>
  54.             </tr>
  55.             <tr>
  56.                 <th>Adresse</th>
  57.                 <td><textarea rows="5" name="address" id="address"><? echo htmlspecialchars(utf8_decode($school["address"])); ?></textarea></td>
  58.             </tr>
  59.             <tr>
  60.                 <th>E-mail</th>
  61.                 <td><input type="text" name="email" id="email" value="<? echo htmlspecialchars(utf8_decode($school["email"])); ?>"/></td>
  62.             </tr>
  63.             <tr>
  64.                 <th>Telefon</th>
  65.                 <td><input type="text" name="phone" id="phone" value="<? echo htmlspecialchars(utf8_decode($school["phone"])); ?>"/></td>
  66.             </tr>
  67.             <tr>
  68.                 <th></th>
  69.                 <td><input type="submit" value="Gem"/><button onclick="location.href='mergeschools.php?id=<? echo $id ?>';">Flet</button></td>
  70.             </tr>
  71.         </table>
  72.     </form>
  73. <?
  74.     }
  75.     include "footer.php";
  76. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement