Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (isset($_POST['Submit']))://if admin wants to edit category
- $h1 = $_POST['h1'];
- $text = $_POST['text'];
- $servername = "localhost";
- $username = "user";
- $password = "password";
- $dbname = "dbname";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- // Prepare statement
- $stmt = $conn->prepare('UPDATE sections (h1, text) values (:h1, :text) WHERE id=1');
- $stmt->bindParam(':h1', $h1);
- $stmt->bindParam(':text', $text);
- // execute the query
- $stmt->execute();
- // echo a message to say the UPDATE succeeded
- echo $stmt->rowCount() . " records UPDATED successfully";
- }
- catch(PDOException $e)
- {
- echo $sql . "<br>" . $e->getMessage();
- }
- $conn = null;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement