PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon May 25, 2020 11:38 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue May 17, 2016 10:18 am 
Offline
Forum Contributor

Joined: Tue Jul 28, 2009 9:26 am
Posts: 184
Hello,
I have a login page and I am trying to use the input username & password to confirm member. Below is my code but it is not echoing the name out.
Syntax: [ Download ] [ Hide ]
$uname = $_POST[username];                     
$pword = $_POST[password]:

$get = $dWay->prepare(SELECT firstname, lastname, city FROM members WHERE username=? AND password=?);
$get->bind_param('s, s', $uname, $pword);
$get->execute();
$get->bind_result($fname, $lname, $city);
$get->fetch();
echo $fname;
 


If I use one parameter like in below code, It will echo out the name. But I must use two (username & password) parameter

Syntax: [ Download ] [ Hide ]
$get = $dWay->prepare(SELECT firstname, lastname, city FROM members WHERE username=?);
$get->bind_param('s', $uname);

//OR

$get = $dWay->prepare(SELECT firstname, lastname, city FROM members WHERE password=?);
$get->bind_param('s', $pword);
 


Please what could be the problem, because I must use both Email & Password to confirm each member.

Thanks


Top
 Profile  
 
PostPosted: Tue May 17, 2016 10:29 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada
Get rid of the comma.

Syntax: [ Download ] [ Hide ]
$get = $dWay->prepare("SELECT firstname, lastname, city FROM members WHERE username=? AND password=?");
$get->bind_param('ss', $uname, $pword);
$get->execute();
$get->bind_result($fname, $lname, $city);
$get->fetch();
echo $fname;


You could get rid of $uname and $pword, too, as they serve very little purpose, but that's another story.

_________________


Top
 Profile  
 
PostPosted: Tue May 17, 2016 11:12 am 
Offline
Forum Contributor

Joined: Tue Jul 28, 2009 9:26 am
Posts: 184
Thanks Celauran

It works, like magic. I have been on this for more than an hour.

Thanks greatly.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group