Link to home
Start Free TrialLog in
Avatar of farhadabas
farhadabas

asked on

Help With Cookies

hello i am new to php and i am making a login system using php but i am getting problems with it.
For example when you login it checks if a person has that name and password and if its true then :

        setcookie("user",$username);
        setcookie("pass",$password);
        header("location:console.php");

Ok then in the console.php it shows your profile like your username and email and msn:
Username: farhadabas
MSN: blahblah@hotmail.com

 Well then i have change profile link when you click it takes you to ch_profile.php. There you can change your info in the text boxes and stuff then when you click submit it sends this to chprofile.php. There it takes the info that you sent and updates the database with your new info. After it does that i want it to update the old cookie so it has the new username in it since you changed it. So i just put:      
 
 setcookie("user",'$_POST[username]');

username is the textbox name from the previous change profile page.

And after that  i have:

header("location:console.php");

Well when it goes to console.php again all the fields are empty for some reason. Like it says

Username: ________
MSN: _____________

but it should not be empty tho.

Oh yea and this is how it gets the info for your profile out of database in colsole.php:  

    $conn = mysql_connect($sql_host, $sql_username);
      mysql_select_db("$sql_database",$conn);
      $sql="SELECT * FROM members where username='$_COOKIE[user]' and password= '$_COOKIE[pass]'";
      $result = mysql_query($sql, $conn) or die(mysql_error());

      while ($newArray = mysql_fetch_array($result)) {

         $password  = $newArray['password'];
         $username = $newArray['username'];
         $msn = $newArray['msn'];
         $email = $newArray['email'];

Can someone tell me how to fix it so when you click submit and after it updates the cookie that in the console your profile info is not empty?

Help REALLY APPRECIATED
ASKER CERTIFIED SOLUTION
Avatar of crazycomputers
crazycomputers

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of farhadabas
farhadabas

ASKER

Thanks alot man i really appreciate your help. You deserve an A :-D
You're welcome, and thanks!  =)