Page 1 of 3

I need help w/ my login script

Posted: Mon Jun 26, 2006 7:51 pm
by 4Boredom
Alright... my MySQL database is set up correctly with user registration details.... Now I need to get the login fixed... any help would be appreciated

Basically I just want it to login and go to a main.php where I will later set up a control panel for the individual user. For now I just want it to say Hi "usersfirstname" and then post a logout option. Right now In my main.php I get the following errors

Warning: main(login_success.php): failed to open stream: No such file or directory in /home/i4boredo/public_html/main.php on line 8

Warning: main(login_success.php): failed to open stream: No such file or directory in /home/i4boredo/public_html/main.php on line 8

Warning: main(): Failed opening 'login_success.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/i4boredo/public_html/main.php on line 8


login.php

Code: Select all

<?php require("header.php"); ?>

<center>
<br><b>User Login</b><br>
<FORM ACTION="main.php" METHOD="post" name="loginform"> 
  <DIV ALIGN="justify"> 
    <TABLE WIDTH="50%" BORDER="0" ALIGN="center" CELLPADDING="4" CELLSPACING="0" align="center"> 
      <TR>  
        <TD WIDTH="22%">E-Mail Address</TD> 
        <TD WIDTH="78%"><INPUT name="email_address" TYPE="email_address" id="email_address"></TD> 
      </TR> 
      <TR>  
        <TD>Password</TD> 
        <TD><INPUT name="password" TYPE="password" id="password"></TD> 
      </TR> 
      <TR>  
        <TD> </TD> 
        <TD><INPUT TYPE="submit" name="Submit" VALUE="Submit"></TD> 
      </TR> 
    </TABLE> 
	</center>
  </DIV> 
</FORM> 
</BODY> 
</HTML>
login_sucess.php

Code: Select all

<? 
/* start the session */ 
session_start(); 

# error handler, if userid is blank, make them sign in
if ( empty( $userid ) ) { 
    print "Please login below!"; 
    include 'login.php'; 
} else { 

include 'db.php'; 

/* this prints at the top of the page. */ 
echo "Welcome, ". $_SESSION['first_name'] .". You are now in our exclusive 'Members Only' section.<br>"; 
 
/* always prints the logout page, just in case the user is done */ 
echo "<br><br><br><b><a href=logout.php>Logout</a><br>"; 
print "<br><br><br><br>"; 
?>
logout.php

Code: Select all

<?php 
session_start(); 

if(!isset($_REQUEST['logmeout'])){ 
    session_unset(); 
    session_destroy(); 
    if(!session_is_registered('userid')){ 
        echo "<center><font color=red><strong>You are now logged out!</strong></font></center><br />"; 
        echo "<center><strong>Login:</strong></center><br />"; 
        include 'login.php'; 
    } 
} 
?>
main.php

Code: Select all

<?php require("header.php"); ?>



Search coming soon...

<?php
include 'login_success.php';
?>
</td></tr>
</table>



</center>
</body>

</html>

Posted: Mon Jun 26, 2006 8:34 pm
by phpCCore Brad
Your file name is: login_sucess.php, but your include is correctly spelled login_success.php... IE Your file is named wrong. Well assuming you put the right file here. In any case the file login_success.php is not including because it does not exist.

Posted: Tue Jun 27, 2006 3:46 am
by Roja
Dupe thread much?

viewtopic.php?t=50679

Posted: Tue Jun 27, 2006 8:23 am
by phpCCore Brad
He didn't really duplicate the post. He posted about his registration script. Which, is because he is just learning php and had no idea how to do a SQL insert.

Posted: Wed Jun 28, 2006 1:30 pm
by 4Boredom
alright yeah.... as Brad said one was about the registration script...

anyways... fixing the file name eliminated 2 errors.....

however...I now get the following error

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/i4boredo/public_html/header.php:16) in /home/i4boredo/public_html/login_success.php on line 3

Every file has header.php included.... so in my login.php where it has "include 'login.php'; ", that duplicates the header. Is there any alternative?

Does anything think it would work if I made a login2.php without the header.php and just did a phpinclude in my errors handler on login.php?

Or is there a better approach?

Posted: Wed Jun 28, 2006 1:38 pm
by RobertGonzalez
Please, search for 'Headers already sent' on these boards. This question has been asked probably ten times in the last two weeks. I personally have explained it about five times in that same period. Search, and if you can't figure it out, then post back.

Posted: Wed Jun 28, 2006 10:10 pm
by tecktalkcm0391
I think, I even talked to you about this in a PM and told you to do this:

Code: Select all

<?php
ob_start();

// Code

ob_flush();
?>
Do you remember me telling you this? And do you get what goes on with the to things I put in the example? Cause the only way to really learn PHP is not just to take the code, but try to understand it. :D

Posted: Sun Jul 02, 2006 9:47 pm
by 4Boredom
no I have no clue what that means

Posted: Sun Jul 02, 2006 10:19 pm
by John Cartwright
tecktalkcm0391 wrote:I think, I even talked to you about this in a PM and told you to do this:

Code: Select all

<?php
ob_start();

// Code

ob_flush();
?>
Do you remember me telling you this? And do you get what goes on with the to things I put in the example? Cause the only way to really learn PHP is not just to take the code, but try to understand it. :D
That is what we call a bandaid approach as it only covers up the real proper. Why not fix it properly?

Posted: Mon Jul 03, 2006 12:16 am
by RobertGonzalez
I can't count the number of times someone has offered bandaid answers to errors and notices. The fact is, covering up the output of an error message just makes PHP quieter. It does nothing to fix the issue that is throwing the error/notice. Fix what is causing the notice and the notice goes away.

Posted: Mon Jul 03, 2006 12:46 am
by 4Boredom
I have searched several times for headers already sent and am getting nothing

Posted: Mon Jul 03, 2006 12:49 am
by RobertGonzalez
Go to search, enter the term 'Headers already sent' (without the quotes) and check the Search for all terms radio button. It just returned 504 results on these boards.

Posted: Mon Jul 03, 2006 1:37 am
by 4Boredom
none of them work for me...

The best example is viewtopic.php?t=1157

And here I still get an error:

Parse error: parse error, unexpected '?', expecting ',' or ')' in /home/i4boredo/public_html/login_success.php on line 3

Posted: Mon Jul 03, 2006 1:38 am
by 4Boredom
I tried doing this

Code: Select all

<?php 

if ( isset($_POST?'submit']) ) { 
        if ( empty($userid']) { 
                header("Location: memberok.php"); 
        } else { 
                echo 'Login incorrect.'; 
        } 
} 
?>

theres an error on line 3 which is the if (isset line

Posted: Mon Jul 03, 2006 11:57 am
by 4Boredom
so does anyone know what the error there is?

hopefully this can fix my headers issue thats been holding me up all week