Login Tutorial [FIXED]

0 favourites
  • 5 posts
From the Asset Store
Carousel Animation, make carousel of you image gallery or anything
  • I'm following this login tutorial which uses PHP, AJAX and Mysql (Sorry can't post URLs due to reputation) but my results aren't coming out as I expected and I wondered if someone could assist.

    Login.php located at

    <?php
    $email = $_GET['femail'];
    $password = $_GET['fpass'];
    $con=mysqli_connect("mysql2.clusterdb.net","UserD-1i1","*snipped password*");
    // Check connection
    if (mysqli_connect_errno())
      {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }
    $qz = "SELECT IsMember FROM PlayerLoginData where EmailID='".$email."' and PassID='".$password."'"; 
    $qz = str_replace("\'","",$qz); 
    $result = mysqli_query($con,$qz);
    while($row = mysqli_fetch_array($result))
      {
      echo $row['IsMember'];
      }
    mysqli_close($con);
    ?>[/code:9vz7otb2]
    
    [b]Database details [/b]- Database and database login are the same as default
    [img="http://i.imgur.com/P1fh41q.png"]
    
    [b]Construct 2 Settings[/b] - I was told AJAX returns a string after I attempted to return a [i]tinyint[/i] from the database so I changed it to a [i]string[/i].
    [img="http://i.imgur.com/onLkmxw.png"]
    
    [b]Results[/b] - As an [i]int [/i]I got [b]NaN[/b] in the IsMember after attempting to login but as a string I receive a blank string.
    AJAX last data is also blank.
    
    [b]*With some error checking I have been given this error[/b]
    [code:9vz7otb2]Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/cluster-sites/2/o/ouroboros-development.co.uk/public_html/login.php on line 15[/code:9vz7otb2]
    
    Thank you for any help that any help I receive.
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Well, you are missing a "AJAX - On error" event that could log what is actually going wrong when the request is not completed.

    As mentioned in the AJAX manual article, cross domain security issues can happen.

    Make sure first the request is completed. If it is not, that's the explanation as why you are not getting the expected value.

    Consider still posting the URL for the tutorial you are following (post it as plain text with spaces in it).

  • https:// www scirra com /tutorials/525/simple-login-using-a-mysql-database

    I've been learning as I go along and I've put in plenty of error checks.

    The php script does run and it does connect but the query always returns

    RESULT = END OF RESULT[/code:3s9n1l5m] inside of it but If I run SQL straight in phpmyadmin with the exact same query (Minus the variable = ) then I get a good result of IsMember 1.
    
    I'll look into the AJAX possible issue.
    
    [b]*An AJAX error is occurring as you stated it may[/b]
  • AJAX is now operating but the script is returning

    Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/cluster-sites/2/o/ouroboros-development.co.uk/public_html/login.php on line 17[/code:2n7e4n8h]
  • Kettlewell have you solved this problem you get from the tutorial you followed before?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)