Advertisement
sueckreimir

ucenicMVC/uredi

Oct 9th, 2019 (edited)
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.40 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!--
  3. To change this license header, choose License Headers in Project Properties.
  4. To change this template file, choose Tools | Templates
  5. and open the template in the editor.
  6. -->
  7. <html>
  8.     <head>
  9.         <meta charset="UTF-8">
  10.         <title></title>
  11.     </head>
  12.     <body>
  13.         <?php
  14.        
  15.         class model
  16.         {
  17.            
  18.             function pohranaPodataka()
  19.             {
  20.                 require 'konekcija.php';
  21.                 if(isset($_GET['mbr']))
  22.                 {
  23.                    
  24.                    $mbr=$_GET['mbr'];
  25.                    $broj=$_GET['broj'];
  26.                    $query="select imeStud,prezStud,mbrStud
  27.                   from stud
  28.                   where mbrStud=$mbr";
  29.                    $result=mysqli_query($link,$query);
  30.                    $fetch=mysqli_fetch_assoc($result);
  31.                 }
  32.                 if(isset($_POST['submit']))
  33.                 {
  34.                    $izvrseno='da';
  35.                    $ime=$_POST['ime'];
  36.                    $prezime=$_POST['prezime'];
  37.                    
  38.                    $query2="UPDATE stud SET imeStud='$ime',"
  39.                          . " prezStud = '$prezime' WHERE stud.mbrStud =$mbr";
  40.                    $result2=mysqli_query($link,$query2);
  41.                    
  42.                 }
  43.                 else
  44.                 {
  45.                     $izvrseno='ne';
  46.                 }
  47.                
  48.                 $podaci=array('fetch'=>$fetch,
  49.                            'izvrseno'=>$izvrseno,
  50.                                'broj'=>$broj,
  51.                                 'mbr'=>$mbr);
  52.                                
  53.                                
  54.                 return $podaci;
  55.                
  56.             }
  57.            
  58.         }
  59.        
  60.        
  61.         class view
  62.         {
  63.             function ispisPodataka($podaci)
  64.             {
  65.                 if($podaci['izvrseno']=='da')
  66.                 {
  67.                     echo 'Unos podataka izvršen'.'<br>';
  68.                     echo '<a href="index.php?mbr='.$podaci['mbr'].'&broj='.$podaci['broj'].'">'.'Vidi Promjene'.'</a>';
  69.                 }
  70.                 else
  71.                 {
  72.                     echo '<table border="0">'.
  73.                     '<form action="" method="POST">'.
  74.                     '<tr><td>'.'Ime '.'<td>'.'<input type="text" name="ime" value="'.$podaci['fetch']['imeStud'].'">'.'<tr>'.
  75.                     '<tr><td>'.'Prezime'.'<td>'.'<input type="text" name="prezime" value="'.$podaci['fetch']['prezStud'].'">'.'<tr>'.
  76.                     '<tr><td>'.'<input type="submit" name="submit" value="Izmjeni">'.'<tr>'.
  77.                     '</form>'.
  78.                     '</table>';
  79.  
  80.                 }    
  81.                  
  82.             }  
  83.                
  84.         }        
  85.                
  86.            
  87.         class controler
  88.         {
  89.             public $_Model;
  90.             public $_View;
  91.            
  92.             function __construct()
  93.             {
  94.                 $this->_Model=new model();
  95.                 $this->_View=new view();
  96.             }
  97.            
  98.             function start()
  99.             {
  100.                 $podaci= $this->_Model->pohranaPodataka();
  101.                 $this->_View->ispisPodataka($podaci);
  102.             }
  103.         }
  104.        
  105.        
  106.         $pokreni=new controler();
  107.         $pokreni->start();
  108.        
  109.        
  110.         ?>
  111.     </body>
  112.    
  113. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement