Jump to content

Recommended Posts

The php in this file works, as long as the html is gone, whats wrong with the html?

[code]<html>
<head>

<link rel='stylesheet' type='text/css' href='mreds.css' />
<link rel='alternate stylesheet' type='text/css' media='screen' title='mmilds' href='mmilds.css' />
<link rel='alternate stylesheet' type='text/css' media='screen' title='mmenthollights' href='mmenthollights.css' />
<link rel='alternate stylesheet' type='text/css' media='screen' title='mno27s' href='mno27s.css' />

</head>
<body onLoad='goforit()' align=center>

<table border=0 height=100% width=100%><tr><td vAlign=middle align=center>

<table border=0 cellspacing=0 cellpadding=0 bgcolor='#ffffff'>
<tr>
<td><img src='images/layout/cornerleft.png' height='26' width='31'></img></td><td><img src='images/layout/top.png' height='26' width='100%'></img></td><td><img src='images/layout/cornerright.png' height='26' width='31'></img></td></tr>
<tr>
<td class='loginoroutleft'></td><td align=center>

<!-- start shit -->
        <table border=0 width=300 cellspacing=0 cellpadding=0>
        <tr>
        <td align=left vAlign=top width=100% cellspacing=0 cellpadding=0>
                    <table border=1 width=100% cellspacing=0 cellpadding=0><tr><td align=left vAlign=top class='menuheadertop' width=100%>
            <b>Status</b>
                    </td></tr></table>
        </td>
        </tr>
        <tr>
        <td align=left width=100%>
                    <table border=1 width=100% height=100 cellspacing=0 cellpadding=0><tr><td vAlign=top class='menuheaderbottom' width=100% align=center>

<?php

$user = $_POST["UserName"];
$pass = $_POST["PassWord"];
$UID = 1;

if ($_POST["UserName"] == "user" && $_POST["PassWord"] == "pass") {

    setcookie("UserName", $user, time()+3600);
    setcookie("Password", $pass, time()+3600);
    setcookie("UID", $UID, time()+3600);

    echo "Logged in as $user.";
    echo "<br><br><a href='index.php' align=left>Continue</a>";

   } else {

    echo "Invalid username or password.";
    echo "<br><br><a href='index.php' align=left>Continue</a>";

   }

?>

                </td></tr></table>
        </td>
        </tr>
        </table>
<!-- end shit -->

</td><td class='loginoroutright'></td></tr>
<tr><td><img src='images/layout/cornerleftbottom.png' height='26' width='31'></img></td><td><img src='images/layout/bottom.png' height='26' width='100%'></img></td><td><img src='images/layout/cornerrightbottom.png' height='26' width='31'></img></td>
</tr>
</table></td></tr></table>
<center><font color='#ffffff'><b>Best Viewed In:: Mozilla Firefox - Resolution:: 1024x768</b></font></center>

</body>
</html>[/code]
Link to comment
https://forums.phpfreaks.com/topic/5267-setting-cookies/
Share on other sites

Fixed! This code works:

[code]<?php

$user = $_POST["UserName"];
$pass = $_POST["PassWord"];
$UID = 1;

if ($_POST["UserName"] == "Thomas" && $_POST["PassWord"] == "**killedbyuse**") {

    setcookie("UserName", $user, time()+3600);
    setcookie("Password", $pass, time()+3600);
    setcookie("UID", $UID, time()+3600);

echo "<html>
<head>

<link rel='stylesheet' type='text/css' href='mreds.css' />
<link rel='alternate stylesheet' type='text/css' media='screen' title='mmilds' href='mmilds.css' />
<link rel='alternate stylesheet' type='text/css' media='screen' title='mmenthollights' href='mmenthollights.css' />
<link rel='alternate stylesheet' type='text/css' media='screen' title='mno27s' href='mno27s.css' />

</head>
<body onLoad='goforit()' align=center>

<table border=0 height=100% width=100%><tr><td vAlign=middle align=center>

<table border=0 cellspacing=0 cellpadding=0 bgcolor='#ffffff'>
<tr>
<td><img src='images/layout/cornerleft.png' height='26' width='31'></img></td><td><img src='images/layout/top.png' height='26' width='100%'></img></td><td><img src='images/layout/cornerright.png' height='26' width='31'></img></td></tr>
<tr>
<td class='loginoroutleft'></td><td align=center>

<!-- start shit -->
        <table border=0 width=300 cellspacing=0 cellpadding=0>
        <tr>
        <td align=left vAlign=top width=100% cellspacing=0 cellpadding=0>
                    <table border=1 width=100% cellspacing=0 cellpadding=0><tr><td align=left vAlign=top class='menuheadertop' width=100%>
            <b>Status</b>";
if ($UID == 1) {

echo "[admin]";

} else {

echo "[guest]";

}

echo "              </td></tr></table>
        </td>
        </tr>
        <tr>
        <td align=left width=100%>
                    <table border=1 width=100% height=100 cellspacing=0 cellpadding=0><tr><td vAlign=top class='menuheaderbottom' width=100% align=center>";

    echo "Logged in as $user.";
    echo "<br><br><a href='index.php' align=left>Continue</a>";

   } else {

echo "<html>
<head>

<link rel='stylesheet' type='text/css' href='mreds.css' />
<link rel='alternate stylesheet' type='text/css' media='screen' title='mmilds' href='mmilds.css' />
<link rel='alternate stylesheet' type='text/css' media='screen' title='mmenthollights' href='mmenthollights.css' />
<link rel='alternate stylesheet' type='text/css' media='screen' title='mno27s' href='mno27s.css' />

</head>
<body onLoad='goforit()' align=center>

<table border=0 height=100% width=100%><tr><td vAlign=middle align=center>

<table border=0 cellspacing=0 cellpadding=0 bgcolor='#ffffff'>
<tr>
<td><img src='images/layout/cornerleft.png' height='26' width='31'></img></td><td><img src='images/layout/top.png' height='26' width='100%'></img></td><td><img src='images/layout/cornerright.png' height='26' width='31'></img></td></tr>
<tr>
<td class='loginoroutleft'></td><td align=center>

<!-- start shit -->
        <table border=0 width=300 cellspacing=0 cellpadding=0>
        <tr>
        <td align=left vAlign=top width=100% cellspacing=0 cellpadding=0>
                    <table border=1 width=100% cellspacing=0 cellpadding=0><tr><td align=left vAlign=top class='menuheadertop' width=100%>
            <b>Status</b>";
if ($UID == 1) {

echo "[admin]";

} else {

echo "[guest]";

}

echo "              </td></tr></table>
        </td>
        </tr>
        <tr>
        <td align=left width=100%>
                    <table border=1 width=100% height=100 cellspacing=0 cellpadding=0><tr><td vAlign=top class='menuheaderbottom' width=100% align=center>";

    echo "Invalid username or password.";
    echo "<br><br><a href='index.php' align=left>Continue</a>";

   }

?>

                </td></tr></table>
        </td>
        </tr>
        </table>
<!-- end shit -->

</td><td class='loginoroutright'></td></tr>
<tr><td><img src='images/layout/cornerleftbottom.png' height='26' width='31'></img></td><td><img src='images/layout/bottom.png' height='26' width='100%'></img></td><td><img src='images/layout/cornerrightbottom.png' height='26' width='31'></img></td>
</tr>
</table></td></tr></table>
<center><font color='#ffffff'><b>Best Viewed In:: Mozilla Firefox - Resolution:: 1024x768</b></font></center>

</body>
</html>[/code]

But only if this is in there, for some odd reason:

[code]if ($UID == 1) {

echo "[admin]";

} else {

echo "[guest]";

}[/code]

Could anyone explain to me why?
Link to comment
https://forums.phpfreaks.com/topic/5267-setting-cookies/#findComment-18741
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.