Login script which only works some of the time...?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dubdave
    New Member
    • Aug 2006
    • 5

    Login script which only works some of the time...?

    Hi

    I wrote a very basic login script which acesses a mySQL database, like this:-


    <?php

    // compares values entered in login page form with mySQL database,
    and then
    directs either to protected page or to a failure page

    $em = trim($_POST['email']);
    $pw = trim($_POST['password']);

    $link = mysql_connect ('server', 'account', 'password');
    mysql_select_db ("database1" );


    // if $em and $pw match a record, then display page, else display
    failure page

    $query = "SELECT email, password FROM details_table WHERE (email
    = '$em'
    AND password = '$pw')";

    $result = mysql_query ($query);

    if (mysql_num_rows ($result) == 1)
    {
    require('http://www.homesite/redirect.php');
    }
    else
    {
    echo"login failed";
    }


    mysql_close($li nk);
    ?>


    My problem is this :-

    It worked fine on my localhost test system, and fine on the first remote server/ database combination I put it on.

    However, I have since tried to reuse it, calling other tables on the same database, other databases, and on other servers using other databases - and it does not work on these, although it is still runnng fine on the original configuration

    Does anyone have have any ideas about why this might be, or whether there is another, more solid way of achieving what this script does ( bearing in mind I am trying to keep it as simple as possible for the moment?
  • phpmaet
    New Member
    • Sep 2006
    • 27

    #2
    Hi,
    please note what error you have?

    thanks

    Comment

    • dubdave
      New Member
      • Aug 2006
      • 5

      #3
      Hi

      It doen't post any mySQL error code - it just runs the 'login failed' part of the script - as though it couldn't access the database

      I have a version of it working fine on a server right now - but if I try to rewrite it to access another table in the same database, or another database, it just runs straight to the login failed page

      I have spent two days trying every variation of the script - different databases, different tables - changing only one thing at a time - and I know it works because the version I have posted is running fine....

      Any thoughts on this would be most welcome - or an alternate script for this simple job which works - I have tried some others i have seen posted and tey don't seem to run at all

      Comment

      Working...