How to solve a question about pdo

Source: Internet
Author: User
One question about pdo: PHPcodeif (isset ($ _ POST ['loginname']) & amp; isset ($ _ POST ['pwd']) & amp; & amp; $ _ POST ['action'] = 'submit ') {a question about pdo
PHP code
  If (isset ($ _ POST ['loginname']) & isset ($ _ POST ['pwd']) & $ _ POST ['action'] = 'submit ') {$ loginName = $ _ POST ['loginname']; $ pwd = $ _ POST ['pwd']; echo $ loginName. ''. $ pwd; $ SQL = "SELECT COUNT (*) FROM tb_esq WHERE login_name =: loginName AND pwd =: pwd"; require_once ('Conn. php '); $…… = $ db-> prepare ($ SQL); $……> bindParam (': loginname', $ loginName, PDO: PARAM_STR, 25 ); $ Something-> bindParam (': pwd', $ pwd, PDO: PARAM_STR, 25); $ Something-> execute (); $ rowCount = $ Something-> fetchColumn (); var_dump ($ rowCount ); // Always 0 $ db = NULL; if ($ rowCount = 1) {echo "script window. location = \ "index.html \"; script ";} else {alert ('user name or password is incorrect! '); Echo "script window. location = \" login. php \ "; script";}


After submitting the username and password in the database, the system prompts that the password is incorrect. why?

------ Solution --------------------
Use a common query to check whether data can be obtained.
PHP code
$sql = "SELECT COUNT(*) FROM tb_esq WHERE login_name = '$loginName' AND pwd = '$pwd'";$result = $db->query($sql);$row = $result->fetch(PDO::FETCH_ASSOC);print_r($row);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.