I'm making a php page that inserts values written by the user into an MySql table. I'm trying to get the textbox values sent to the php code portion and can't do it.
I currently have this php function:
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();
}
And this Javascript function (notice the last line here, i call my php function):
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);?>
}
How do i send all thoses variables to my php function?
If this is all correct then something else might not work in my spaghetti code.
Also i'm working on a single .php file named Inscription.php.