Warning: Cannot modify header information

Résolu/Fermé
Sinistrus Messages postés 1017 Date d'inscription mercredi 12 décembre 2007 Statut Membre Dernière intervention 6 juin 2023 - 6 juil. 2011 à 11:27
CrazyWorld Messages postés 326 Date d'inscription samedi 8 novembre 2008 Statut Membre Dernière intervention 16 février 2013 - 6 juil. 2011 à 11:49
Bonjour,

J'ai deux problèmes ici et le premier est plus important que l'autre et je sollicite votre aide.

Avec ce code, j'obtiens cette erreur :
Warning: Cannot modify header information - headers already sent by (output started at /home/xxx/domains/mondomaine.com/public_html/KeyProduct.php:10) in /home/xxx/domains/mondomaine.com/public_html/KeyProduct.php on line 12


Voici mon code :
<?php
if (isset($_POST["Valid"])) {
$Valid =  $_POST["Valid"];

mysql_connect("localhost", "jaber2_testes", "KOcmGhVz");
mysql_select_db("jaber2_testes");  

$req=mysql_query("select * from clevalidation where Validation='$Valid'"); 
$nb= mysql_num_rows($req);
echo $nb;
if ( $nb > 0 )
header('Location: Validite.php');
else
header('Location: Invalidite.php');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HightSecurity</title>
<style type="text/css">
<!--
body,td,th 			{font-family: Tahoma;font-size: 13px;}
body 				{margin: 0px;}
a.Verif				{background:url(BoutonVerifier.png) no-repeat; width:89px; height:25px; display:block;}
a.Verif:hover		{background-position: bottom center;}
-->
</style>

</head>

<body>

<table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="592" align="center" valign="middle" background="Ecran.jpg">
<form id="form1" name="form1" method="post" action="">
<input name="Valid" type="text" id="Valid" size="35" maxlength="25" />
<br /><br />
<input type="submit" name="button" id="button" value="Installer" />
<a href="#" class="Verif"></a>
</form>
</td>
</tr>
</table>
</body>
</html>

Et le second problème est sur celui-ci :
Je voudrais remplacer le bouton submit par ce code:
<a href="#" class="Verif"></a>

4 réponses

CrazyWorld Messages postés 326 Date d'inscription samedi 8 novembre 2008 Statut Membre Dernière intervention 16 février 2013 41
6 juil. 2011 à 11:49
Salut, il faut aucun affichage avant la fonction Header, le soucis viens de la ligne 10
echo $nb;


et pour remplacer le bouton submit
<a href="javascript:void(0)" class="Verif" onclick="document.forms['form1'].submit();">Submit</a>
1
Melooo Messages postés 1405 Date d'inscription vendredi 28 novembre 2008 Statut Membre Dernière intervention 18 mars 2013 84
6 juil. 2011 à 11:44
Salut,
Discussion abordée d'innombrable fois !
Première erreur : normal, tu envoi des données, donc ton header ne peux pas fonctionner, vire ton echo ca fonctionnera mieux.
Pour la deuxième question, essayes ca :
<a href="javascript:;" onclick="this.submit()">envoyer</a>
0
adns Messages postés 1094 Date d'inscription vendredi 23 février 2007 Statut Membre Dernière intervention 27 mars 2012 153
6 juil. 2011 à 11:45
Bonjour,

Ton premier problème, me semble t-il vient du fait que tu écris avant ton DOCTYPE ce qui dans mes souvenir est "interdit".

Pour ton deuxième problème tu peux utiliser ce code

<a href="#" class="Verif" onclick="document.getElementById('form1').submit();"></a>


En espérant avoir aidé

Adns
0
Sinistrus Messages postés 1017 Date d'inscription mercredi 12 décembre 2007 Statut Membre Dernière intervention 6 juin 2023 17
6 juil. 2011 à 11:47
Merci à tous les deux, ca fonctionne super bien maintenant ^^
0