• 22-12-2018, 19:05:13
    #1
    herkese selamlar kolay gelsin dostlar

    localhosttan sayfa boş geliyor neden boş geldiğini biliyorum altta gördüğünüz switch case den dolayı switch sildiğimde hersey normale dönüyor

    switc case yi silmeden bu hatayı nasıl düzelte bilirim şimdiden zaman ayırıp yardım eden herkese teşekkürler..


    <?php include("fonksiyon.php");  ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="dosya/boost.css" >
    <title>PDO ÜYELİK SİSTEMİ</title>
    </head>
    <body>
    
    <div class="container-fluid">
    	<div class="row">
        
        	<div class="col-md-6 mx-auto mt-4" >
            
               <?php
    		   $hareket=$_GET["hareket"];
    		   	
    			switch($hareket):
    				case"ekle":
    				break;
    				
    				case"uyeguncelle":
    				break;
    				
    				case"uyesil":
    				break;
    			
    			?>
            
            
            	<table class="table table-bordered table-striped text-center bg-white">
                <thead>
                <tr>
                <th colspan="6"> <a href="index.php?hareket=ekle" class="btn btn-success"> Üye Ekle  </a></th>
                           
                </tr>
                </thead>
            	<thead>
                <tr>
                <th class="font-weight-bold">AD</th>
                <th class="font-weight-bold">SOYAD</th>
                <th class="font-weight-bold">YAŞ</th>
                <th class="font-weight-bold">AİDAT</th>
                <th class="font-weight-bold">GÜNCELLE</th>
                <th class="font-weight-bold">SİL</th>            
                </tr>
                </thead>
                <tbody>
                
                <?php
    			$clas= new uye;
    			
    			 
                echo $clas->listele($baglanti);         
               
                
    			?>
               
              
                </tbody>
            	
                </table>
                <?php
                default;
    			 endswitch;        
               
                
    			?>
               
              
            
            </div>
        
        
        </div>
    
    	
    
    </div>
    
    </body>
    </html>
    fonsiyon .php

    <?php
    
    try  {
    	$baglanti = new PDO("mysql:host=localhost;dbname=kisiler;charset=utf8", "root","123456");
    	$baglanti->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    	
    	
    } catch (PDOException $e) {
    	die($e->getMessege());
    }
    
    class uye {
    	
    	function ekle ($baglanti){
    		$buton=$_POST["buton"];
    		
    		
    		if($buton):
    		
    		$ad= htmlspecialchars ($_POST["ad"]);
    		$soyad= htmlspecialchars ($_POST["soyad"]);
    		$yas= htmlspecialchars ($_POST["yas"]);
    		$aidat=htmlspecialchars($_POST["aidat"]);
    		
    			if (empty ($ad) or empty ($soyad) or empty ($yas) or empty ($aidat)  ):
    				echo"boş alan bırakma ";
    					else:
    					$ekleme=$baglanti->prepare("insert into uyeler  (ad,soyad,yas,aidat) VALUES(?,?,?,?)");
    					$ekleme->bindParam(1,$ad,PDO::PARAM_STR);
    					$ekleme->bindParam(1,$soyad,PDO::PARAM_STR);
    					$ekleme->bindParam(1,$yas,PDO::PARAM_STR);
    					$ekleme->bindParam(1,$aidat,PDO::PARAM_INT);
    					$ekleme->execute();
    					echo "ekleme başarılı ";
    				endif;
    		
    		endif;
    		
    		
    		
    		echo '<table class="table table-border table-striped text-center bg-white">
            <thead>
                <tr>
                <th colspan="6">Üye Ekleme</th>
                  </tr>    
                   </thead>
                   <tbody> 
                   <tr>    
               <td colspan="6">
            <form action="inde.php?islem=ekle" method="post">
            <input type="text" name="ad" class="form-control mx-auto col-md-3 mt-2" placeholder="ad yaz" />
            <input type="text" name="soyad" class="form-control mx-auto col-md-3 mt-2" placeholder="soyad yaz" />
            <input type="text" name="yas" class="form-control mx-auto col-md-3 mt-2" placeholder="yas yaz" />
            <input type="text" name="aidat" class="form-control mx-auto col-md-3 mt-2" placeholder="aidat yaz" />
            <input type="submit" name="buton" class="btn btn-success" value="EKLE" />
            </form>
            </td>
             <tr>
                
                </tbody>   
            </table>';
    		
    		}
    	
    	function listele($baglanti){
    		$sorgu=$baglanti->prepare("select * from uyeler") ;
    		$sorgu->execute();
    		if($sorgu->rowCount()==0):
    		echo'<tr>
    		<td colspan="6"> Kayıtlı Üye Yok</td>
    		</tr>';
    		else:
    		while ($cikti=$sorgu->fetch(PDO::FETCH_ASSOC)):
    			echo ' <tr>
                <td>'.$cikti["ad"].'</td>
                <td>'.$cikti["soyad"].'</td>
                <td>'.$cikti["yas"].'</td>
                <td>'.$cikti["aidat"].'</td>
                <td><a href="index.php?hareket=uyeguncelle&id='.$cikti["id"].'" class="btn btn-warning" >Güncelle </a> </td>
                <td><a href="index.php?hareket=uyesil&id='.$cikti["id"].'" class="btn btn-danger" >Sil </a></td>            
                </tr>';
                 
    		endwhile;
    		endif;
    		
    		}
    	
    	
    	}
    
    
    
    ?>
  • 22-12-2018, 19:09:23
    #2
    switch($hareket){
    case "ekle": echo "ekle";
    break;

    case "uyeguncelle": echo "uyeguncelle";
    break;

    case "uyesil": echo "uyesil";
    break;
    }

    şeklinde dener misiniz ? echo yazdığım kısmında artık ne işlem yapacaksanız onu yapmanız gerek
  • 22-12-2018, 19:45:59
    #3
    fozalp adlı üyeden alıntı: mesajı görüntüle
    switch($hareket){
    case "ekle": echo "ekle";
    break;

    case "uyeguncelle": echo "uyeguncelle";
    break;

    case "uyesil": echo "uyesil";
    break;
    }

    şeklinde dener misiniz ? echo yazdığım kısmında artık ne işlem yapacaksanız onu yapmanız gerek
    hocam ilgilenip cevap yazdığınız için çok teşekkürler fakat dediğiniz gibi yaptım olmadı
  • 22-12-2018, 20:17:05
    #4
    Merhaba, dosyayı şu şekilde güncelleyiniz;
    <?php include("fonksiyon.php");  ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="dosya/boost.css" >
    <title>PDO ÜYELİK SİSTEMİ</title>
    </head>
    <body>
     
    <div class="container-fluid">
       <div class="row">
        
          <div class="col-md-6 mx-auto mt-4" >
            
               <?php
             $hareket=$_GET["hareket"];
                
             switch($hareket):
                case"ekle":
                break;
                
                case"uyeguncelle":
                break;
                
                case"uyesil":
                break;
                 default:
             ?>
            
            
             <table class="table table-bordered table-striped text-center bg-white">
                <thead>
                <tr>
                <th colspan="6"> <a href="index.php?hareket=ekle" class="btn btn-success"> Üye Ekle  </a></th>
                          
                </tr>
                </thead>
             <thead>
                <tr>
                <th class="font-weight-bold">AD</th>
                <th class="font-weight-bold">SOYAD</th>
                <th class="font-weight-bold">YAŞ</th>
                <th class="font-weight-bold">AİDAT</th>
                <th class="font-weight-bold">GÜNCELLE</th>
                <th class="font-weight-bold">SİL</th>            
                </tr>
                </thead>
                <tbody>
                
                <?php
             $clas= new uye;
            
              
                echo $clas->listele($baglanti);        
              
                
             ?>
              
              
                </tbody>
            
                </table>
                <?php
             break;
              endswitch;        
              
                
             ?>
              
              
            
            </div>
        
        
        </div>
     
      
     
    </div>
     
    </body>
    </html>
  • 22-12-2018, 20:20:58
    #5
    Kimlik doğrulama veya yönetimden onay bekliyor.
    <form action="inde.php?islem=ekle" method="post">
    Eğer üye Ekleme yaparken hata alıyorsan burada bi sorun var
    <form action="index.php?hareket=ekle" method="post">
    Bu şekilde düzeltebilirmisin
    Fozalp arkadaşımızın verdiği kodda da bi sıkıntı yok.
    $hareket=$_GET["hareket"];
    hemen altına
    echo $hareket;
    yazarak çıktı var mı bakabilirmisiniz
  • 22-12-2018, 20:38:56
    #6
    Scorpion2763 adlı üyeden alıntı: mesajı görüntüle
    Merhaba, dosyayı şu şekilde güncelleyiniz;
    <?php include("fonksiyon.php");  ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="dosya/boost.css" >
    <title>PDO ÜYELİK SİSTEMİ</title>
    </head>
    <body>
     
    <div class="container-fluid">
       <div class="row">
        
          <div class="col-md-6 mx-auto mt-4" >
            
               <?php
             $hareket=$_GET["hareket"];
                
             switch($hareket):
                case"ekle":
                break;
                
                case"uyeguncelle":
                break;
                
                case"uyesil":
                break;
                 default:
             ?>
            
            
             <table class="table table-bordered table-striped text-center bg-white">
                <thead>
                <tr>
                <th colspan="6"> <a href="index.php?hareket=ekle" class="btn btn-success"> Üye Ekle  </a></th>
                          
                </tr>
                </thead>
             <thead>
                <tr>
                <th class="font-weight-bold">AD</th>
                <th class="font-weight-bold">SOYAD</th>
                <th class="font-weight-bold">YAŞ</th>
                <th class="font-weight-bold">AİDAT</th>
                <th class="font-weight-bold">GÜNCELLE</th>
                <th class="font-weight-bold">SİL</th>            
                </tr>
                </thead>
                <tbody>
                
                <?php
             $clas= new uye;
            
              
                echo $clas->listele($baglanti);        
              
                
             ?>
              
              
                </tbody>
            
                </table>
                <?php
             break;
              endswitch;        
              
                
             ?>
              
              
            
            </div>
        
        
        </div>
     
      
     
    </div>
     
    </body>
    </html>
    hocam öncelikle zaman ayırıp cevap verdiğiniz çok çok teşekkürler sizin dediğiniz gibi yaptım ve sorunum çözüldü fakat bunun mantığı nedir acaba böyle birşeyle karşılaşırsam ne yapmam lazım nasıl çözdünüz acaba söyleyebilirmisiniz



    ali_akkececi adlı üyeden alıntı: mesajı görüntüle
    <form action="inde.php?islem=ekle" method="post">
    Eğer üye Ekleme yaparken hata alıyorsan burada bi sorun var
    <form action="index.php?hareket=ekle" method="post">
    Bu şekilde düzeltebilirmisin
    Fozalp arkadaşımızın verdiği kodda da bi sıkıntı yok.
    $hareket=$_GET["hareket"];
    hemen altına
    echo $hareket;
    yazarak çıktı var mı bakabilirmisiniz
    hocam öncelikle zaman ayırıp cevap yazdığınız için çok çok teşekkürler
    sorunum çözüldü hocam
  • 22-12-2018, 20:42:23
    #7
    ozgun58 adlı üyeden alıntı: mesajı görüntüle
    hocam öncelikle zaman ayırıp cevap verdiğiniz çok çok teşekkürler sizin dediğiniz gibi yaptım ve sorunum çözüldü fakat bunun mantığı nedir acaba böyle birşeyle karşılaşırsam ne yapmam lazım nasıl çözdünüz acaba söyleyebilirmisiniz
    rica ederim, switch kullanımı için buraya tıklayarak bilgi alabilirsiniz., koddaki hata default: blogu koddan sonra açılmış ve kapatma blogu olaran (break;) kullanılmamış. İyi çalışmalar