code not doing anything

Reply

Join Date: Oct 2008
Posts: 89
Reputation: sfrider0 is an unknown quantity at this point 
Solved Threads: 0
sfrider0 sfrider0 is offline Offline
Junior Poster in Training

code not doing anything

 
0
  #1
Aug 3rd, 2009
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.
  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. .......
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 214
Reputation: chrishea is an unknown quantity at this point 
Solved Threads: 32
chrishea's Avatar
chrishea chrishea is offline Offline
Posting Whiz in Training

Re: code not doing anything

 
0
  #2
Aug 3rd, 2009
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.
Chris
See my list of PHP development tools at:
InnovationsDesign.net
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 89
Reputation: sfrider0 is an unknown quantity at this point 
Solved Threads: 0
sfrider0 sfrider0 is offline Offline
Junior Poster in Training

Re: code not doing anything

 
0
  #3
Aug 3rd, 2009
Well, I tried added the extra = and turning on global variables, still nothing. It acts as though I just refreshed the page.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 214
Reputation: chrishea is an unknown quantity at this point 
Solved Threads: 32
chrishea's Avatar
chrishea chrishea is offline Offline
Posting Whiz in Training

Re: code not doing anything

 
0
  #4
Aug 4th, 2009
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
Chris
See my list of PHP development tools at:
InnovationsDesign.net
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 172
Reputation: Menster is an unknown quantity at this point 
Solved Threads: 22
Menster's Avatar
Menster Menster is offline Offline
Junior Poster

Re: code not doing anything

 
0
  #5
Aug 4th, 2009
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.
$me = new Person();
if (isset($_COOKIE)){
$me->eat($_COOKIE);
} else { $me->starve(); }
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 89
Reputation: sfrider0 is an unknown quantity at this point 
Solved Threads: 0
sfrider0 sfrider0 is offline Offline
Junior Poster in Training

Re: code not doing anything

 
0
  #6
Aug 5th, 2009
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...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC