zero a la place des champs vide

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : zero a la place des champs vide

Re: zero a la place des champs vide

par xTG » 31 oct. 2014, 09:25

Bon on arrive à moitié à comprendre...

Des zéros dans ta table lorsque tu ne renseignes pas les champs ?
Si c'est cela c'est parce que le champs de ta table n'accepte pas NULL.

zero a la place des champs vide

par topvision » 29 oct. 2014, 15:50

Bonjour,
lorsque j'envoie mon formulaire depuis php les zero remplace automatiquement les champs vides
voici mon code php
<?php
		
$host = 'localhost'; 
$user = 'root'; 
$pass = ''; 
$bdd  = 'tsm'; 
@mysql_connect($host,$user,$pass)
   or die("Impossible de se connecter");
@mysql_select_db("$bdd")
   or die("Impossible de se connecter");

			
			$resultat2=mysql_query("SELECT * FROM matiere");

		
	?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<meta http-equiv="content-type" content="text/html; charset=utf-8" />
				<title>noteAjout</title>
					<meta name="keywords" content="" />
					<meta name="Adhesive" content="" />
			<link href="../../css/admin.css" rel="stylesheet" type="text/css" media="screen" />
		</head>
		
<body>

	<div id="wrapper">
		<?php include('../includes/menu.ini.php'); ?>
	
	<div id="page"> 

		
			<!--boutton deconnection-->
				<span class="decnx"> <a href="admin.php?logout=ok">
				 <font color="white" >Se deconnecter</a></font></span>
		
		<br/><br/> <br/>	
				<p align="center"><font face="times news roman, tahoma" size="4px" color="white">
					<b>AJOUT DE NOTE</b></font>
				</p>
			
	<table border="0px" align="center" >
				
	<form method="POST" action="noteInscription.php">

		<tr>
			<td colspan=6>
					<b>Matricule 
						<input type="text" name="id" id="id" size=7/>
								
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					Matiere :</b>
						<select name="matiere" id="matiere">
									<?php while($matiere=mysql_fetch_array($resultat2)){ ?>
							<option value="<?php echo $matiere['matiere']; ?>">
									<?php echo ' '.$matiere['matiere']; ?>
							</option>
									<?php } ?>
					</select>
			</td>
		</tr>
						
		<tr>
			<td colspan=4 >			
				<font background="#000" size="4px" color="black" >Trimestre 1</font>
			</td>
			<td colspan=4>			
				<font background="#000" size="4px" color="black" >Trimestre 2 </font>
			</td>
		</tr>
		<tr>
			<td>
				note
					<input type="text" name="note1" size=3 maxlength=6 />
			</td>
			<td>
				note2:
					<input type="text" name="note2" size="3" maxlength="6" />
			</td>
			<td>
				note3:
					<input type="text" name="note3" size="3" maxlength="6" />
			</td>
			<td>
				composition
					<input type="text" name="compo1" size="3" maxlength=6 />
			</td>
			<td>
			note4:
			<input type="text" name="note4"size="3" maxlength="6" />
			</td>
			<td>
				note5:
					<input type="text" name="note5" size="3" maxlength="6" />
			</td>
			<td>
				note6:
					<input type="text" name="note6" size="3" maxlength="6" />
			</td>
			<td>
				composition:
					<input type="text" name="compo2" size="3" maxlength="6" /></td>
		</tr>
		<tr>
				
			<td cellpadding=2px colspan=8>	<input type="submit" name="ok" value="Ajouter" />
			</td>
		</tr>
</table>	<br />	<br />
</form>
<?php
			if(isset($_POST['ok']))
			{
		    
		$req= mysql_query("select * FROM note where idelevenote='".$_POST['id']."' and matierenote='".$_POST['matiere']."'  ");
		     
   			 if(mysql_num_rows($req)>0)
    		{  
				echo "MATIERE DEJA AJOUTEE VEILLEZ TOUT SIMPLEMENT CLIQUER SUR MODIFIER ";
			}
			else
			{
				$id_eleve=$_POST['id'];
				$matiere=$_POST['matiere'];
				$note1=$_POST['note1'];
				$note2=$_POST['note2'];
				$note3=$_POST['note3'];
				$compo1=$_POST['compo1'];
				
				$note4=$_POST['note4'];
				$note5=$_POST['note5'];
				$note6=$_POST['note6'];
				$compo2=$_POST['compo2'];
				

		$sql="INSERT INTO note VALUES ('','$id_eleve','$matiere','$note1','$note2', '$note3','$compo1',' ',
					'$note4','$note5','$note6','$compo2',' ')"; 
					
					
					if($result=mysql_query($sql))
				{
					echo "note inseree";
				}
					else 
				{
					echo "l'insersion a échouéé";
				}
			}//Fin else
			}//fin ok
	?>
</div>
					<div id="footer-wrapper">
		<div id="footer">
		<p class="copyright">&copy;&nbsp;&nbsp;2013 TOUS DROIT RESERVE A <a href="#">TOPVISION</a>.</p>
	</div>
</div> <!---Fin footer-wratter-->
</div><!--fin wratter-->
</body>
</html>