Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Prisijungimas {
- var $host;
- var $username;
- var $password;
- var $db;
- function connect(){
- $con = mysql_connect($this->host, $this->username, $this->password)or die (mysql_error());
- mysql_select_db($this->db, $con)or die (mysql_error());
- }
- function Gavimas(){
- $sql = "SELECT * FROM tvs_content";
- $res = mysql_query($sql)or die (mysql_error());
- while($row = mysql_fetch_assoc($res)){
- echo '<h1>' . $row['title'] . '</h1>';
- echo '<p>' . $row['body'] . '</p>';
- }
- }
- function Prideti($p){
- $title = mysql_real_escape_string($p['title']);
- $body = mysql_real_escape_string($p['body']);
- if(!$title || $body):
- if(!$title):
- echo "<p>Neįvestas pavadinimas!</p>";
- endif;
- if(!$body):
- echo "<p>Neįvestas textas!</p>";
- endif;
- echo "<a href='newnaujiena.php'><p>Pakartoti iš naujo!</p></a>";
- else:
- $sql = "INSERT INTO tvs_content VALUES (null, '$title', '$body'";
- $res = mysql_query($sql)or die (mysql_error());
- echo "<p>Naujiena Prideta!</p>";
- endif;
- }
- } //Pabaiga
- $obj = new Prisijungimas();
- $obj->host = 'localhost';
- $obj->username = 'root';
- $obj->password = '';
- $obj->db = 'lvlifetvs';
- $obj->connect();
- ?>
Add Comment
Please, Sign In to add comment