cbz_extreme's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
5 (0.01 per day)
Joined:
23-December 11
Profile Views:
284
Last Active:
User is offline Nov 05 2012 05:26 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   cbz_extreme has not set their status

Posts I've Made

  1. In Topic: Log in Script Error

    Posted 24 Dec 2011

    View PostAtli, on 23 December 2011 - 07:10 AM, said:

    There are a couple of other things that are worth looking at:

    • Never use the return value of mysql_query() without making sure it is valid.
      // Either do:
      $result = mysql_query($sql) or die(mysql_error());
      
      // Or, if you don't want the error to show on
      // production servers (which you shouldn't):
      $result = mysql_query($sql) or trigger_error(mysql_error(), E_USER_ERROR);
      
      // You could also just do:
      $result = mysql_query($sql);
      if ($result) {
          // ...
      }
      else {
          trigger_error(mysql_error(), E_USER_ERROR);
      }
      
      


    • Don't SELECT * if you don't intend to use ALL the data. Your SELECT statements should never fetch fields you don't intend to use. Otherwise you are just wasting resources. - If all you need is to count the number of rows the query would return, use the SQL COUNT() function:
      $sql = "SELECT COUNT(*) FROM members 
              WHERE username='$username' 
              AND   password='$password'";
      $result = mysql_query($sql) or trigger_error(mysql_error(), E_USER_ERROR);
      
      $row = mysql_fetch_row($result);
      $count = $row[0];
      
      


    Thank you. I will follow your advice.

    View PostDuckington, on 23 December 2011 - 07:48 AM, said:

    The header's already sent error is given when some form of output has been sent to the browser, as an echo or a print, or a php error/notice, or sometimes even whitespace. So you need to make sure that in all the lines leading up to the header() call, nothing is sent to the browser. So for example, if there was an error with one of your mysql functions that output an error to the browser, that would cause the header's already sent message.

    So check what's happening on line 9.


    As for "sending the password"... why do you want to send the password? You have already checked that the password is correct when they've logged in, you don't need to do anything else with it now. Use the username as the session to identify them.

    If you really think you need to store the password in a session, first explain to me/us why you want to do that and what you are planning to do with the password session to need to do it.

    Thank you. I got the point. There is no need to send password in the session.
  2. In Topic: Log in Script Error

    Posted 23 Dec 2011

    View PostDuckington, on 23 December 2011 - 06:57 AM, said:

    At the top of your checklogin.php page, put:

    session_start();
    
    


    That will..start a session.

    Then when you want to set the user's session, instead of using register, do:

    $_SESSION['username'] = $username; // Or whatever you want to store in the session
    
    


    I would also strongly advise you not to store the password in a session, there is no point to it and only leads to possible/probable security problems.



    To Duckington,

    I have put session_start(); at the top

    and put the code
     
         if($count==1)
     
         {
           $_SESSION['username']=$username;
           $_SESSION['password']=$password;
     
           header("Location: login_sucess.php");
        }
     
    
    



    But still there are some errors:

    Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\easy\checklogin.php:9) in C:\xampp\htdocs\easy\checklogin.php on line 10

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\easy\checklogin.php:9) in C:\xampp\htdocs\easy\checklogin.php on line 10

    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\easy\checklogin.php:9) in C:\xampp\htdocs\easy\checklogin.php on line 43

    Please tell me some other way to send password.
  3. In Topic: Log in Script Error

    Posted 23 Dec 2011

    To Duckington,

    I have put session_start(); at the top

    and
             if($count==1)
             {
    	 $_SESSION['username']=$username;
    	 $_SESSION['password']=$password;
    	 
    	header("Location: login_sucess.php"); 
            }
            
    


    But still there are some errors:

    Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\easy\checklogin.php:9) in C:\xampp\htdocs\easy\checklogin.php on line 10

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\easy\checklogin.php:9) in C:\xampp\htdocs\easy\checklogin.php on line 10

    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\easy\checklogin.php:9) in C:\xampp\htdocs\easy\checklogin.php on line 43

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

cbz_extreme hasn't added any friends yet.

Comments

cbz_extreme has no profile comments yet. Why not say hello?