/    Sign up×
Community /Pin to ProfileBookmark

Hi I want to create a login form, but need some help with the code below because it doesn’t seem working:

<?php
session_start();

if(isset($_POST[‘submit’]))
{
if(isset($_
POST[‘username’], $_POST[‘password’]))
{
$con=mysqli_connect(“localhost”,”root”,””,”sgptt”);
$username = mysqli_real_escape_string($con, $_
POST[‘username’]);
$password = hash(‘sha512’, $_POST[‘password’]);
$exists = mysqli_query($con, “SELECT COUNT(*) FROM useraccount WHERE Username = ‘{$username}’ AND Password = ‘{$password}'”) or die(mysqli_error($con));

if(mysqli_fetch_array($exists, MYSQL_NUM) === 1)
{
echo(“Login Sucessfull”) ;
}
else
{
echo(“Login fail”);

}
}
}
?>

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmFeb 11.2014 — Does the code itself actually run? Do you get any message from your echos? Do you have error checking turned on and get any php messages? Put some messages in the if statements where they are 'false' (the non-existent else clauses) so you can see what may be happening.

Help us to help you. Don't just say it's not working.
Copy linkTweet thisAlerts:
@JpergegaauthorFeb 11.2014 — No I didn't get any message from echos just returns a blank page. I will put some message in the if statement now. Thanks
Copy linkTweet thisAlerts:
@ginerjmFeb 11.2014 — I find that a page that returns nothing at all usually has an error in it. Turning on error checking shows me the message.
Copy linkTweet thisAlerts:
@aubenefitFeb 13.2014 — please check on this line:

if(isset($_POST['username'], $_POST['password']))
Copy linkTweet thisAlerts:
@ginerjmFeb 13.2014 — aubenefit - one can use multiple parms in the isset function.

If the OP would simply turn on error checking - OR use an IDE that recognizes PHP syntax, etc. - he would find his problem is an error in his php. There is no mysqli_fetch_array function and that would show up in either his editor or in his execution.
×

Success!

Help @Jpergega spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...