Probleme d'inscription

Eléphant du PHP | 84 Messages

08 mai 2005, 19:13

Bonsoir tout le monde :wink:
J'ai crée un script qui ne marche pas
il verifie er efectue un formulaire d'inscription
les erreur:
Notice: Undefined index: avatar in c:\documents and settings\philippe\mes documents\mes sites web\aaf5.0\web\verif.php on line 22
chargement de l'avatar echouer verifier la t'aille du fichier. Elle doit etre inferieure a 20Ko

Notice: Undefined index: avatar in c:\documents and settings\philippe\mes documents\mes sites web\aaf5.0\web\verif.php on line 26
le fichier envoyer n'est pas une images graphique. Essayer avec un autre fichier
voila le code c'est mon 1er script avec $_FILES :roll: c'est un echaique total :shock: :
<html>

<head>
<meta http-equiv="Content-Language" content="fr">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Nouvelle page 1</title>
</head>

<body background="design/fond.png">

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-width: 0" bordercolor="#111111" id="AutoNumber1" width="336">
  <tr>
    <td width="336" style="border-style: none; border-width: medium" background="design/h.png">
    <p align="center"><font face="Comic Sans MS" color="#000080"><b>Inscription</b></font></td>
  </tr>
  <tr>
    <td width="336" style="border-style: none; border-width: medium" background="design/pagefond.gif">
    <p align="center">&nbsp;
    <?
    if($_FILES['avatar']['size'] == 0)
    {
    echo 'chargement de l\'avatar echouer verifier la t\'aille du fichier. Elle doit etre inferieure a 20Ko</br>';
	}
	if(!ereg("image",$_FILES['avatar']['type']))
	{
	echo 'le fichier envoyer n\'est pas une images graphique. Essayer avec un autre fichier';
	}
	else
	{
	$avatar = 'C:\Program Files'."\\".$_POST['pseudo'];
	$file = $_FILES['avatar']['tmp_name'];
	move_uploaded_file($file,$avatar);?>
	<?if(isset($_POST['pseudo']) and isset($_POST['email']) and isset($POST['profil']) and isset($POST['sexe']) and isset($POST['mdp']))
	{
	$pseudo = $_POST['pseudo'];
	$email = $_POST['email'];
	$profil = $POST['profil'];
	$sexe = $POST['sexe'];
	$mdp = $POST['mdp'];
	?>
    Votre pseudo: <?echo $pseudo;?><br>
    Votre email: <?echo  $email;?></br>
    Votre Profil: <?echo $profil;?></br>
    Votre sexe: <?echo $sexe;?>
    <?
    mysql_connect("localhost","root");
    mysql_select_db("gtn");
    $rep=mysql_query("INSERT INTO membre VALUES('','".$pseudo."','".$email."','".$profil."','".$sexe."','".$mdp."','".$avatar."')");
    mysql_close();
    if($rep)
    {
    echo 'Merci'.$_POST['pseudo'].' de votre inscription (réussite)';
    }
    else
    {
    echo 'Erreur réinscrivez vous';
    }
	}
	}
    ?>
    </td>
  </tr>
  <tr>
    <td width="336" style="border-style: none; border-width: medium" background="design/b.png">&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>

</body>

</html>
Merci de m'aider :wink:
~~Jojo~~

ViPHP
fab
ViPHP | 2657 Messages

08 mai 2005, 19:26

$_FILES['avatar'] n'a pas l'air d'éxister

Eléphant du PHP | 84 Messages

08 mai 2005, 19:44

Pourtemps il existe :x
:cry:
le code du formulaire:
<html>

<head>
<meta http-equiv="Content-Language" content="fr">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Nouvelle page 1</title>
</head>

<body background="design/fond.png">

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-width: 0" bordercolor="#111111" id="AutoNumber1" width="336">
  <tr>
    <td width="336" style="border-style: none; border-width: medium" background="design/h.png">
    <p align="center"><font face="Comic Sans MS" color="#000080"><b>Inscription</b></font></td>
  </tr>
  <tr>
    <td width="336" style="border-style: none; border-width: medium" background="design/pagefond.gif">
    <div align="center">
      <center>
      <table border="1" cellpadding="0" cellspacing="0" style="border-width:0; border-collapse: collapse" bordercolor="#111111" width="266" id="AutoNumber2">
        <tr>
          <td width="113" style="border-style: none; border-width: medium">Pseudo</td>
          <td width="165" style="border-style: none; border-width: medium">
          <form action="web/verif.php" methode="POST">
          <input type="text" name="pseudo" size="22"></td>
        </tr>
        <tr>
          <td width="113" style="border-style: none; border-width: medium">Petit message</td>
          <td width="165" style="border-style: none; border-width: medium">
          <textarea rows="4" name="profil" cols="18">age
ville
com</textarea></td>
        </tr>
        <tr>
          <td width="113" style="border-style: none; border-width: medium">Mots de passe</td>
          <td width="165" style="border-style: none; border-width: medium">
          <input type="text" name="mdp" size="22"></td>
        </tr>
        <tr>
          <td width="113" style="border-style: none; border-width: medium">Email</td>
          <td width="165" style="border-style: none; border-width: medium">
          <input type="text" name="email" size="22"></td>
        </tr>
        <tr>
          <td width="113" style="border-style: none; border-width: medium">sexe</td>
          <td width="165" style="border-style: none; border-width: medium">
          <select size="1" name="sexe">
          <option value="fille">fille</option>
          <option value="garcon">garcon</option>
          </select><input type="hidden" name="MAX_FILE_SIZE" value="20000"/></td>
        </tr>
        <tr>
          <td width="113" style="border-style: none; border-width: medium">
          Avatar </td>
          <td width="165" style="border-style: none; border-width: medium">
          <input type="file" name="avatar" size="8"></td>
        </tr>
        <tr>
          <td width="279" colspan="2" style="border-style: none; border-width: medium">
          <p align="center"><input type="submit" value="inscription"/></form></td>
        </tr>
      </table>
      </center>
    </div>
    </td>
  </tr>
  <tr>
    <td width="336" style="border-style: none; border-width: medium" background="design/b.png">&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>

</body>

</html>
~~Jojo~~

ViPHP
ViPHP | 2144 Messages

08 mai 2005, 21:12

Il manque l'enctype dans le tag du form

enctype="multipart/form-data"

cfr : le tutorial sur l'upload par formulaire