Raised This Month: $ Target: $400
 0% 

[PHP] Login Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shuttle_wave
Veteran Member
Join Date: Apr 2009
Location: New Zealand
Old 10-08-2010 , 04:59   [PHP] Login Help
Reply With Quote #1

PHP Code:
<?php include("header.php"); ?>

<?php
$User 
"Shuttle_Wave";
$Pass "testing";
?>

<center>

<h1>Admin Login Panel</h1>


<form action='checklogin.php' method='post'>

Username: <input type="text" name="username" />
Password: <input type="password" name="password" />
<input type="submit" name="Submit" value="Login" /></form>

</center>

<?php

if($_POST["username"] == $User && $_POST["password"] == $Pass)
{
    
session_register("username");
    
session_register("password");
    
header("location:main_system.php");
}
else
{
    echo 
"Incorrect Username or Password";
}

?>

<body>
</body>
</html>
i seem to be having problems with my php login i coded. it doesnt work and also it shows the Incorrent ... b4 i even login.

Sorry i am PHP coding beginner
__________________
JailBreak Mod with Plugin API ( 90% ) Public
shuttle_wave is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 10-08-2010 , 07:11   Re: [PHP] Login Help
Reply With Quote #2

it might be easier to make 2 pages
1 for login.php which contains the login form and aims at checklogin.php
checklogin.php can then contain the checks and redirect or echo instructions on what they got wrong
__________________
minimiller is offline
Send a message via MSN to minimiller
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-08-2010 , 12:10   Re: [PHP] Login Help
Reply With Quote #3

PHP Code:
if($_POST["username"] == $User && $_POST["password"] == $Pass
This is ALWAYS false on first load.
__________________
fysiks is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-08-2010 , 16:48   Re: [PHP] Login Help
Reply With Quote #4

PHP Code:
<?php

if(isset($_POST["username"]) && isset($_POST["password"]))
{
    if(
$_POST["username"] == $User && $_POST["password"] == $Pass)
    {
        
session_register("username");
        
session_register("password");
        
header("location:main_system.php");
    }
    else
    {
        echo 
"Incorrect Username or Password";
    }
}

?>
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
shuttle_wave
Veteran Member
Join Date: Apr 2009
Location: New Zealand
Old 10-08-2010 , 20:31   Re: [PHP] Login Help
Reply With Quote #5

PHP Code:
<?php include("header.php"); ?>

<?php
$User 
"Shuttle_Wave";
$Pass "test";
?>

<center>

<h1>Admin Login Panel</h1>


<form action='#' method='post'>

Username: <input type="text" name="username" id="username" />
Password: <input type="password" name="password" id="password" />
<input type="submit" name="Submit" value="Login" /></form>

</center>

<?php 

if(isset($_POST["username"]) && isset($_POST["password"])) 

    if(
$_POST["username"] == $User && $_POST["password"] == $Pass
    { 
        
session_register("username");
        
session_register("password");
        
header("location:system.php");
    } 
    else 
    { 
        echo 
"Incorrect Username or Password"
    } 


?>

<body>
</body>
</html>
i did that. it wrks but when i enter the correct user and password i get this error

PHP Code:
Warningsession_register() [function.session-register]: Cannot send session cookie headers already sent by (output started at C:\xampp\htdocs\header.php:12in C:\xampp\htdocs\login.php on line 27

Warning
session_register() [function.session-register]: Cannot send session cache limiter headers already sent (output started at C:\xampp\htdocs\header.php:12in C:\xampp\htdocs\login.php on line 27

Warning
Cannot modify header information headers already sent by (output started at C:\xampp\htdocs\header.php:12in C:\xampp\htdocs\login.php on line 29 

codes below is my system.php

PHP Code:
<?php include("header.php"); ?>
<?php 
include("databases.php"); ?>

<?
session_start
();
 
if(!
session_is_registered(username))
{
  
header("location:login.php");
}
?>

<center>

<h1>Login System Information</h1>

<?php

echo "<table border='1'>
    <tr class=\"table_head\">
        <th class=\"number\" style=\"min-width:20px;\">#</th>
        <th>&nbsp; Name &nbsp;</th>
        <th>&nbsp; UserName &nbsp;</th>
        <th>&nbsp; Password &nbsp;</th>
        <th>&nbsp; Status &nbsp;</th>
    </tr>"
;
    
    while(
$row mysql_fetch_array($result))
    {
        echo 
"<tr>";
        echo 
"<td class=\"number\">&nbsp;" $row['num'] .  "&nbsp;</td>";
        echo 
"<td class=\"center\">&nbsp;" $row['name'] . "&nbsp;</td>";
        echo 
"<td class=\"center\">&nbsp;" $row['username'] . "&nbsp;</td>";
        echo 
"<td class=\"center\">&nbsp;" $row['password'] . "&nbsp;</td>";
        echo 
"<td class=\"center\">&nbsp;" $row['status'] . "&nbsp;</td>";
        
        echo 
"</tr>";
    }

echo 
"</table>";

mysql_close($database);
?>

</center>

<body>
</body>
</html>
__________________
JailBreak Mod with Plugin API ( 90% ) Public
shuttle_wave is offline
8088
Veteran Member
Join Date: Jan 2008
Old 10-08-2010 , 20:51   Re: [PHP] Login Help
Reply With Quote #6

Is Google broken? Move session_start(); to the beginning of your code. By the way, a warning is not an error.
__________________
steamID converter with OpenSearch browser plugin
8088 is offline
platzpatrone
Veteran Member
Join Date: Apr 2007
Location: Germany
Old 10-08-2010 , 21:11   Re: [PHP] Login Help
Reply With Quote #7

and so many open and closing php tags in order they dont needed

PHP Code:
<?php 
session_start
(); 
  
if(!
session_is_registered(username)) 

  
header("location:login.php"); 


include(
"header.php");
include(
"databases.php");
 
echo 
"<body>";
echo 
"<center>";
echo 
"<h1>Login System Information</h1>";

echo 
"<table border='1'> 
    <tr class=\"table_head\"> 
        <th class=\"number\" style=\"min-width:20px;\">#</th> 
        <th>&nbsp; Name &nbsp;</th> 
        <th>&nbsp; UserName &nbsp;</th> 
        <th>&nbsp; Password &nbsp;</th> 
        <th>&nbsp; Status &nbsp;</th> 
    </tr>"

     
    while(
$row mysql_fetch_array($result)) 
    { 
        echo 
"<tr>"
        echo 
"<td class=\"number\">&nbsp;" $row['num'] .  "&nbsp;</td>"
        echo 
"<td class=\"center\">&nbsp;" $row['name'] . "&nbsp;</td>"
        echo 
"<td class=\"center\">&nbsp;" $row['username'] . "&nbsp;</td>"
        echo 
"<td class=\"center\">&nbsp;" $row['password'] . "&nbsp;</td>"
        echo 
"<td class=\"center\">&nbsp;" $row['status'] . "&nbsp;</td>"
         
        echo 
"</tr>"
    } 

echo 
"</table>"

mysql_close($database); 

echo 
"</center>";
echo 
"</body>";
echo 
"</html>";
?>
platzpatrone is offline
shuttle_wave
Veteran Member
Join Date: Apr 2009
Location: New Zealand
Old 10-08-2010 , 21:43   Re: [PHP] Login Help
Reply With Quote #8

Quote:
Originally Posted by platzpatrone View Post
and so many open and closing php tags in order they dont needed

PHP Code:
<?php 
session_start
(); 
  
if(!
session_is_registered(username)) 

  
header("location:login.php"); 


include(
"header.php");
include(
"databases.php");
 
echo 
"<body>";
echo 
"<center>";
echo 
"<h1>Login System Information</h1>";

echo 
"<table border='1'> 
    <tr class=\"table_head\"> 
        <th class=\"number\" style=\"min-width:20px;\">#</th> 
        <th>&nbsp; Name &nbsp;</th> 
        <th>&nbsp; UserName &nbsp;</th> 
        <th>&nbsp; Password &nbsp;</th> 
        <th>&nbsp; Status &nbsp;</th> 
    </tr>"

     
    while(
$row mysql_fetch_array($result)) 
    { 
        echo 
"<tr>"
        echo 
"<td class=\"number\">&nbsp;" $row['num'] .  "&nbsp;</td>"
        echo 
"<td class=\"center\">&nbsp;" $row['name'] . "&nbsp;</td>"
        echo 
"<td class=\"center\">&nbsp;" $row['username'] . "&nbsp;</td>"
        echo 
"<td class=\"center\">&nbsp;" $row['password'] . "&nbsp;</td>"
        echo 
"<td class=\"center\">&nbsp;" $row['status'] . "&nbsp;</td>"
         
        echo 
"</tr>"
    } 

echo 
"</table>"

mysql_close($database); 

echo 
"</center>";
echo 
"</body>";
echo 
"</html>";
?>
Quote:
Originally Posted by 8088 View Post
Is Google broken? Move session_start(); to the beginning of your code. By the way, a warning is not an error.
ty vm
__________________
JailBreak Mod with Plugin API ( 90% ) Public
shuttle_wave is offline
shuttle_wave
Veteran Member
Join Date: Apr 2009
Location: New Zealand
Old 10-08-2010 , 22:14   Re: [PHP] Login Help
Reply With Quote #9

i get this error now. I get that when i log in.

PHP Code:
Warningsession_register() [function.session-register]: Cannot send session cache limiter headers already sent (output started at C:\xampp\htdocs\header.php:12in C:\xampp\htdocs\login.php on line 27

Warning
Cannot modify header information headers already sent by (output started at C:\xampp\htdocs\header.php:12in C:\xampp\htdocs\login.php on line 29 
line 27 28 and 29 is
PHP Code:
        session_register("username");
        
session_register("password");
        
header("location:system.php"); 
__________________
JailBreak Mod with Plugin API ( 90% ) Public

Last edited by shuttle_wave; 10-08-2010 at 22:18.
shuttle_wave is offline
platzpatrone
Veteran Member
Join Date: Apr 2007
Location: Germany
Old 10-08-2010 , 22:33   Re: [PHP] Login Help
Reply With Quote #10

PHP Code:
<?php 
$User 
"Shuttle_Wave"
$Pass "test"

if(isset(
$_POST["username"]) && isset($_POST["password"]))  
{  
    if(
$_POST["username"] == $User && $_POST["password"] == $Pass)  
    {  
        
session_register("username"); 
        
session_register("password"); 
        
header("location:system.php"); 
    }  
    else  
    {  
        
$errormsg "Incorrect Username or Password";  
    }  
}  
include(
"header.php");
 
?> 
 <body>
<center> 

<h1>Admin Login Panel</h1> 

<?php if(!empty($errormsg)) echo $errormsg?>

<form action='#' method='post'> 

Username: <input type="text" name="username" id="username" /> 
Password: <input type="password" name="password" id="password" /> 
<input type="submit" name="Submit" value="Login" /></form> 

</center> 

</body> 
</html>
platzpatrone is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode