Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- include "init.php";
- $id = trim( $_POST["id"] );
- if( $id != "" )
- {
- // Is postback
- $name = trim( $_POST["name"] );
- $address = trim( $_POST["address"] );
- $email = trim( $_POST["email"] );
- $phone = trim( $_POST["phone"] );
- $name = utf8_encode($name);
- $address = utf8_encode($address);
- $email = utf8_encode($email);
- $phone = utf8_encode($phone);
- $name = $conn->real_escape_string($name);
- $address = $conn->real_escape_string($address);
- $email = $conn->real_escape_string($email);
- $phone = $conn->real_escape_string($phone);
- $sql = "UPDATE sct_schools SET name='".$name."', address='".$address."', email='".$email."', phone='".$phone."' WHERE id=".$id.";";
- //echo $sql;
- if( $conn->query($sql) === TRUE )
- {
- header('Location: showschool.php?id='.$id);
- die();
- }
- else
- {
- die("Error in update school information query: ".$sql);
- }
- }
- include "header.php";
- ?><h1>Rediger skole</h1><?
- $sql = "SELECT * FROM sct_schools WHERE id=".$_GET["id"].";";
- $result = $conn->query($sql);
- if( $result->num_rows > 0 )
- {
- $school = $result->fetch_assoc();
- ?>
- <form action="editschool.php" method="post">
- <input type="hidden" name="id" id="id" value="<? echo $_GET["id"]; ?>"/>
- <table class="form">
- <tr>
- <th>Skole/institution</th>
- <td><input type="text" name="name" id="name" value="<? echo htmlspecialchars(utf8_decode($school["name"])); ?>"/></td>
- </tr>
- <tr>
- <th>Adresse</th>
- <td><textarea rows="5" name="address" id="address"><? echo htmlspecialchars(utf8_decode($school["address"])); ?></textarea></td>
- </tr>
- <tr>
- <th>E-mail</th>
- <td><input type="text" name="email" id="email" value="<? echo htmlspecialchars(utf8_decode($school["email"])); ?>"/></td>
- </tr>
- <tr>
- <th>Telefon</th>
- <td><input type="text" name="phone" id="phone" value="<? echo htmlspecialchars(utf8_decode($school["phone"])); ?>"/></td>
- </tr>
- <tr>
- <th></th>
- <td><input type="submit" value="Gem"/><button onclick="location.href='mergeschools.php?id=<? echo $id ?>';">Flet</button></td>
- </tr>
- </table>
- </form>
- <?
- }
- include "footer.php";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement