Hi everyone,
I have worked with php for about 2 months now and have stepped into created membership websites. I have learned allot from developphp.com and the thenewboston.com including many books. Anyways so I have been building this basic membership profile login when I go back to the home page it shows the user is logged in and I can view all the profile information but when i come to the login page and enter the user info and password for some reason every time I log in I get the error :
Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home/younga8/public_html/membersystem/connect_to_mysql.php:20) in /home/younga8/public_html/membersystem/login.php on line 24
Warning: Cannot modify header information - headers already sent by (output started at /home/younga8/public_html/membersystem/connect_to_mysql.php:20) in /home/younga8/public_html/membersystem/login.php on line 33
I tried relinking variables, checking for any spaces, and extra lines. Again I am a little new so maybe this may just be something simple. Here is my php code :
<?php if ($_POST['email']) { //Connect to the database through our include include_once "connect_to_mysql.php"; $email = stripslashes($_POST['email']); $email = strip_tags($email); $email = mysql_real_escape_string($email); $password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters $password = md5($password); // Make query and then register all database data that - // cannot be changed by member into SESSION variables. // Data that you want member to be able to change - // should never be set into a SESSION variable. $sql = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$password' AND emailactivated='1'"); $login_check = mysql_num_rows($sql); if($login_check > 0){ while($row = mysql_fetch_array($sql)){ // Get member ID into a session variable $id = $row["id"]; session_register('id'); $_SESSION['id'] = $id; // Get member username into a session variable $username = $row["username"]; session_register('username'); $_SESSION['username'] = $username; // Update last_log_date field for this member now mysql_query("UPDATE members SET lastlogin=now() WHERE id='$id'"); // Print success message here if all went well then exit the script header("www.youngamme.com/membersystem/member_profile.php?id=$id"); exit(); } // close while } else { // Print login failure message to the user and link them back to your login page print 'No match in our records, try again
Click here to go back to the login page.'; exit(); } }// close if post ?> Login to your profile
Log in to your account here
Email Address: |
|
Password: |
|
Thanks everyone any help is greatly appreciated