Don't like ads? PRO users don't see any ads ;-)
Guest

Klasse wo Funktion aufgerufen wird

By: a guest on May 6th, 2012  |  syntax: PHP  |  size: 2.23 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. class RSS{
  3.        
  4.         public static function dbread() { //liest XML aus
  5.                 echo 'Hallo wer da?';
  6.                 $objXML = simplexml_load_file('xml.php');
  7.                 echo 'Hallo wer da2?';
  8.                 foreach($objXML->item as $myfeed){
  9.                         echo 'Item geholt';
  10.                         echo $myfeed->title;
  11.                         }
  12.         }
  13.                 //schreibt Daten in die Datenbank
  14.         public function dbinsert($dbhost , $dbuser, $dbpass, $dbname, $connect, $autor, $titel, $text){
  15.        
  16.                 $sql = 'INSERT INTO `rss` (`autor`, `title`, `text`) VALUES (? ,? ,? )';
  17.                 $kommando = $connect->prepare($sql);
  18.                 $kommando->bind_param('sss', $autor, $titel, $text);
  19.                 $kommando->execute();
  20.                 }
  21. }
  22.         if(isset($_POST['rsssubmit']) && isset($_POST['autor']) && !empty($_POST['autor']) &&   isset($_POST['titel']) && !empty($_POST['titel']) && isset($_POST['rsstext']) && !empty($_POST['rsstext'])) {
  23.                
  24.         $dbhost     =   'localhost';        
  25.         //$dbuser     =   "s12int_11137";          //für FH Server    
  26.         //$dbpass     =   "sd6vd5";                        //------""------
  27.         $dbuser  =  'root';
  28.         $dbpass  =  '';
  29.         $dbname  =  's12int_11137';            
  30.         $connect = @new mysqli($dbhost , $dbuser, $dbpass, $dbname);
  31.         if(mysqli_connect_errno() == 0){
  32.         echo 'Verbindung offen';
  33.         } else {
  34.                  echo 'Die Datenbank konnte nicht erreicht werden!' .mysqli_connect_errno(). ' : ' .mysqli_connect_error();
  35.                 }
  36.                 $autor = $_POST['autor'];
  37.                 $titel = $_POST['titel'];
  38.                 $text = $_POST['rsstext'];
  39.         $feed = new RSS();     
  40. /*      $feed->setAutor($autor);
  41. //      echo $feed->getAutor();
  42.         $feed->setTitel($titel);
  43. //      echo $feed->getTitel();
  44.         $feed->setText($text);
  45. //      echo $feed->getText();
  46.         */
  47.         $feed->dbinsert($dbhost , $dbuser, $dbpass, $dbname, $connect, $autor, $titel, $text);
  48.         $connect->close();
  49.         echo 'Verbindung zu.';
  50. }
  51.  
  52. ?>
  53.  
  54. <div class="window" id="noteapplet" align="left"
  55.         style="left: <?php echo $_SESSION['noteapplet']['posX'];?>px; top: <?php echo $_SESSION['noteapplet']['posY'];?>px; display: <?php echo $_SESSION['noteapplet']['vis'];?>">
  56. <span class="x" onClick="funcicon('noteapplet')">[x]</span>
  57. <?php
  58. if(isset($_GET['feed']) && ($_GET['feed'])==1){
  59.                 include "feedform.php";
  60.                         }       else {
  61. echo '<span>';
  62. echo "<a href='index.php?feed=1' id='register'> Neuen Feed ver&ouml;ffentlichen</a>";
  63. echo '<br/><br/>';
  64. RSS::dbread();
  65.  
  66. echo '</span>';
  67.  
  68. }
  69. ?>
  70.  
  71.  
  72. </div>