0
我在教自己的php和MySQL,現在我有一個MySQL問題。如何將來自用戶php的輸入與MySQL的輸入進行比較
我想比較用戶輸入的電話號碼與MYSQL中的電話號碼,以及是否在MYSQL中不再註冊。
我的代碼:
<?php
require_once 'connection/connection.php';
// Variables from HTML to php
$worker_Name = $_POST['workerNameFromHtml']; // worker Name
$worker_City = $_POST['workerCityFromHtml']; // workerCity
$worker_career = $_POST['workerCareerFromHtml']; // worker career
$worker_PhoneNumber = $_POST['workerPhonNumberFromHtml']; // worker Phone Number
$worker_SecondPhoneNumber = $_POST['workerSecondPhoneNumberFromHtml']; // worker Second Phone Number
$submt=$_POST['submitFromHtml'];
if($submt){
$qry = ("SELECT workrPhoneNumber FROM workersTable WHERE workrPhoneNumber = '$worker_PhoneNumber'") or die(mysql_error());
$result = $connect->query($qry);
$num = $result->num_rows;
if ($num == 1) {
$here = "INSERT INTO workersTable VALUES('','$worker_Name','$worker_City','$worker_career','$worker_PhoneNumber','$worker_SecondPhoneNumber')";
$query = $connect->query($here);
print "Successfully added!";
}
else {print "This number has already been entered Thank you for your cooperation!";}}
$connect->close();
到目前爲止,我還沒有找到一個解決這個問題。
你的'$ qry'變量是錯誤的。檢查這個教程https://www.w3schools.com/php/php_mysql_select.asp –
我改變了錯誤。但不工作。 我會改變和編輯我的問題到我的最終文件。 – hasan