Bonjour à tous
j'ai un gros problème et je sollicite votre aide.
Je suis entrain de réaliser une application web avec laquelle on pourra réserver des terrain de football.Mon problème consiste dans mon incapacité à rediriger mon formulaire (réalisé avec php avec des contrôles en ajax et en js)vers ma page profil tout en récupérant ma variable login
(je débute ajax)
code php(formulaire)
<form id="formulaire" name="formulaire" >
<table width="447">
<tr>
<td>>Login :</td>
<td><input type="text" name="login" id="loginform" onkeyup="check()"/></td>
<td width="116"><div id="mention" style="color:#F00;"></div></td>
</tr>
<tr>
<td>>Mot de passe :</td>
<td><input type="password" name="mdp" id="pwdform"/></td>
<td><div id="vide"></div></td>
</tr>
<tr>
<td>>Confirmez Mot de passe :</td>
<td><input type="password" name="Confmdp" id="confmdp"/></td>
</tr>
<tr>
<td>>Nom Du contact:</td>
<td><input type="text" name="nom" id="nom"/></td>
</tr>
<tr>
<td>>Prenom :</td>
<td><input type="text" name="prenom" id="prenom"/></td>
</tr>
<tr>
<td>>Email :</td>
<td><input type="text" name="mail" id="email" onkeyup="verifmail(this.value)"/></td>
<td><div id="mail"></div></td>
</tr>
<tr>
<td>>Telephone :</td>
<td><input type="text" name="tel" maxlength="8" id="tel" onkeyup="veriftel(this.value)"/></td>
<td><div id="num"></div></td>
</tr>
<tr>
<td><input type="button" value="Ajouter" onclick="checkValidate()"/></td>
</tr>
</table>
Contrôle (ajax et js)
/////////////Pour l'instanciaion du XMLHttpRequest selon le navigateur//////////
var XmlHttpVersions = new Array('MSXML2.XMLHTTP.6.0','MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP');
function getXMLHttpRequest(){
var xmlHttpRequest; //pour communiquer avec le serveur : XML http request object
try{
xmlHttpRequest = new XMLHttpRequest(); //Instantiation pour Firefox, Safari, Chrome & Opera
}catch(e1){ // Instantiation pour Internet Explorer
for(var i=0; i<XmlHttpVersions.length && !xmlHttpRequest;i++){
try{
xmlHttpRequest = new ActiveXObject(XmlHttpVersions[i]);
}catch(e2){
}
}
}
if(!xmlHttpRequest){
alert('Your browser can\'t handle this AJAX script');
}
return xmlHttpRequest;
}
////////////////////////////////////////////////:::::::::::::::::::::::::::
function check(){
xmlHttpRequest = getXMLHttpRequest();
if (xmlHttpRequest != null) {
////////////////////////////////////Envoi de la requete//////////////////////////////////////////////
var loginRec = document.getElementById("loginform").value;
xmlHttpRequest.open("GET", "requete_inscription.php?verif=true&login="+loginRec, true);
xmlHttpRequest.send(null);
/////////////////////////////Pour définir le traitement de la réponse du serveur///////////////////////
xmlHttpRequest.onreadystatechange = checkLogin;
}
}
function checkLogin(){
if(xmlHttpRequest.readyState == 4){
try{
var tabLogins = xmlHttpRequest.responseXML.getElementsByTagName("login");
if(tabLogins.item(0)){
window.document.getElementById("mention").innerHTML = "Utilisateur Existant";
window.document.getElementById("checkState").value = "false";
}else{
window.document.getElementById("mention").innerHTML = ""; //c'est bon
window.document.getElementById("checkState").value = "true";
}
}catch(e){
alert(e);
}
}
}
function checkValidate(){
if((document.getElementById("pwdform").value=="")||(document.getElementById("nom").value=="")||(document.getElementById("prenom").value=="")||(document.getElementById("email").value=="")||(document.getElementById("tel").value=="")||(document.getElementById("pwdform").value!=document.getElementById("confmdp").value)||(document.getElementById("nom_ent").value=="")||(document.getElementById("num_part").value=="")||(document.getElementById("email").value.length>50)||(document.getElementById("email").value.indexOf('@')<0)||(document.getElementById("email").value.indexOf('.')<0)||(document.getElementById("email").value.length<5)||(document.getElementById("tel").value.length!=8)||( isNaN (document.getElementById("tel").value))) alert("Erreur de remplissage");
else
{
var checkStateRec = document.getElementById("checkState").value;
if (checkStateRec == "true"){
xmlHttpRequest = getXMLHttpRequest();
if (xmlHttpRequest != null) {
////////////////////////////////////Envoi de la requete//////////////////////////////////////////////
var nom=document.getElementById("nom").value;
var prenom=document.getElementById("prenom").value;
var email=document.getElementById("email").value;
var tel=document.getElementById("tel").value;
var loginRec = document.getElementById("loginform").value;
var pwdRec = document.getElementById("pwdform").value;
xmlHttpRequest.open("GET", "requete_inscription.php?verif=false&login="+loginRec+"&pwd="+pwdRec+"&nom="+nom+"&prenom="+prenom+"&email="+email+"&tel="+tel, true);
xmlHttpRequest.send(null);
/////////////////////////////Pour définir le traitement de la réponse du serveur///////////////////////
xmlHttpRequest.onreadystatechange = validateResponse;
}
}else{
alert('Utilisateur Existant');
}
}
}
function validateResponse(){
alert(xmlHttpRequest.responseXML.getElementsByTagName("message").item(0).firstChild.nodeValue);
}
function writediv(texte)
{
document.getElementById('mail').innerHTML = texte;
}
function verifmail(email)
{
if(email != '')
{
if(email.length<5)
{
writediv('<span style="color:#cc0000">ce mail est trop court</span>');
}else{
if((email.indexOf('@')<0)||(email.indexOf('.')<0))
{
writediv('<span style="color:#cc0000">Vérifier votre mail</span>');
}else{
if(email.length>50)
{
writediv('<span style="color:#cc0000">ce mail est trop long</span>');
} else{
writediv('');
}
}
}
}
}
function writediv2(texte)
{
document.getElementById('num').innerHTML = texte;
}
function veriftel(tel)
{
if(tel != '')
{
if((tel.length!=8)||( isNaN (tel)))
{
writediv2('<span style="color:#cc0000">8 chiffre</span>');
}else{
writediv2('');
}
}
}
page php de vérification
<?php
//Declaration des parametres
$serveur = "localhost" ;
$utilisateur = "root";
$pwd = "";
$bd = "pfa";
//connexion au serveur BD
$lien = mysql_connect($serveur,$utilisateur,$pwd)/*En cas d'erreur */or die("impossible de se connecter");
//selection de la base de donnes
mysql_select_db($bd, $lien);
$verifParam = $_GET['verif'];
if($verifParam == "true") {
$loginParam = $_GET['login'];
//definition des requetes mysql pour afficher la liste des clients
$query = "select * from utilisateur where login='$loginParam'";
//execution de requete
$cur = mysql_query($query);
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='utf-8'?>\n";
echo "<logins>\n";
while($ligne = mysql_fetch_array($cur))
{
echo "<login>\n";
echo $ligne['login'];
echo "</login>\n";
}
echo "</logins>\n";
}
else
{
$loginParam = $_GET['login'];
$pwdParam = $_GET['pwd'];
$nomParam = $_GET['nom'];
$prenomParam = $_GET['prenom'];
$emailParam = $_GET['email'];
$telParam = $_GET['tel'];
$type="p";
$query= "insert into utilisateur (login,nom,prenom,ad_mail,num_tel,mdp,type) VALUES ('$loginParam','$nomParam','$prenomParam','$emailParam','$telParam','$pwdParam','$type')";
mysql_query($query);
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='utf-8'?>\n";
echo "<message>Utilisateur ajouté avec succès</message>";
}
?>
Merci d'avance