Results 1 to 13 of 13

Thread: [RESOLVED] PHP/MYSQL: can"t get Login page to work

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    204

    Resolved [RESOLVED] PHP/MYSQL: can"t get Login page to work

    I am trying to set-p a chechlogin page but I can't get it to work. I have been trying for more than a week now. This is my first PhP, if you have a better idea how to do this, I will appreciate your help. here is my code. when I run this code it tells me page not found. Thank you for your time
    AL code
    Here is the code [HT<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
    <form name="form1" method="post" action="checklogin.php">
    <td>
    <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
    <tr>
    <td colspan="3"><strong>Member Login </strong></td>
    </tr>
    <tr>
    <td width="78">Username</td>
    <td width="6">:</td>
    <td width="294"><input name="myusername" type="text" id="myusername"></td>
    </tr>
    <tr>
    <td>Password</td>
    <td>:</td>
    <td><input name="mypassword" type="text" id="mypassword"></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type="submit" name="Submit" value="Login"></td>
    </tr>
    </table>
    </td>
    </form>
    </tr>
    </table>ML][/HTML]

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: PHP/MYSQL: can"t get Login page to work

    Does checklogin.php exist?

    You haven't posted any PHP code, just the HTML.

    At current, all you have shown is that your form will POST the field "myusername" and "mypassword" to checklogin.php.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    204

    Re: PHP/MYSQL: can"t get Login page to work

    Quote Originally Posted by kfcSmitty View Post
    Does checklogin.php exist?

    You haven't posted any PHP code, just the HTML.

    At current, all you have shown is that your form will POST the field "myusername" and "mypassword" to checklogin.php.
    I am sorry
    checklogin.php
    HTML Code:
      <?php
    
     $host="ftp.xyz.com"; // Host name 
    $username="John"; // Mysql username 
    $password="zzww99"; // Mysql password 
    $db_name="testdb"; // Database name 
    $tbl_name="members"; // Table name 
    
    
    
    // Connect to server and select databse.
     mysql_connect("$host", "$axyz", "$john")or die("cannot connect"); 
    mysql_select_db("$testdb")or die("cannot select DB");
    
    
    // username and password sent from form 
    $myusername=$_POST['myusername']; 
    $mypassword=$_POST['mypassword']; 
    
    
    
    // To protect MySQL injection (more detail about MySQL injection)
     $myusername = stripslashes($myusername);
     $mypassword = stripslashes($mypassword);
     $myusername = mysql_real_escape_string($myusername);
     $mypassword = mysql_real_escape_string($mypassword);
    
    $sql="SELECT * FROM $member WHERE username='$myusername' and password='$mypassword'";
     $result=mysql_query($sql);
    
    
    
    // Mysql_num_row is counting table row
     $count=mysql_num_rows($result);
    
    // If result matched $myusername and $mypassword, table row must be 1 row
    
    if($count==1){
    
    // Register $myusername, $mypassword and redirect to file "login_success.php"
     session_register("myusername");
     session_register("mypassword"); 
    header("location:login_success.php");
     }
     else {
     echo "Wrong Username or Password";
     }
     ?>
    Here is my code for login_success.php
    [HTML<?php
    session_start();
    if(!session_is_registered(myusername)){
    header("location:main_login.php");
    }
    ?>][/HTML]

  4. #4
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: PHP/MYSQL: can"t get Login page to work

    What error are you getting and on what page?

    The only big thing I can see from your code is that you're using $member in your SELECT statement, but that variable has never been declared.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    204

    Re: PHP/MYSQL: can"t get Login page to work

    Quote Originally Posted by kfcSmitty View Post
    What error are you getting and on what page?

    The only big thing I can see from your code is that you're using $member in your SELECT statement, but that variable has never been declared.
    When I try to do previel, I get 'Page Not found'

  6. #6
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: PHP/MYSQL: can"t get Login page to work

    Do you get that when you first try to load up you page (before your login form)?
    Do you get that after you've clicked "Login" on your login form?
    If you remove the 'header("Location:login_success.php");' from your checklogin.php page does it still give the error?

    If it hits your checklogin.php page, have you tried echoing out along the path to see where it is crapping out?

    Sounds more like "you've tried nothing, but you're all out of ideas" so to speak. What kind of debugging have you tried?

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    204

    Re: PHP/MYSQL: can"t get Login page to work

    Quote Originally Posted by kfcSmitty View Post
    Do you get that when you first try to load up you page (before your login form)?
    Do you get that after you've clicked "Login" on your login form?
    If you remove the 'header("Location:login_success.php");' from your checklogin.php page does it still give the error?

    If it hits your checklogin.php page, have you tried echoing out along the path to see where it is crapping out?

    Sounds more like "you've tried nothing, but you're all out of ideas" so to speak. What kind of debugging have you tried?
    I get it when I first try to load up the page, before the login form. I will go and try your suggestions and get back in the forum. Thanks for your time

  8. #8
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: PHP/MYSQL: can"t get Login page to work

    Maybe a screenshot would help... I don't see how you can get a "page not found" error before the login page... a screenshot along with the address (in the screenshot) would probably help... I foresee a couple things... but I'll wait for the screenshot to comment furhter.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    204

    Re: PHP/MYSQL: can"t get Login page to work

    Quote Originally Posted by techgnome View Post
    Maybe a screenshot would help... I don't see how you can get a "page not found" error before the login page... a screenshot along with the address (in the screenshot) would probably help... I foresee a couple things... but I'll wait for the screenshot to comment furhter.

    -tg
    I am sorry for not responding yesterday, my system crashed on me, but this what the page says "Page Not Found
    The page you are looking for might have been removed, had its name changed, or is temporarily unavailable. Please try the following:

    If you typed the page address in the Address bar, make sure that it is spelled correctly.
    Click the Back button in your browser to try another link.
    Use a search engine like Google to look for information on the Internet.

    "

  10. #10
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: PHP/MYSQL: can"t get Login page to work

    Yeah, I KNOW what a 404 page not found error looks like... and for the reason for it... but that's not what I asked for was it?
    Quote Originally Posted by me
    a screenshot along with the address (in the screenshot)
    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    204

    Re: PHP/MYSQL: can"t get Login page to work

    Quote Originally Posted by techgnome View Post
    Yeah, I KNOW what a 404 page not found error looks like... and for the reason for it... but that's not what I asked for was it?


    -tg
    tg, Name:  Untitled.png
Views: 706
Size:  463.4 KB

  12. #12
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: PHP/MYSQL: can"t get Login page to work

    You're accessing the FTP URL which is not correct for your site.

    StartLogic doesn't appear to offer a DNS for you when you sign up for their hosting. You're going to have to get a domain and point it to their nameservers. Or, you could get a domain through them.

    I would suggest using their support for this, as this is more that you don't seem to understand their hosting services.

    The first step in their registration process is asking for a domain. Did you check off "Do not register a domain"? If so, you need one.

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    204

    Re: PHP/MYSQL: can"t get Login page to work

    Thanks everybody that took time to offer some help. The problem was that the files on the server was not updating, so when I changed a file name it will not update. But once this get corrected everything works fine.
    AL

Posting Permissions

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



Click Here to Expand Forum to Full Width