Hi,
I am a PHP Beginner & getting the following error when i run the code.I have gone through various forums & implemented numerous suggestions but to no avail. I have the latest WAMP server.. this code was written by someone else inPHP 4 and i am working on it in PHP 5.3
ERROR:
Notice: Undefined variable: action in I:\wamp\www\seo\htm\login.php on line 10
Notice: Undefined variable: action in I:\wamp\www\seo\htm\login.php on line 44
Notice: Undefined variable: action in I:\wamp\www\seo\htm\login.php on line 71
CODE
if ($action == "login")
{
echo "<table cellpadding=4 cellspacing=0 border=1 width=300 align=center>\n";
echo "<form method=post action=\"login.php?action=verify\" name=login_form>\n";
echo "<tr><td>Username</td><td><input type=text size=10 name=username></td></tr>\n";
echo "<tr><td>Password</td><td><input type=password size=10 name=password></td></tr>\n";
echo "<tr><td>Project</td><td>\n";
$sql_temp = "select client_id, name from clients";
$qid_temp = db_query($sql_temp);
$num_temp = db_num_rows($qid_temp);
echo "<select name=client_id>\n";
for ($i=0;$i<=$num_temp-1;$i++)
{
$result_temp = db_fetch_row($qid_temp);
echo "<option value=\"".$result_temp[0]."\">".$result_temp[1]."</option>\n";
}
echo "</select>\n";
echo "</td></tr>\n";
echo "<tr><td></td><td><input type=submit value=Login></td></tr>\n";
echo "</form>\n";
echo "</table>\n";
}
//-------------------------------------------------------------------------------------------
// VERIFY LOGIN
//-------------------------------------------------------------------------------------------
if ($action == "verify")
{
$sql = "select count(*) from admin where username = '".$username."' and password = '".$password."'";
$qid = db_query($sql);
$result = db_fetch_row($qid);
if ($result[0] > 0)
{
echo "Login Successful. <a href=\"index.php\">Click here to continue</A>\n";
$_SESSION["seo_user"]=$username;
$_SESSION["client_id_session"]=$client_id;
}
else
{
echo "Login Failed. <a href=\"login.php?action=login\">Click here to continue</A>\n";
}
}
WHAT I TRIED:
1. gave $action= "login"; the code worked but it kept getting refreshed to the login page & didnt verify the uname & pwd.
2. in php.ini file, I changed: error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
3. i tried if ($_POST['$action'] == "login") only to get Undefined Index error.
HELP!!!! m really confused now..
Notice: Undefined variable: action in I:\wamp\www\seo\htm\
Moderator: General Moderators
Re: Notice: Undefined variable: action in I:\wamp\www\seo\htm\
Using PHP 4 code on a PHP 5.3 platform is going to be a pain. Good luck.
Anyways, use $_REQUEST["action"]. I say REQUEST and not GET or POST because it'll allow the "action" going through the URL or through a form.
Anyways, use $_REQUEST["action"]. I say REQUEST and not GET or POST because it'll allow the "action" going through the URL or through a form.