little problem with script ...
Posted: Wed Aug 27, 2003 1:14 pm
ok ... i am not sure what's going on but i can't get my script to work. if somebody can tell me what i'm doing wrong, that'd be awesome. i tried everything ...
here's the sitch ... i am redirecting the output of a form to the originating page. that page then processes the form info and rewrites a new page, based on that info. try it for yourself. it won't adjust the variable $p even if the password & user name are correct (which is "space" and "steve" respectively ... hard-coded for now, it will later be tied to a database).
heres the code ... (also when you run it in a browser be sure to add the following to the end the url: "?a=1&b=1" w/o quotes)
thanks for any feedback ...
?>
here's the sitch ... i am redirecting the output of a form to the originating page. that page then processes the form info and rewrites a new page, based on that info. try it for yourself. it won't adjust the variable $p even if the password & user name are correct (which is "space" and "steve" respectively ... hard-coded for now, it will later be tied to a database).
heres the code ... (also when you run it in a browser be sure to add the following to the end the url: "?a=1&b=1" w/o quotes)
Code: Select all
<?php $a = $_GET["a"];
$b = $_GET["b"];
$n = $_POST["n"];
$c = $_POST["c"];
$p = 0;
if ($c == "steve" && $n == "space") {
$p = $p + 2;
echo "Correct ...";
}
if ($b == 0) {
$s = inx;
} elseif ($b == 1) {
$s = moz;
} elseif ($b == 2) {
$s = gen;
} else {
$a = 2;
$e = "error #";
}
if ($a == 1) {
if ($p == 0) { //default (initial) output
echo "<html><head><link href="../inc/stl" rel="stylesheet" type="text/css"><script src="../inc/jvs/", $s ,""></script></head><body><!-- onContextMenu="return false" --><br><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="5"> </td><td width="*"><b class="dbm">Member login:</b></td><td align="right" width="72"><b class="dns">(Register?) </b></td></tr></table><table border="0" cellpadding="1" cellspacing="0" width="100%"><form action="", $PHP_SELF, "?a=1&b=", $b, "" method="post" target="sd"><tr><td width="5"> </td><td align="right" width="*"><b class="dnm">User:</b></td><td width="126"> <input class="ntb" name="n" size="15" type="text"></td></tr><tr><td width="5"> </td><td align="right" width="*"><b class="dnm">Password:</b></td><td width="126"> <input class="ntb" name="c" size="15" type="password"></td></tr></table><table border="0" cellpadding="4" cellspacing="0" width="100%"><tr><td align="right" colspan="3" width="*"><input class="nsb" size="15" type="submit" value="Login"></td></tr></form></table>
<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td colspan="2"> </td></tr><tr><td width="5"> </td><td width="*"><b class="dnm">Link tree", $p, "</b></td></tr></table>", $n, "<br>", $c, "</body></html>";
} elseif ($p == 1) { //session already started
echo "<html><head><link href="../inc/stl" rel="stylesheet" type="text/css"><script src="../inc/jvs/", $s ,""></script></head><body><!-- onContextMenu="return false" --><br><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="5"> </td><td width="*"><b class="dbm">Welcome back <i>username</i>!</b></td></tr><tr><td align="center" colspan="2" width="*"><b class="dns">[Account Info | View Cart | Logout]</b></td></tr></table>
<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td colspan="2"> </td></tr><tr><td width="5"> </td><td width="*"><b class="dnm">Link tree", $p, "</b></td></tr></table>", $n, "<br>", $c, "</body></html>";
} elseif ($p == 2) { //new session
echo "<html><head><link href="../inc/stl" rel="stylesheet" type="text/css"><script src="../inc/jvs/", $s ,""></script></head><body><!-- onContextMenu="return false" --><br><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="5"> </td><td width="*"><b class="dbm">Welcome <i>username</i>!</b></td></tr><tr><td align="center" colspan="2" width="*"><b class="dns">[Account Info | View Cart | Logout]</b></td></tr></table>
<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td colspan="2"> </td></tr><tr><td width="5"> </td><td width="*"><b class="dnm">Link tree", $p, "</b></td></tr>
</table>", $n, "<br>", $c, "</body></html>";
} elseif ($p == 3) { //administration toolbar
echo "<html><head><link href="../inc/stl" rel="stylesheet" type="text/css"><script src="../inc/jvs/", $s ,""></script></head><body><!-- onContextMenu="return false" --><br><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="5"> </td><td width="*"><b class="dbm">Welcome <i>username</i>!</b></td></tr></table>
<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td colspan="2"> </td></tr><tr><td width="5"> </td><td width="*"><b class="dnm">Admin toolbar", $p, "</b></td></tr>
</table>", $n, "<br>", $c, "</body></html>";
}} else {
echo "<html><head><link rel="stylesheet" type="text/css" href="css"><title>SmartMart :: error</title></head><frameset rows="100%" frameborder="0" framespacing="0" border="0"><frame name="rt" src="../err/?a=1&e=" noresize><noframes>this website uses frames ... please turn frames on or download an updated browser that supports frames</noframes></frameset></html>";
}
?>?>