Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/114520-php-if-statement/
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/114520-php-if-statement/#findComment-588930
Share on other sites

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;?>>

Link to comment
https://forums.phpfreaks.com/topic/114520-php-if-statement/#findComment-588931
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.