Cms login error

This is guide mostly for website tools and code, for example CMS or registration scripts.
There can also be tools.

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Cms login error

Postby Ultra on Sat Apr 21, 2012 11:28 pm

Hi!
Im making a new website layout/design and im getting some errors when i try to login
login.php:
  1. <?php
  2. session_start(); // start up your PHP session!
  3. require ('config.php');
  4. ?>
  5.  
  6. <br /><br /><div class="formitem" style="width:250px;overflow: hidden;">
  7. <form id="form1" name="form1" method="post" action="?op=ulogin">
  8.   <p align="center" class="tdglobal"><span class="b01"><?php echo $DynCMS['title']; ?> User Control Panel</span></p>
  9.   <table width="200" border="0" align="center" class="liteoption">
  10.     <tr>
  11.       <td width="97" class="center"><div align="center"><b>Username:</b></div></td>
  12.       <td width="93" class="center"><input name="user" type="text" class="liteoption" id="user" size="15" maxlength="15" /></td>
  13.     </tr>
  14.     <tr>
  15.       <td class="center"><div align="center"><b>Password:</b></div></td>
  16.       <td class="center"><input name="pass" type="password" class="liteoption" id="pass" size="15" maxlength="15" /></td>
  17.     </tr>
  18.   </table>
  19.   <p align="center" class="tdglobal"><span class="center">
  20.     <input name="submit" type="submit" class="liteoption" id="submit" value="Log In" size="15" maxlength="15" />
  21.   </span></p>
  22. </form>
  23. <p align="center" class="tdglobal"></div>
  24.   <?php
  25. if(isset($_POST['submit'])) {
  26. $U = $_POST['user'];
  27. $P = md5($_POST['pass']);
  28.  
  29. require ('config.php');
  30.  
  31. $result1 = "SELECT * FROM `accounts` WHERE username='$U' and password='$P' and accesslevel >= '100'";
  32. $query = mysql_query($result1);
  33.  
  34. $count = mysql_num_rows($query);
  35.  
  36.  
  37. if($count == 1){
  38.  
  39. session_register("User_Name");
  40. session_register("User_Pass");
  41. $_SESSION['account'] = $_POST['user'];
  42. echo('Logged in.... Click <a href=user><strong>here</strong></a>');
  43. }
  44. else {
  45. echo "<strong>Try Again</strong>";
  46. }
  47. }
  48. ?>
  49.   <br />
  50. </p>
  51.  ------------------------------------------------------------------------------------------------------------------------
  52.  
config.php
  1. <?php
  2.  
  3. // Make a MySQL Connection
  4. mysql_connect("localhost", "root", "root") or die(mysql_error());
  5. mysql_select_db("irose") or die(mysql_error());
  6.  
  7. ?>


The problem is when i click "Logged in.... Click here"
i have make it to redirect the users to user.php
and it writes:
[You must log in you noob!]
( I am using some iframes )
When im using a normal login.php from dynastycms
it writes
Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\irosetest\web\images\items\login.php:22) in C:\AppServ\www\irosetest\web\images\items\login.php on line 53
Logged in.... Click here
and when i click "Logged in.... Click here " it redirects me again to login.php
(dynasty cms login.php) - edited by me
  1. */
  2. ?>
  3. <form id="form1" name="form1" method="post" action="?op=login">
  4.   <p align="center" class="tdglobal"><span class="b01"><?php echo $DynCMS['title']; ?> User Control Panel</span></p>
  5.   <table width="200" border="0" align="center" class="liteoption">
  6.     <tr>
  7.       <td width="97" class="center"><div align="center"><b>Username:</b></div></td>
  8.       <td width="93" class="center"><input name="user" type="text" class="liteoption" id="user" size="15" maxlength="15" /></td>
  9.     </tr>
  10.     <tr>
  11.       <td class="center"><div align="center"><b>Password:</b></div></td>
  12.       <td class="center"><input name="pass" type="password" class="liteoption" id="pass" size="15" maxlength="15" /></td>
  13.     </tr>
  14.   </table>
  15.   <p align="center" class="tdglobal"><span class="center">
  16.     <input name="submit" type="submit" class="liteoption" id="submit" value="Log In" size="15" maxlength="15" />
  17.   </span></p>
  18. </form>
  19. <p align="center" class="tdglobal">
  20.   <?php
  21. if(isset($_POST['submit'])) {
  22. $U = $_POST['user'];
  23. $P = md5($_POST['pass']);
  24.  
  25. require("config.php");
  26.  
  27. $result1 = "SELECT * FROM `accounts` WHERE username='$U' and password='$P' and accesslevel >= '100'";
  28. $query = mysql_query($result1);
  29.  
  30. $count = mysql_num_rows($query);
  31.  
  32.  
  33. if($count == 1){
  34.  
  35. session_register("User_Name");
  36. session_register("User_Pass");
  37. $_SESSION['account'] = $_POST['user'];
  38. echo('Logged in.... Click <a href=?op=user><strong>here</strong></a>');
  39. }
  40. else {
  41. echo "<strong>Try Again</strong>";
  42. }
  43. }
  44. ?>
  45.   <br />
  46. </p>
  47. --------------------------------------------------------------------------------------------------------

Soo can someone help me ?
Ultra
Rackie
Rackie
 
Posts: 225
Joined: Thu Jul 22, 2010 6:31 pm
Location: Usa

Re: Cms login error

Postby hoegarden31 on Sun Apr 22, 2012 12:18 am

Check if you pass your session to your other pages.
It looks like you forgot to send the session to your page user.php, and so it redirect you to the login page.
Common mistake for a beginner :lol:
I'm the one and only. In heaven and on earth.
Image
hoegarden31
Rackie
Rackie
 
Posts: 150
Joined: Sun Nov 13, 2011 7:13 pm

Re: Cms login error

Postby Vetyst on Sun Apr 22, 2012 1:02 pm

Ultra wrote:Hi!
Im making a new website layout/design and im getting some errors when i try to login
login.php:
  1. <?php
  2. session_start(); // start up your PHP session!
  3. require ('config.php');
  4. ?>
  5.  
  6. <br /><br /><div class="formitem" style="width:250px;overflow: hidden;">
  7. <form id="form1" name="form1" method="post" action="?op=ulogin">
  8.   <p align="center" class="tdglobal"><span class="b01"><?php echo $DynCMS['title']; ?> User Control Panel</span></p>
  9.   <table width="200" border="0" align="center" class="liteoption">
  10.     <tr>
  11.       <td width="97" class="center"><div align="center"><b>Username:</b></div></td>
  12.       <td width="93" class="center"><input name="user" type="text" class="liteoption" id="user" size="15" maxlength="15" /></td>
  13.     </tr>
  14.     <tr>
  15.       <td class="center"><div align="center"><b>Password:</b></div></td>
  16.       <td class="center"><input name="pass" type="password" class="liteoption" id="pass" size="15" maxlength="15" /></td>
  17.     </tr>
  18.   </table>
  19.   <p align="center" class="tdglobal"><span class="center">
  20.     <input name="submit" type="submit" class="liteoption" id="submit" value="Log In" size="15" maxlength="15" />
  21.   </span></p>
  22. </form>
  23. <p align="center" class="tdglobal"></div>
  24.   <?php
  25. if(isset($_POST['submit'])) {
  26. $U = $_POST['user'];
  27. $P = md5($_POST['pass']);
  28.  
  29. require ('config.php');
  30.  
  31. $result1 = "SELECT * FROM `accounts` WHERE username='$U' and password='$P' and accesslevel >= '100'";
  32. $query = mysql_query($result1);
  33.  
  34. $count = mysql_num_rows($query);
  35.  
  36.  
  37. if($count == 1){
  38.  
  39. session_register("User_Name");
  40. session_register("User_Pass");
  41. $_SESSION['account'] = $_POST['user'];
  42. echo('Logged in.... Click <a href=user><strong>here</strong></a>');
  43. }
  44. else {
  45. echo "<strong>Try Again</strong>";
  46. }
  47. }
  48. ?>
  49.   <br />
  50. </p>
  51.  ------------------------------------------------------------------------------------------------------------------------
  52.  
config.php
  1. <?php
  2.  
  3. // Make a MySQL Connection
  4. mysql_connect("localhost", "root", "root") or die(mysql_error());
  5. mysql_select_db("irose") or die(mysql_error());
  6.  
  7. ?>


The problem is when i click "Logged in.... Click here"
i have make it to redirect the users to user.php
and it writes:
[You must log in you noob!]
( I am using some iframes )
When im using a normal login.php from dynastycms
it writes
Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\irosetest\web\images\items\login.php:22) in C:\AppServ\www\irosetest\web\images\items\login.php on line 53
Logged in.... Click here
and when i click "Logged in.... Click here " it redirects me again to login.php
(dynasty cms login.php) - edited by me
  1. */
  2. ?>
  3. <form id="form1" name="form1" method="post" action="?op=login">
  4.   <p align="center" class="tdglobal"><span class="b01"><?php echo $DynCMS['title']; ?> User Control Panel</span></p>
  5.   <table width="200" border="0" align="center" class="liteoption">
  6.     <tr>
  7.       <td width="97" class="center"><div align="center"><b>Username:</b></div></td>
  8.       <td width="93" class="center"><input name="user" type="text" class="liteoption" id="user" size="15" maxlength="15" /></td>
  9.     </tr>
  10.     <tr>
  11.       <td class="center"><div align="center"><b>Password:</b></div></td>
  12.       <td class="center"><input name="pass" type="password" class="liteoption" id="pass" size="15" maxlength="15" /></td>
  13.     </tr>
  14.   </table>
  15.   <p align="center" class="tdglobal"><span class="center">
  16.     <input name="submit" type="submit" class="liteoption" id="submit" value="Log In" size="15" maxlength="15" />
  17.   </span></p>
  18. </form>
  19. <p align="center" class="tdglobal">
  20.   <?php
  21. if(isset($_POST['submit'])) {
  22. $U = $_POST['user'];
  23. $P = md5($_POST['pass']);
  24.  
  25. require("config.php");
  26.  
  27. $result1 = "SELECT * FROM `accounts` WHERE username='$U' and password='$P' and accesslevel >= '100'";
  28. $query = mysql_query($result1);
  29.  
  30. $count = mysql_num_rows($query);
  31.  
  32.  
  33. if($count == 1){
  34.  
  35. session_register("User_Name");
  36. session_register("User_Pass");
  37. $_SESSION['account'] = $_POST['user'];
  38. echo('Logged in.... Click <a href=?op=user><strong>here</strong></a>');
  39. }
  40. else {
  41. echo "<strong>Try Again</strong>";
  42. }
  43. }
  44. ?>
  45.   <br />
  46. </p>
  47. --------------------------------------------------------------------------------------------------------

Soo can someone help me ?



Witch version of php are you using ?
if you dont know, create a new file as a type .php with this content :

xx.php
User avatar
Vetyst
osRose dev
osRose dev
 
Posts: 146
Joined: Sat Jun 18, 2011 10:56 am
Location: The Netherlands

Re: Cms login error

Postby Ultra on Wed Apr 25, 2012 8:04 pm

@hoegarden31
it works fine
- FIXED
Ultra
Rackie
Rackie
 
Posts: 225
Joined: Thu Jul 22, 2010 6:31 pm
Location: Usa


Return to PHP / Web Guides, Scripts and tools.

Who is online

Users browsing this forum: No registered users and 5 guests

cron