• 03-05-2016, 00:50:22
    #1
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Kod yapısı aşağıdaki gibi veri ekleme sayfasında tek tırnaklı yazı gireceğim zaman sorun yaşıyorum eklemiyor.buraya nasıl bir kod eklenmesi lazım ki hatasız işlem gerçekleşsin.teşekkürler.


    <?php 
    			if(isset($_POST) && !empty($_POST)) {
    		
    				$query = ("INSERT INTO `customers` SET 
                 	name = '" . $_POST['name'] . "',
    	            company = '" . $_POST['company'] . "',
    	            title = '" . $_POST['title'] . "',
    	            email = '" . $_POST['email'] . "',
    	            address = '" . $_POST['address'] . "',
    	            company_phone = '" . $_POST['company_phone'] . "',
    	            company_fax = '" . $_POST['company_fax'] . "',
    	            person_phone = '" . $_POST['person_phone'] . "',
    	            person_gsm = '" . $_POST['person_gsm'] . "',
    	            tax_name = '" . $_POST['tax_name'] . "',
    	            tax_no = '" . $_POST['tax_no'] . "'
    	           	");
    					
    				$result = mysql_query($query);
    				$last_id = mysql_insert_id($conn);;
    				
    				$query2 = ("INSERT INTO `questions` SET 
                 	customer_id = '" . $last_id . "',
    	            question_12 = '" . $_POST['question_12'] . "',
    	            question_13 = '" . $_POST['question_13'] . "',
    	            question_14 = '" . $_POST['question_14'] . "',
    	            question_15 = '" . $_POST['question_15'] . "',
    	            question_16 = '" . $_POST['question_16'] . "',
    	            question_17 = '" . $_POST['question_17'] . "',
    	            question_18 = '" . $_POST['question_18'] . "',
    	            question_19 = '" . $_POST['question_19'] . "',
    	            question_20 = '" . $_POST['question_20'] . "',
    	            question_21 = '" . $_POST['question_21'] . "',
    	            question_22 = '" . $_POST['question_22'] . "',
    	            question_23 = '" . $_POST['question_23'] . "',
    	            question_24 = '" . $_POST['question_24'] . "',
    	            question_25 = '" . $_POST['question_25'] . "',
    	            question_26 = '" . $_POST['question_26'] . "',
    	            question_27 = '" . $_POST['question_27'] . "',
    	            question_28 = '" . $_POST['question_28'] . "',
    	            question_29 = '" . $_POST['question_29'] . "',
    	            question_30 = '" . $_POST['question_30'] . "',
    	            question_31 = '" . $_POST['question_31'] . "',
    	            question_32 = '" . $_POST['question_32'] . "',
    	            question_33 = '" . $_POST['question_33'] . "',
    	            question_34 = '" . $_POST['question_34'] . "',
    	            question_35 = '" . $_POST['question_35'] . "',
    	            question_36 = '" . $_POST['question_36'] . "',
    	            question_37 = '" . $_POST['question_37'] . "',
    	            question_38 = '" . $_POST['question_38'] . "',
    	            question_39 = '" . $_POST['question_39'] . "',
    	            question_40 = '" . $_POST['question_40'] . "',
    	            question_41 = '" . $_POST['question_41'] . "',
    	            question_42 = '" . $_POST['question_42'] . "',
    	            question_43 = '" . $_POST['question_43'] . "',
    	            question_44 = '" . $_POST['question_44'] . "'
    	            ");
    				
    				$result2 = mysql_query($query2);
    				
    			}
    			
    			if (!$result && !$result2) {
    				die("Cannot execute query.");
    			}
    			else{
    				echo '<div class="alert alert-success">Müşteri Eklenmiştir. <a href="index.php">Geri Dön.</a></div>';
    			}
    		?>
  • 03-05-2016, 03:00:29
    #2
    mysqli_real_escape_string() bu fonksiyon işini görücektir.
    örnek kullanım
    mysqli_real_escape_string($_POST['question_12']);
  • 03-05-2016, 13:37:05
    #3
    $query = ("INSERT INTO `customers` SET  
                     name = '" . addslashes($_POST['name']) . "', 
                    company = '" . addslashes($_POST['company']) . "', 
                    title = '" . addslashes($_POST['title']) . "', 
                    email = '" . $_POST['email'] . "', 
                    address = '" . $_POST['address'] . "', 
                    company_phone = '" . $_POST['company_phone'] . "', 
                    company_fax = '" . $_POST['company_fax'] . "', 
                    person_phone = '" . $_POST['person_phone'] . "', 
                    person_gsm = '" . $_POST['person_gsm'] . "', 
                    tax_name = '" . $_POST['tax_name'] . "', 
                    tax_no = '" . $_POST['tax_no'] . "' 
                       ");
  • 03-05-2016, 14:39:23
    #4
    Defatul adlı üyeden alıntı: mesajı görüntüle
    $query = ("INSERT INTO `customers` SET  
                     name = '" . addslashes($_POST['name']) . "', 
                    company = '" . addslashes($_POST['company']) . "', 
                    title = '" . addslashes($_POST['title']) . "', 
                    email = '" . $_POST['email'] . "', 
                    address = '" . $_POST['address'] . "', 
                    company_phone = '" . $_POST['company_phone'] . "', 
                    company_fax = '" . $_POST['company_fax'] . "', 
                    person_phone = '" . $_POST['person_phone'] . "', 
                    person_gsm = '" . $_POST['person_gsm'] . "', 
                    tax_name = '" . $_POST['tax_name'] . "', 
                    tax_no = '" . $_POST['tax_no'] . "' 
                       ");
    teşekkürler işe yaradı.