Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: Aleksandar Veljanov
- * Date: 07.11.2016
- * Time: 20:57
- */
- $dns = 'mysql:host=127.0.0.1;dbname=praktikum131088';
- $username = 'root';
- $password='';
- $pdo = new PDO($dns, $username, $password);
- $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- if(isset($_POST['submit_news'])){
- $title = $_POST['title'];
- $content = $_POST['content'];
- echo $title;
- echo $content;
- if($title != '' && $content != ''){
- $date = new DateTime();
- $time_string = $date->format('Y-m-d H:i:s');
- $ps = $pdo->prepare("INSERT INTO news (date, news_title, full_text) VALUES (:date, :title, :content)");
- $ps->bindParam(':date', $time_string);
- $ps->bindParam(':title', $title);
- $ps->bindParam(':content', $content);
- $ps->execute();
- echo 'you have submitted your news';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement