talor123 Posted July 13, 2008 Share Posted July 13, 2008 hey, i have no idea whats rong with my code... what meants to happen is if a user submits the rong user/password to login.php.. it will send back what the variable 'message' is equal to.. (eg: message=1) which will then be turned into the necessary image like so... if($number == "1") {$img = "invaild.png";}.. then that image will be used as a table row background on the login form... so the user knows what they have done rong. heres my code.. <? if(isset($_GET["message"])) { $number = $_GET["message"]; if($number == "1"){$img = "invalid.png";} elseif($number == "3"){$img = "details.png";} $bg = "<tr style='background-image:url($img);'></tr>"; } ?> <table class="tableclose" cellpadding="0" cellspacing="0" id="logtable"> <form action="login.php" method="post"> <tr style="background-color:43BF4F;"><td>Login</td></tr> <?=$bg?> <tr><td>Username:</td><td><input type="text" name="user"></td></tr> <tr><td>Password:</td><td><input type="password" name="password"></td></tr> <tr><td></td><td><input type="submit" value="Login"></td></tr> </table> thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/114520-php-if-statement/ Share on other sites More sharing options...
DeanWhitehouse Posted July 13, 2008 Share Posted July 13, 2008 so whats the question? Quote Link to comment https://forums.phpfreaks.com/topic/114520-php-if-statement/#findComment-588892 Share on other sites More sharing options...
talor123 Posted July 13, 2008 Author Share Posted July 13, 2008 sorry if i wasnt clear, the question is why is my code not doing what it meants to be doing(what i explained at first) Quote Link to comment https://forums.phpfreaks.com/topic/114520-php-if-statement/#findComment-588895 Share on other sites More sharing options...
DeanWhitehouse Posted July 13, 2008 Share Posted July 13, 2008 yes, but are there any errors, what isn't it doing, not setting the background? Quote Link to comment https://forums.phpfreaks.com/topic/114520-php-if-statement/#findComment-588896 Share on other sites More sharing options...
talor123 Posted July 13, 2008 Author Share Posted July 13, 2008 yea.. its not setting the background for the table row Quote Link to comment https://forums.phpfreaks.com/topic/114520-php-if-statement/#findComment-588897 Share on other sites More sharing options...
sader Posted July 13, 2008 Share Posted July 13, 2008 first try to echo your $bg value <? echo $bg; ?> second I think you should include and <td> tags in your string $bg = "<tr style='background-image:url($img); height:24px;'><td colspan=2></td></tr>"; Quote Link to comment https://forums.phpfreaks.com/topic/114520-php-if-statement/#findComment-588925 Share on other sites More sharing options...
.josh Posted July 13, 2008 Share Posted July 13, 2008 Where is your code that passes "message" via the GET method? And on that note, why are you even using the GET method like this? It doesn't look like anybody could do any real harm by changing the value of "message" here, but still... you should be passing data through a session var. But regardless, where is your code that passes your 1 or 3 to this script? Quote Link to comment https://forums.phpfreaks.com/topic/114520-php-if-statement/#findComment-588930 Share on other sites More sharing options...
teynon Posted July 13, 2008 Share Posted July 13, 2008 Wow, you guys are overcomplicating a simple HTML issue heh... The TR you are making is simply that. A row. So the image will show up in that row only, which is empty. So, you need to set that image to the table background. Example: $bg=" style='background-image:url($img);'"; <table<?=$bg;?>> Quote Link to comment https://forums.phpfreaks.com/topic/114520-php-if-statement/#findComment-588931 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.