+11 ovoz
473 ko'rilgan 11 1
<?php

echo '

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

<input type="text" name="txt">

<input type="submit" name="btn" value="GO!">

</form>';

$mytxt=$_POST["txt"];

if (empty($mytext)) {

echo '<font color="red">Hech narsa yozmadingiz !</font>';

else {

echo '<font color="green">'.$mytxt.'</font>';

}

?>

-------------------------------------------------------------------------

Mana bu yerda sahifani yangilagandayam "Hech narsa yozmadingiz !" degan so'z chiqyapti. Ya'ni aytmoqchi bo'lgan savolim sahifa yangilanganda hech qanaqa so'z chiqmasinda formaga so'z kiritilib "GO!" tugmasi bosilganda chiqishi kere. Agar yozilmagan bo'lsa "Hech narsa yozmadingiz !" so'zi chiqishi kerak... Rahmat !
Bu mavzu Dasturlash bo'limida
Teg o'zgartirilgan | 473 ko'rilgan

1 Javob

+1 ovoz
Eng zo'r javob
1
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>  

<?php

if ($_SERVER["REQUEST_METHOD"] == "POST") {
  if (empty($_POST["Mytxt"])) {
    $MytxtErr = "Hech narsa yozmadingiz !";
  } else {
    $Mytxt = test_input($_POST["Mytxt"]);
  }
}


?>

<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">  
  <input type="text" name="Mytxt">
  <span class="error">* <?php echo $MytxtErr;?></span>
  <br><br>
  <input type="submit" name="submit" value="Go!">  
</form>

<?php
echo $name;
?>

</body>
</html>

belgilash
0
E RAHMAT !!!!

O'xshash savollar

+14 ovoz
1 javob
Kodirjonov Bu mavzu Kompyuter bo'limida 27 Apr, 18 savol berdi | 557 ko'rilgan
+10 ovoz
2 javob
+7 ovoz
1 javob
POKERIST Bu mavzu Saytlar bo'limida 02 Noy, 18 savol berdi | 348 ko'rilgan
+5 ovoz
1 javob
Shohjaxon Bu mavzu Dasturlash bo'limida 11 Mart, 19 savol berdi | 471 ko'rilgan
+11 ovoz
12 javob
JavIk Bu mavzu Dasturlash bo'limida 18 Iyun, 17 savol berdi | 1.7k ko'rilgan