Login Tutorial [FIXED]

Get help using Construct 2

Post » Wed Jun 10, 2015 10:05 am

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 Image
Code: Select all
<?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);
?>


Database details - Database and database login are the same as default
Image

Construct 2 Settings - I was told AJAX returns a string after I attempted to return a tinyint from the database so I changed it to a string.
Image

Results - As an int I got NaN in the IsMember after attempting to login but as a string I receive a blank string.
AJAX last data is also blank.

*With some error checking I have been given this error
Code: Select all
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


Thank you for any help that any help I receive.
Last edited by Kettlewell on Wed Jun 10, 2015 10:00 pm, edited 1 time in total.
B
4
Posts: 19
Reputation: 240

Post » Wed Jun 10, 2015 10:48 am

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).
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,317
Reputation: 87,483

Post » Wed Jun 10, 2015 11:15 am

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
Code: Select all
RESULT = END OF RESULT
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.

*An AJAX error is occurring as you stated it may
B
4
Posts: 19
Reputation: 240

Post » Wed Jun 10, 2015 11:19 am

AJAX is now operating but the script is returning
Code: Select all
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
B
4
Posts: 19
Reputation: 240


Return to How do I....?

Who is online

Users browsing this forum: stevenode and 10 guests