douyue5856 2016-04-13 14:27
浏览 33

从网站调用phpmyadmin中的存储过程以检查登录详细信息

I am trying to call a stored procedure in php-myadmin from wordpress website to check user login details.

I have a button that points to javascript function:

<input type="submit" value="Login" onclick="checkloging()">

The javascript file contains ajax:

function checkloging() {
      $.ajax({
           type: "POST",
           url: 'checklogin_php',
           data:{action:'call_this'},
           success:function(html) {
             alert(html);
           }

      });
 }

The ajax code is to call a php file:

<?php

//Call the proc() procedure follow
$result= mysql_query("CALL checkpassword('username', 'password');") or die(mysql_error()); 
while($row = mysql_fetch_row($result))
{
    for($i=0;$i<=6;$i++)
    { 
        echo  $row[$i]."<br>";
    }  
}  
mysql_close($con);
?>

which invokes a stored procedure in phpmyadmin.

Please can any anyone help with this? I am not not sure if this is a good approach and I'm not getting it to work.

  • 写回答

1条回答 默认 最新

  • dongshao1981 2016-04-13 14:42
    关注

    This might help you. Note: Use and read more about mysqli

    <?php 
    
      //connect to database
      $connection = mysqli_connect("hostname", "user", "password", "db");
    
      //call and run the store proc
      $result = mysqli_query($connection, 
         "CALL checkpassword") or die("Query fail: " . mysqli_error());
    
      //loop the result set
      while ($row = mysqli_fetch_array($result)){   
          echo $row[0] . " - " . + $row[1]; 
      }
    
      mysql_close($con);
    
    ?>
    
    评论

报告相同问题?