test.php
<body> <h1>验证</h1> <div>代号:<input type="text" id="code" /></div> <div>品牌:<input type="text" id="name" /></div> <div><input type="button" value="验证" id="btn"/></div> </body> </html> <script type="text/javascript"> $(document).ready(function(e) { $("#btn").click(function(){ var code = $("#code").val(); var name = $("#name").val(); $.ajax({ url:"chuli.php", data:{code:code,name:name}, type:"POST", dataType:"text", success: function(a){ alert(a); } }) }) }); </script>
chuli.php
<?php $code = $_POST["code"]; $name = $_POST["name"]; include("mydbda.php"); $db = new mydbda(); $sql = " select count(*) from pinpai where Code= ‘{$code}‘ and Name = ‘{$name}‘"; $str = $db->Select($sql,"CX","mydb"); echo $str; ?>
时间: 2024-10-15 02:53:30