Php post kullanımı etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
Php post kullanımı etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

11 Ocak 2025

PHP POST Metodu Örneği

<?php
echo "<pre>";

if (isset($_POST['sayi'])) {
$sayi = $_POST['sayi'];

if ($sayi === "") {
echo"Lütfen bir değer giriniz";
}else {
if($sayi % 3 == 0) {
echo "Girdiginiz sayi ($sayi) 3'e tam bölünebilir";
} else {
$ilkBolunen= $sayi + (3 - $sayi % 3);
echo "Girdiğiniz sayı ($sayi) 3'e bölünemez. Bölebileceğiniz ilk sayi $ilkBolunen'dir.";
}
}
}

?>

<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>POST</title>
</head>
<body>

<form action="odevpost.php" method="post">

<input type="number" name="sayi" placeholder="Sayi"><br>

<button type="submit"> Gonder </button>
</form>




</body>
</html>

PHP Get Kullanımı

 <!DOCTYPE html>

<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>POST</title>
</head>
<body>

<form action="get.php" method="get">

<input type="text" name="isim" placeholder="Isim"><br>
<input type="text" name="soyisim" placeholder="Soyisim"><br>

<label>Diller</label><br>
<label>PHP</label>
<input type="checkbox" value="php" name="dil[]"><br>
<label>NODEJS</label>
<input type="checkbox" value="node" name="dil[]"><br>
<label>JS</label>
<input type="checkbox" value="js" name="dil[]"><br>

<button type="submit"> Gonder </button>
</form>




</body>
</html>
get.php dosyasi =>
<?php
error_reporting(E_ALL);

echo '<pre>';

function filtre($p)
{
return is_array($p) ? array_map('filtre', $p) : htmlspecialchars(trim($p));
}

$dizi = array_map('filtre', $_GET);

print_r($dizi);


?>

PHP Post Kullanımı

form.php dosyası => 

<!DOCTYPE html>

<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>POST</title>
</head>
<body>

<form action="post.php" method="post">

<input type="text" name="isim" placeholder="Isim"><br>
<input type="text" name="soyisim" placeholder="Soyisim"><br>

<label>Diller</label><br>
<label>PHP</label>
<input type="checkbox" value="php" name="dil[]"><br>
<label>NODEJS</label>
<input type="checkbox" value="node" name="dil[]"><br>
<label>JS</label>
<input type="checkbox" value="js" name="dil[]"><br>

<button type="submit"> Gonder </button>
</form>




</body>
</html>

post.php dosyası =>
<?php
error_reporting(E_ALL);

function filtre($p)
{
return is_array($p) ? array_map('filtre', $p) : htmlspecialchars(trim($p));
}

$dizi = array_map('filtre', $_POST);

echo "<pre>";

print_r($dizi);

?>