Jump to content

if-else statement a small question?


bulgaria_mitko

Recommended Posts

i have this code:

[code]<?php
if ($ime != TRUE) {
    echo $_POST['ime'];
} else {
    echo "<i>Моля, въведете Вашето име!</i>";
}
?>[/code]

trying to display the $ime witch in english is $name and when someone write a name it displays it, but when nothing is written and is clicked on submit it suppossed to show this text: "Моля, въведете Вашето име!" (witch means that the user didnt enter a name), but when i user didnt enter a name and click on submit it dosent show anything, what i mean by that is that i suppose it is FALSE and thats why it is 0 but the 0 is not displayed and it is displaying "" (nothing), not an error and also not the messege, nothing.

So can someone tell me where is my mistake? thank you!
Link to comment
https://forums.phpfreaks.com/topic/30474-if-else-statement-a-small-question/
Share on other sites

Hi,

Give this a try,

[code]
<?php
if (isset($_POST['ime']) && $_POST['ime'] != '') {
    echo $_POST['ime'];
} else {
    echo "<i>&#1052;&#1086;&#1083;&#1103;, &#1074;&#1098;&#1074;&#1077;&#1076;&#1077;&#1090;&#1077; &#1042;&#1072;&#1096;&#1077;&#1090;&#1086; &#1080;&#1084;&#1077;!</i>";
}
?>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.