Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 6th, 2012, 11:42 PM
Authorized User
Points: 64, Level: 1
Points: 64, Level: 1 Points: 64, Level: 1 Points: 64, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default error in line 27 please help

<?php
include("includes/function.php");
session_start();

if(isset($_POST['login']))
{
if(isset($_POST['username']))
{
if(isset($_POST['password']))
{
$username = $_POST['username'];
$query = mysql_query("select * from users where Username = '$username'") or die(mysql_error());

$user = mysql_fetch_array($query);

if(md5($_POST['password']) == $user['Password'])
{
echo "Login successful";
$_SESSION['user'] = $user['Username'];
header("Location: index.php");
}
else {
echo "Please check you Login details";
include("login.php");
}

else {
echo "Please check you password";
include("login.php");
}
else {
echo "Please check your username";
include("login.php");

}
else {
echo "Please check that you filled out the login form";
include("login.php");
}
}
}
}


?>
Reply With Quote
  #2 (permalink)  
Old June 6th, 2012, 11:45 PM
Authorized User
Points: 64, Level: 1
Points: 64, Level: 1 Points: 64, Level: 1 Points: 64, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

note::
is there a problem after first else??

i used else if but also no any correction found
Reply With Quote
  #3 (permalink)  
Old June 7th, 2012, 03:44 AM
Friend of Wrox
Points: 651, Level: 9
Points: 651, Level: 9 Points: 651, Level: 9 Points: 651, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Location: North East UK
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

You are missing some } and the 3 } at the end are not needed.
PHP Code:
<?php
include("includes/function.php");
session_start();

if(isset(
$_POST['login']))
{
    if(isset(
$_POST['username']))
    {
        if(isset(
$_POST['password']))
        {
            
$username $_POST['username'];
            
$query mysql_query("select * from users where Username = '$username'") or die(mysql_error());

            
$user mysql_fetch_array($query);

            if(
md5($_POST['password']) == $user['Password'])
            {
                echo 
"Login successful";
                
$_SESSION['user'] = $user['Username'];
                
header("Location: index.php");
            }
            else
            {
                echo 
"Please check you Login details";
                include(
"login.php");
            }
        }
        else
        {
            echo 
"Please check you password";
            include(
"login.php");
        }
    }
    else
    {
        echo 
"Please check your username";
        include(
"login.php");
    }
}
else
{
    echo 
"Please check that you filled out the login form";
    include(
"login.php");
}

?>
If when starting an if statement you start it like this;
Code:
if( test )
{
then the { needs to be closed BEFORE any else, if an else is required.

Last edited by UseLess; June 7th, 2012 at 03:47 AM..
Reply With Quote
  #4 (permalink)  
Old June 7th, 2012, 12:22 PM
Authorized User
Points: 64, Level: 1
Points: 64, Level: 1 Points: 64, Level: 1 Points: 64, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ye thanks it worked.. Hats off!! :)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 27: Modules And Handlers - Listing 27.2 Nikhil BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 0 February 4th, 2010 07:25 AM
Chapter 27 Run-time Error DaveHowland BOOK: Professional VB 2005 ISBN: 0-7645-7536-8 7 February 16th, 2008 09:32 PM
returning error line robertdavies Classic ASP Professional 2 September 30th, 2004 09:06 AM
Parse error on line that does not exist shabboleth Beginning PHP 1 December 19th, 2003 01:41 PM



All times are GMT -4. The time now is 10:06 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.