[AJAX] ajax et php upload
Bonjour à tous,
je cherche a faire un formulaire en vérification sans rechargement mais avec upload de fichier.
jusque là sans upload j'utilisais ça:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| <script type="text/javascript">
function verif()
{
$('ajout').request({
onComplete: function(transport){
var err="";
err =(transport.responseText);
alert=err;
}
})
}
function metsAJour() {
var url = 'inscription/cinscr.php?login='+$F('login')+'&password='+$F('password')+'&cpassword='+$F('cpassword')+'&nom='+$F('nom')+'&prenom='+$F('prenom')+'&privil='+$F('privil')
var pars = '';
var target = 'cible';
var myAjax = new Ajax.Updater(target, url, {method: 'GET', parameters: pars});
}
</script>
<div id="text">
<br>
Formulaire d'ajout:
<form name="ajout" id="ajout" method="POST" action="javascript:void(0)">
Identifiant<br />
<input name="login" type="text" id="login" size="20" />
<br />
Mot de passe<br />
<input name="password" type="text" id="password" size="20" />
<br />
Confirmer <br />
<input name="cpassword" type="text" id="cpassword" size="20" />
<br>
Nom<br />
<input name="nom" type="text" id="nom" size="20" />
<br />
Prenom<br />
<input name="prenom" type="text" id="prenom" size="20" />
<br />
Statut<br />
<select name="privil" id="privil">
<option value="0" selected>Utilisateur</option>
<option value="1">Administrateur</option>
</select>
<br />
<br />
<input name="Submit2" type="image" value="Envoyer" src="pictur/send.gif" width="39" height="20" onclick="metsAJour()" />
<br />
<br />
</form> |
avec ça:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| <?php
include("../include/connect.php");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
//verification complètion des champs.
$toaff="";
$manq="";
if (empty($_GET['login']))
$manq.="- Identifiant <br>";
if (empty($_GET['password']))
$manq.="- Mot de passe<br>";
if (empty($_GET['cpassword']))
$manq.="- Confirmation Mot de passe<br>";
if (empty($_GET['nom']))
$manq.="- Nom<br>";
if (empty($_GET['prenom']))
$manq.="- Prenom <br>";
if($manq!="")
$toaff.="• Il manque: <br>".$manq."<br>";
//verification: les deux password
if ($_GET['cpassword']!=$_GET['password'])
$toaff.="• Les deux mots de passe sont différents<br>";
if($toaff==""){
$sql="INSERT INTO `user` (
`user_id` ,
`user_nom` ,
`user_prenom` ,
`user_login` ,
`user_password` ,
`user_last` ,
`user_level`
)
VALUES (
NULL , '".$_GET['nom']."', '".$_GET['prenom']."', '".$_GET['login']."', '".md5($_GET['password'])."', '0', '".$_GET['privil']."')";
mysql_query($sql);
$toaff="Ajout de ".$_GET['nom'].", ".$_GET['prenom']." terminé.";
}
echo "<b>".$toaff."</b>";
?> |
Mais là du coup je test même pas car le fichier qui passe dans l'url je le sens pas...
si quelqu'un à une idée ...
Merci