[英]Send Javascript variables into PHP's function parameters on file?
我正在制作一個將用戶編寫的值插入MySql表中的php頁面。 我正在嘗試將文本框值發送到php代碼部分,但無法執行。
我目前有這個php函數:
function insertion($Alias,$Password,$Nom,$Adresse,$Telephone,$CatPrefere){
try{
$insert = $mybd->prepare("CALL insertClients(?,?,?,?,?,?,?)",array(PDO::ATTR_CURSOR, PDO::CURSOR_FWDONLY));
$insert->bindParam(1,$Alias);
$insert->bindParam(2,$Password);
$insert->bindParam(3,$Nom);
$insert->bindParam(4,$Adresse);
$insert->bindParam(5,$Telephone);
$insert->bindParam(6,0);
$insert->bindParam(7,$CatPrefere);
$insert->execute();
}
catch(PDOException $e){
echo('Erreur insertion dans table client: '.$e->getMessage());
exit();
}
和這個Javascript函數(注意最后一行,我稱我的php函數):
function inscription() {
var Alias = document.getElementById("alias").value;
var Password = document.getElementById("password").value;
var Nom = document.getElementById("nom").value;
var Adresse = document.getElementById("adresse").value;
var Telephone = document.getElementById("telephone").value;
var Categories = document.getElementById("categorie");
var CatPrefere = Categories.options[Categories.selectedIndex].value;
<?php insertion(Alias,Password,Nom,Adresse,Telephone,CatPrefere);?>
}
如何將所有這些變量發送到我的php函數?
如果這一切都正確,那么在我的意大利面條代碼中可能不起作用。
我也正在處理一個名為Inscription.php的.php文件。
我認為那是不可能的。 您可以做的就是更改URL,以獲取$ _GET中的值。
查看該堆棧溢出主題: 將javaScript變量發送到php變量
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.