Results 1 to 9 of 9
  1. #1
    Join Date
    May 2005
    Location
    /etc/passwd
    Posts
    19,110
    Tokens
    1,139

    Latest Awards:

    Default PHP/MySQL Error.

    Hello

    Im getting:

    Code:
    Parse error:  parse error in c:\program files\easyphp1-8\www\djpanelbeta\PHP_Coding\Msystem\login.php on line 14
    


    And heres the PHP Code:

    PHP Code:
    <?
    oB_start
    ();
    // allows you to use cookies.
    include("config.php");
    if (!
    $logged[username])
    {
    if (!
    $_POST[login])
    {
    echo(
    "
    <center><form method=\"POST\">
    <table>
    <tr>
    <td align=\"right\">
    <div align="
    center">Username: 
    <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\">
    </div></td>
    </tr>
    <tr>
    <td align=\"right\">
    <div align="
    center">Password: 
    <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\">
    </div></td></tr><tr>
    <td align=\"center\">
    <input type=\"submit\" name=\"login\" value=\"Login\"></td></tr><tr>
    <td align=\"center\">
    <div align="
    center">All Login attemps are logged. Please do not abuse the system! </div></td>
    </tr></table>
    </form></center>"
    );
    }
    if (
    $_POST[login]) {
    // the form has been submitted.  We continue...
    $username=$_POST['username'];
    $password md5($_POST[password]);
    // the above lines set variables with the submitted information.  
    $info mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    $data mysql_fetch_array($info);
    if(
    $data[password] != $password) {
    // the password was not the user's password!
    echo "Incorrect username or password!";
    }else{
    // the password was right!
    $query mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    $user mysql_fetch_array($query);
    // gets the user's information
    setcookie("id"$user[id],time()+(60*60*24*5), "/""");
    setcookie("pass"$user[password],time()+(60*60*24*5), "/""");
    // the above lines set 2 cookies. 1 with the user's id and another with his/her password.  
    echo ("<meta http-equiv=\"Refresh\" content=\"0; URL=http://localhost/DJPanelBETA/index"/>Thank YouYou will be redirected");
    // modify the above line...add in your site url instead of yoursite.com
    }
    }
    }
    else
    {
    // we now display the user controls.
    $new = mysql_query("select from pmessages where unread 'unread' and touser '$logged[username]'");
    $new = mysql_num_rows($new);
    echo ("
    <center>Welcome <b>$logged[username]</b><br /></center>
    - <
    a href=\"editprofile.php\">Edit Profile</a><br />
    - <a href=\"members.php\">Member List</a><br />
    - <a href=\"messages.php\">Private Message Center (
    $new new)</a><br />
    - <a href=\"logout.php\">Logout</a>"
    );
    }
    ?>
    Please could someone figure this out?
    Im a newbie at PHP and that is part of the Techtuts Usersystem, but I am going to change it ALOT!

    Thanks
    Tom
    Quote Originally Posted by Chippiewill View Post
    e-rebel forum moderator
    :8

  2. #2
    Join Date
    Nov 2006
    Posts
    163
    Tokens
    0

    Default

    PHP Code:
     <?
    oB_start
    ();
    // allows you to use cookies.
    include("config.php");
    if (!
    $logged[username])
    {
    if (!
    $_POST[login])
    {
    echo(
    "
    <center><form method=\"POST\">
    <table>
    <tr>
    <td align=\"right\">
    <div align=\"center\">Username: 
    <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\">
    </div></td>
    </tr>
    <tr>
    <td align=\"right\">
    <div align=\"center\">Password: 
    <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\">
    </div></td></tr><tr>
    <td align=\"center\">
    <input type=\"submit\" name=\"login\" value=\"Login\"></td></tr><tr>
    <td align=\"center\">
    <div align=\"center\">All Login attemps are logged. Please do not abuse the system! </div></td>
    </tr></table>
    </form></center>"
    );
    }
    if (
    $_POST[login]) {
    // the form has been submitted.  We continue...
    $username=$_POST['username'];
    $password md5($_POST[password]);
    // the above lines set variables with the submitted information.  
    $info mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    $data mysql_fetch_array($info);
    if(
    $data[password] != $password) {
    // the password was not the user's password!
    echo "Incorrect username or password!";
    }else{
    // the password was right!
    $query mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    $user mysql_fetch_array($query);
    // gets the user's information
    setcookie("id"$user[id],time()+(60*60*24*5), "/""");
    setcookie("pass"$user[password],time()+(60*60*24*5), "/""");
    // the above lines set 2 cookies. 1 with the user's id and another with his/her password.  
    echo ("<meta http-equiv=\"Refresh\" content=\"0; URL=http://localhost/DJPanelBETA/index"/>Thank YouYou will be redirected");
    // modify the above line...add in your site url instead of yoursite.com
    }
    }
    }
    else
    {
    // we now display the user controls.
    $new = mysql_query("select from pmessages where unread 'unread' and touser '$logged[username]'");
    $new = mysql_num_rows($new);
    echo ("
    <center>Welcome <b>$logged[username]</b><br /></center>
    - <
    a href="editprofile.php\">Edit Profile</a><br />
    - <a href=\"members.php\">Member List</a><br />
    - <a href=\"messages.php\">Private Message Center (
    $new new)</a><br />
    - <a href=\"logout.php\">Logout</a>"
    );
    }
    ?>

  3. #3
    Join Date
    Jul 2005
    Location
    -
    Posts
    2,995
    Tokens
    0

    Latest Awards:

    Default

    when i code php i can never add a table in php echo for some reason if that helps

  4. #4
    Join Date
    May 2005
    Location
    /etc/passwd
    Posts
    19,110
    Tokens
    1,139

    Latest Awards:

    Default

    Thats fixed thanks to :Blobbed

    Now its the same but on line 48!

    PHP Code:
    <?
    oB_start
    ();
    // allows you to use cookies.
    include("config.php");
    if (!
    $logged[username])
    {
    if (!
    $_POST[login])
    {
    echo(
    "
    <center><form method=\"POST\">
    <table>
    <tr>
    <td align=\"right\">
    <div align=\"center\">Username: 
    <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\">
    </div></td>
    </tr>
    <tr>
    <td align=\"right\">
    <div align=\"center\">Password: 
    <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\">
    </div></td></tr><tr>
    <td align=\"center\">
    <input type=\"submit\" name=\"login\" value=\"Login\"></td></tr><tr>
    <td align=\"center\">
    <div align=\"center\">All Login attemps are logged. Please do not abuse the system! </div></td>
    </tr></table>
    </form></center>"
    );
    }
    if (
    $_POST[login]) {
    // the form has been submitted.  We continue...
    $username=$_POST['username'];
    $password md5($_POST[password]);
    // the above lines set variables with the submitted information.  
    $info mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    $data mysql_fetch_array($info);
    if(
    $data[password] != $password) {
    // the password was not the user's password!
    echo "Incorrect username or password!";
    }else{
    // the password was right!
    $query mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    $user mysql_fetch_array($query);
    // gets the user's information
    setcookie("id"$user[id],time()+(60*60*24*5), "/""");
    setcookie("pass"$user[password],time()+(60*60*24*5), "/""");
    // the above lines set 2 cookies. 1 with the user's id and another with his/her password.  
    echo ("<meta http-equiv=\"Refresh\" content=\"0; URL=http://localhost/DJPanelBETA/index2.php"/>Thank YouYou will be redirected");
    // modify the above line...add in your site url instead of yoursite.com
    }
    }
    }
    else
    {
    // we now display the user controls.
    $new = mysql_query("select from pmessages where unread 'unread' and touser '$logged[username]'");
    $new = mysql_num_rows($new);
    echo ("
    <center>Welcome <b>$logged[username]</b><br /></center>
    - <
    a href="editprofile.php\">Edit Profile</a><br />
    - <a href=\"members.php\">Member List</a><br />
    - <a href=\"messages.php\">Private Message Center (
    $new new)</a><br />
    - <a href=\"logout.php\">Logout</a>"
    );
    }
    ?>
    Code:
    Parse error: parse error in c:\program files\easyphp1-8\www\djpanelbeta\PHP_Coding\Msystem\login.php on line 48
    Quote Originally Posted by Chippiewill View Post
    e-rebel forum moderator
    :8

  5. #5
    Join Date
    Nov 2006
    Posts
    163
    Tokens
    0

    Default

    PHP Code:
    <?
    oB_start
    ();
    // allows you to use cookies.
    include("config.php");
    if (!
    $logged[username])
    {
    if (!
    $_POST[login])
    {
    echo(
    "
    <center><form method=\"POST\">
    <table>
    <tr>
    <td align=\"right\">
    <div align=\"center\">Username: 
    <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\">
    </div></td>
    </tr>
    <tr>
    <td align=\"right\">
    <div align=\"center\">Password: 
    <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\">
    </div></td></tr><tr>
    <td align=\"center\">
    <input type=\"submit\" name=\"login\" value=\"Login\"></td></tr><tr>
    <td align=\"center\">
    <div align=\"center\">All Login attemps are logged. Please do not abuse the system! </div></td>
    </tr></table>
    </form></center>"
    );
    }
    if (
    $_POST[login]) {
    // the form has been submitted.  We continue...
    $username=$_POST['username'];
    $password md5($_POST[password]);
    // the above lines set variables with the submitted information.  
    $info mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    $data mysql_fetch_array($info);
    if(
    $data[password] != $password) {
    // the password was not the user's password!
    echo "Incorrect username or password!";
    }else{
    // the password was right!
    $query mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    $user mysql_fetch_array($query);
    // gets the user's information
    setcookie("id"$user[id],time()+(60*60*24*5), "/""");
    setcookie("pass"$user[password],time()+(60*60*24*5), "/""");
    // the above lines set 2 cookies. 1 with the user's id and another with his/her password.  
    echo ("<meta http-equiv=\"Refresh\" content=\"0\"; URL=\"http://localhost/DJPanelBETA/index2.php\" />Thank You! You will be redirected");
    // modify the above line...add in your site url instead of yoursite.com
    }
    }
    }
    else
    {
    // we now display the user controls.
    $new mysql_query("select * from pmessages where unread = 'unread' and touser = '$logged[username]'");
    $new mysql_num_rows($new);
    echo (
    "<center>Welcome <b>$logged[username]</b><br /></center>
    - <a href=\"editprofile.php\">Edit Profile</a><br />
    - <a href=\"members.php\">Member List</a><br />
    - <a href=\"messages.php\">Private Message Center (
    $new new)</a><br />
    - <a href=\"logout.php\">Logout</a>"
    );
    }
    ?>
    Should work now

  6. #6
    Join Date
    May 2005
    Location
    /etc/passwd
    Posts
    19,110
    Tokens
    1,139

    Latest Awards:

    Default

    Almost there!!

    Now i can see login form and all, Ive got 4 errors which I could fix if i knew what:
    Code:
    Notice: Undefined index
    Meant, So what does that mean? (It does tell me were and that but i want to learn to fix it my self )
    Last edited by Recursion; 05-12-2006 at 07:41 PM.
    Quote Originally Posted by Chippiewill View Post
    e-rebel forum moderator
    :8

  7. #7
    Join Date
    Jul 2005
    Location
    -
    Posts
    2,995
    Tokens
    0

    Latest Awards:

    Default

    no index page?

  8. #8
    Join Date
    May 2005
    Location
    /etc/passwd
    Posts
    19,110
    Tokens
    1,139

    Latest Awards:

    Default

    Nope. I dont get the Index error though, I just want someone to tell me rofl, as I am learning PHP
    Quote Originally Posted by Chippiewill View Post
    e-rebel forum moderator
    :8

  9. #9
    Join Date
    May 2005
    Location
    /etc/passwd
    Posts
    19,110
    Tokens
    1,139

    Latest Awards:

    Default

    Okay then, If someone wants to fix it instead of explaining then here is the current code...

    PHP Code:
    <?
    oB_start
    ();
    // allows you to use cookies.
    include("config.php");
    if (!
    $logged["username"])
    {
    if (!
    $_POST["login"])
    {
    echo(
    "
    <center><form method=\"POST\">
    <table>
    <tr>
    <td align=\"right\">
    <div align=\"center\">Username: 
    <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\">
    </div></td>
    </tr>
    <tr>
    <td align=\"right\">
    <div align=\"center\">Password: 
    <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\">
    </div></td></tr><tr>
    <td align=\"center\">
    <input type=\"submit\" name=\"login\" value=\"Login\"></td></tr><tr>
    <td align=\"center\">
    <div align=\"center\">All Login attemps are logged. Please do not abuse the system! </div></td>
    </tr></table>
    </form></center>"
    );
    }
    if (
    $_POST["login"]) {
    // the form has been submitted.  We continue...
    $username=$_POST['username'];
    $password md5($_POST["password"]);
    // the above lines set variables with the submitted information.  
    $info mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    $data mysql_fetch_array($info);
    if(
    $data["password"] != $password) {
    // the password was not the user's password!
    echo "Incorrect username or password!";
    }else{
    // the password was right!
    $query mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    $user mysql_fetch_array($query);
    // gets the user's information
    setcookie("id"$user[id],time()+(60*60*24*5), "/""");
    setcookie("pass"$user[password],time()+(60*60*24*5), "/""");
    // the above lines set 2 cookies. 1 with the user's id and another with his/her password.  
    echo ("<meta http-equiv=\"Refresh\" content=\"0\"; URL=\"http://localhost/DJPanelBETA/index2.php\" />Thank You! You will be redirected");
    // modify the above line...add in your site url instead of yoursite.com
    }
    }
    }
    else
    {
    // we now display the user controls.
    $new mysql_query("select * from pmessages where unread = 'unread' and touser = '$logged[username]'");
    $new mysql_num_rows($new);
    echo (
    "<center>Welcome <b>$logged[username]</b><br /></center>
    - <a href=\"editprofile.php\">Edit Profile</a><br />
    - <a href=\"members.php\">Member List</a><br />
    - <a href=\"messages.php\">Private Message Center (
    $new new)</a><br />
    - <a href=\"logout.php\">Logout</a>"
    );
    }
    ?>
    Quote Originally Posted by Chippiewill View Post
    e-rebel forum moderator
    :8

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •