943,866 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 481
  • PHP RSS
Aug 3rd, 2009
0

code not doing anything

Expand Post »
This is part of the code to a login form. The only file is index.php. The code continues but it what you get after you have successfully logged in. It doesn't matter what I put the the login form, when I hit the "log in" button, if just reloads the page, with no errors or anything. I have the database and everything set up correctly as far as I know. I'm not sure if you need anymore information. If you do I can get it to you. Any help would be greatly appreciated. I have been stuck on this for a few hours now.
php Syntax (Toggle Plain Text)
  1. session_start();
  2. if ($form == 'sent') {
  3. unset($HTTP_SESSION_VARS);
  4. session_destroy();
  5. }
  6. global $asess_name, $asess_passwd, $asess_data;
  7. session_register("asess_name");
  8. session_register("asess_passwd");
  9. session_register("asess_data");
  10. include('../vars.php');
  11. mysql_connect($db_host, $db_user, $db_pwd);
  12. mysql_select_db($db_name);
  13. if (!isset($HTTP_SESSION_VARS["asess_name"])) {
  14. if ($form = 'sent' && ereg($self_name, $HTTP_REFERER)) {
  15. if ($login == "" || $passwd == "" || ereg('%', $login) || ereg('%', $passwd)) {
  16. echo("<html><head><title>$title</title></head><body><p align=center><font face=$fontface><b>
  17. <span style=\"background-color: $admincolor\">&nbsp;$title Control Panel </span></b>
  18. </font></p><div align=center><center>
  19. <table border=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" cellpadding=\"0\" cellspacing=\"3\">
  20. <form method=post action=/control/><input type=hidden name=form value=sent><tr>
  21. <td align=\"right\" valign=\"top\" bgcolor=\"$admincolor\"><b>
  22. <font face=\"$fontface\" size=\"2\">Login</font>:</b></td>
  23. <td align=\"left\" valign=\"top\">
  24. <input type=\"text\" name=\"login\" size=\"25\" style=\"font-family: $fontface; font-size: 8pt; font-weight: bold\"></td>
  25. </tr><tr><td align=\"right\" valign=\"top\" bgcolor=\"$admincolor\">
  26. <font face=\"$fontface\" size=\"2\"><b>Password:</b></font></td>
  27. <td align=\"left\" valign=\"top\">
  28. <input type=\"password\" name=\"passwd\" size=\"25\" style=\"font-size: 8pt; font-family: $fontface; font-weight: bold\"></td>
  29. </tr><tr><td></td><td align=\"left\" valign=\"top\">
  30. <input type=\"submit\" value=\"Log in\" style=\"font-family: $fontface; font-size: 8pt; font-weight: bold; float: right\"></td>
  31. </tr></form></table></center></div></body></html>");
  32. unset($HTTP_SESSION_VARS);
  33. session_destroy();
  34. exit;
  35. }
  36. global $login, $passwd;
  37. $asess_name = $login;
  38. $asess_passwd = $passwd;
  39. header("Location: /control/?".SID);
  40. exit;
  41. }
  42. echo("<html><head><title>$title</title></head><body><p align=\"center\"><font face=\"$fontface\"><b>
  43. <span style=\"background-color: $admincolor\">&nbsp;$title Control Panel </span></b>
  44. </font></p><div align=center><center>
  45. <table border=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" cellpadding=\"0\" cellspacing=\"3\">
  46. <form method=post action=/control/><input type=hidden name=form value=sent><tr>
  47. <td align=\"right\" valign=\"top\" bgcolor=\"$admincolor\"><b>
  48. <font face=\"$fontface\" size=\"2\">Login</font>:</b></td>
  49. <td align=\"left\" valign=\"top\">
  50. <input type=\"text\" name=\"login\" size=\"25\" style=\"font-family: $fontface; font-size: 8pt; font-weight: bold\"></td>
  51. </tr><tr><td align=\"right\" valign=\"top\" bgcolor=\"$admincolor\">
  52. <font face=\"$fontface\" size=\"2\"><b>Password:</b></font></td>
  53. <td align=\"left\" valign=\"top\">
  54. <input type=\"password\" name=\"passwd\" size=\"25\" style=\"font-size: 8pt; font-family: $fontface; font-weight: bold\"></td>
  55. </tr><tr><td></td><td align=\"left\" valign=\"top\">
  56. <input type=\"submit\" value=\"Log in\" style=\"font-family: $fontface; font-size: 8pt; font-weight: bold; float: right\"></td>
  57. </tr></form></table></center></div></body></html>");
  58. unset($HTTP_SESSION_VARS);
  59. session_destroy();
  60. exit;
  61. } else {
  62. $res = mysql_query("select value from admin where field='login'");
  63. $dblogin = mysql_result($res, 0);
  64. $res = mysql_query("select value from admin where field='passwd'");
  65. $dbpasswd = mysql_result($res, 0);
  66. if ($asess_name != $dblogin || $asess_passwd != $dbpasswd || !ereg($self_name, $HTTP_REFERER)) {
  67. echo("<html><head><title>$title</title></head><body><p align=\"center\"><font face=\"$fontface\"><b>
  68. <span style=\"background-color: $admincolor\">&nbsp;$title Control Panel </span></b>
  69. </font></p><div align=\"center\"><center>
  70. <table border=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" cellpadding=\"0\" cellspacing=\"3\">
  71. <form method=post action=/control/><input type=hidden name=form value=sent><tr>
  72. <td align=\"right\" valign=\"top\" bgcolor=\"$admincolor\"><b>
  73. <font face=\"$fontface\" size=\"2\">Login</font>:</b></td>
  74. <td align=\"left\" valign=\"top\">
  75. <input type=\"text\" name=\"login\" size=\"25\" style=\"font-family: $fontface; font-size: 8pt; font-weight: bold\"></td>
  76. </tr><tr><td align=\"right\" valign=\"top\" bgcolor=\"$admincolor\">
  77. <font face=\"$fontface\" size=\"2\"><b>Password:</b></font></td>
  78. <td align=\"left\" valign=\"top\">
  79. <input type=\"password\" name=\"passwd\" size=\"25\" style=\"font-size: 8pt; font-family: $fontface; font-weight: bold\"></td>
  80. </tr><tr><td></td><td align=\"left\" valign=\"top\">
  81. <input type=\"submit\" value=\"Log in\" style=\"font-family: $fontface; font-size: 8pt; font-weight: bold; float: right\"></td>
  82. </tr></form></table></center></div></body></html>");
  83. unset($HTTP_SESSION_VARS);
  84. session_destroy();
  85. exit;
  86. }
  87. }
  88. .......
Similar Threads
Reputation Points: 16
Solved Threads: 0
Junior Poster
sfrider0 is offline Offline
149 posts
since Oct 2008
Aug 3rd, 2009
0

Re: code not doing anything

If your system has register_globals turned off in php.ini (the default in R5), then it doesn't look as if your code is dealing with it (e.g. if ($form == "sent").

It may not be related but on line 14 it seems that you would want it to say:
if ($form == "sent" ...
Last edited by chrishea; Aug 3rd, 2009 at 11:10 am.
Reputation Points: 210
Solved Threads: 228
Nearly a Posting Virtuoso
chrishea is offline Offline
1,389 posts
since Sep 2008
Aug 3rd, 2009
0

Re: code not doing anything

Well, I tried added the extra = and turning on global variables, still nothing. It acts as though I just refreshed the page.
Reputation Points: 16
Solved Threads: 0
Junior Poster
sfrider0 is offline Offline
149 posts
since Oct 2008
Aug 4th, 2009
0

Re: code not doing anything

When I ran your code, it tries to go to control/ which seems to be the way you coded it. Don't know why you can't get out of the initial module
Reputation Points: 210
Solved Threads: 228
Nearly a Posting Virtuoso
chrishea is offline Offline
1,389 posts
since Sep 2008
Aug 4th, 2009
0

Re: code not doing anything

Hi there,
I think the problem might be that you never assign values from the $_POST array into your variables ($login, $passwd, etc.) Unless you do this in your include('../vars.php'). But other wise your variable will always be empty.
Reputation Points: 49
Solved Threads: 22
Junior Poster
Menster is offline Offline
175 posts
since Jun 2009
Aug 5th, 2009
0

Re: code not doing anything

Well, I just took out the include statement and just copied the data in its place. vars.php is just my database information. Still nothing...
Reputation Points: 16
Solved Threads: 0
Junior Poster
sfrider0 is offline Offline
149 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Tender script
Next Thread in PHP Forum Timeline: PEAR package





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC