這是我想要?dú)w檔的內(nèi)容以及我使用curl已經(jīng)走了多遠(yuǎn)的摘要,它似乎通過(guò)觸發(fā)另一臺(tái)服務(wù)器中的文件來(lái)運(yùn)行和更新數(shù)據(jù)庫(kù)來(lái)完美地完成我的任務(wù),但我現(xiàn)在的問(wèn)題是更新的數(shù)據(jù)庫(kù)是不是從 html 表單所在的 serverA 發(fā)送的數(shù)據(jù)或值。<!--- html code --><form action="" method="post" name="cashaform" id="cashaform"><div class="dephone">Phone <br><input type="text" name="phone" id="phone" /></div><div class="deemail">Email <br><input type="text" name="email" id="email" /></div><div class="submit"> <br><input type="submit" name="submitprime" value="Submit" id="submitprime" /></div></form>// 處理表單并將其發(fā)送到另一臺(tái)服務(wù)器上的 do.php 的代碼,該服務(wù)器使用表單中的詳細(xì)信息更新數(shù)據(jù)庫(kù)// This is process.php in serverAif(isset($_POST['submitprime'])){ $sphone = $_POST['phone']; $semail = $_POST['email']; $form_data = array( 'phone' => $sphone, 'email' => $semail ); $str = http_build_query($form_data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost/serverb/do.php'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $str); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $output = curl_exec($ch); curl_close($ch);}現(xiàn)在在serverB上我有一個(gè)名為do.php的文件,一旦process.php通過(guò)curl命中它,它就會(huì)更新數(shù)據(jù)庫(kù)// do.php that is on serverb$hostname = 'localhost';$dbusername = 'prime';$dbpassword = 'prime';$dbname = 'prime'; $conn = mysqli_connect($hostname, $dbusername, $dbpassword, $dbname);$email = 'pandglo@yahoo.com'; // this values should be replaced with phone sent from form in serverA via curl$phone = '09077345'; // this values should be replaced with email sent from form in serverA via curl// update the database$run = "INSERT INTO prime_securetable (email, phone) VALUES('$email', '$phone')";if(mysqli_query($conn, $run) ) { echo 'Transferred Successfully';}else{ echo'transfer failed';}mysqli_close($conn);我希望用于更新數(shù)據(jù)庫(kù)的數(shù)據(jù)電話和電子郵件是從 serverb 中的表單中的帖子發(fā)送的電話和電子郵件,我嘗試并使用 pandglo@yahoo.com 和固定電話 09077345 設(shè)置固定值,但我想要這個(gè)值是從 serverA 中的表單實(shí)際提交的內(nèi)容,它會(huì)更新數(shù)據(jù)庫(kù),但我希望它是通過(guò)curl發(fā)布的表單中的值。請(qǐng)?zhí)峁┤魏螏椭?
使用curl或webhooks將數(shù)據(jù)從外部服務(wù)器發(fā)布到數(shù)據(jù)庫(kù)
天涯盡頭無(wú)女友
2023-08-19 14:16:48