Php 如何获取存储过程&x27;输入框中的参数

Php 如何获取存储过程&x27;输入框中的参数,php,mysql,xampp,Php,Mysql,Xampp,在这里,我调用了一个存储过程,它工作得很好,但是我想给输入框中的参数一个如何从输入框中获取的参数 <?php $con = new PDO("mysql:host=localhost;dbname=acc_project_inv",'root',''); $sql = "CALL calcPro('2018-03-31')"; $result = $con->prepare($sql); $result->setFetchMode(PDO::FETCH_ASSOC); $r

在这里,我调用了一个存储过程,它工作得很好,但是我想给输入框中的参数一个如何从输入框中获取的参数

<?php 
$con = new PDO("mysql:host=localhost;dbname=acc_project_inv",'root','');

$sql = "CALL calcPro('2018-03-31')";
$result = $con->prepare($sql);
$result->setFetchMode(PDO::FETCH_ASSOC);
$result->execute();
if ($result) {
            echo "Calculated";
        }else{
            echo "Report Development Team";
        }
?>

以下是一种可能的解决方案:

<html>
    <body>
        <form method="post">
            <input type="text" name="yymmdd">
            <input type="submit" value="Do it!">
        </form>
    </body>
</html>
<?php
$con = new PDO("mysql:host=localhost;dbname=acc_project_inv",'root','');

if (!empty($_POST["yymmdd"])) {
  $ymd = $_POST["yymmdd"];

  // You should add more checks here to make sure that the $ymd
  // variable only contains expected characters (since it's user
  // input)

  $sql = "CALL calcPro( :yyyymmdd )";
  $result = $con->prepare($sql);
  $result->setFetchMode(PDO::FETCH_ASSOC);
  $result->execute([":yyyymmdd" => $ymd]);
  if ($result) {
    echo "Calculated";
  } else {
    echo "Report Development Team";
  }
}


我想从C:\xampp\htdocs\accounts\dont\callsp.php中的一个输入框中获取它13@MONEYMSN很抱歉。我唯一没有在本地测试的一行包含语法错误。已更新。@jonasdev Thanq太多人了。你在帮助别人的sHello@jonasdev方面真是太棒了