Se connecter / S'enregistrer
Votre question

Probleme PHP

Tags :
  • Echo
  • Programmation
Dernière réponse : dans Programmation
9 Février 2008 02:51:04

Bonjour , j'ai mis en place une boutique sur ce site :

mais il ya un soucis lorsque la personne remplit le formulaire l'achat aprés validation , un avertissement apparait :

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /mnt/151/sdb/f/3/banlieueproduction/valide.php:2) in /mnt/151/sdb/f/3/banlieueproduction/valide.php on line 5


j'ai regarde le fichier valide.php , voici le codage , dois je supprimer quelque chose ou pas :


<?

echo "<font color=white>";
session_start();
echo "</font>";
include "configuration.php";
include "page_haut.inc";



$nom = str_replace(" "," ",$nom);
$email = str_replace(" "," ",$email);
$adresse = str_replace(" "," ",$adresse);
$cp = str_replace(" "," ",$cp);
$ville = str_replace(" "," ",$ville);
$tel = str_replace(" "," ",$tel);
$comments = str_replace(" "," ",$comments);

$typecarte = str_replace(" "," ",$typecarte);
$titulaire = str_replace(" "," ",$titulaire);
$cartexpire = str_replace(" "," ",$carteexpire);
$cartenumero = str_replace(" "," ",$cartenumero);


$typecarte = htmlentities($typecarte);
$titulaire = htmlentities($titulaire);
$carteexpire = htmlentities($carteexpire);
$cartenumero = htmlentities($cartenumero);


if ($nom == "") {
$font_name = "<font color=red><b>*</b></font> Prénom & Nom: </font>";
$field_name = "notok";
} else {
$font_name = "<font color=red><b>*</b></font> Prénom & Nom: </font>";
$field_name = "ok";
}

if ($adresse == "") {
$font_address = "<font color=red><b>*</b></font> Adresse: </font>";
$field_address = "notok";
} else {
$font_address = "<font color=red><b>*</b></font> Adresse: </font>";
$field_address = "ok";
}

if ($cp == "") {
$font_zip = "<font color=red><b>*</b></font> Code Postal: </font>";
$field_zip = "notok";
} else {
$font_zip = "<font color=red><b>*</b></font> Code Postal: </font>";
$field_zip = "ok";
}

if ($pays == "") {
$font_country = "<font color=red><b>*</b></font> Pays: </font>";
$field_country = "notok";
} else {
$font_country = "<font color=red><b>*</b></font> Pays: </font>";
$field_country = "ok";
}

if ($ville == "") {
$font_city = "<font color=red><b>*</b></font> Ville: </font>";
$field_city = "notok";
} else {
$font_city = "<font color=red><b>*</b></font> Ville: </font>";
$field_city = "ok";
}

if ($tel == "") {
$font_phone = "<font color=red><b>*</b></font> Téléphone: </font>";
$field_phone = "notok";
} else {
$font_phone = "<font color=red><b>*</b></font> Téléphone: </font>";
$field_phone = "ok";
}

if ($typecarte == "") {
$font_typecarte = "<font color=red><b>*</b></font> Carte de crédit: </font>";
$field_typecarte = "notok";
} else {
$font_typecarte = "<font color=red><b>*</b></font> Carte de Crédit: </font>";
$field_typecarte = "ok";
}
if ($titulaire == "") {
$font_titulaire = "<font color=red><b>*</b></font> Titulaire: </font>";
$field_titulaire = "notok";
} else {
$font_titulaire = "<font color=red><b>*</b></font> Titulaire: </font>";
$field_titulaire = "ok";
}
if ($carteexpire == "") {
$font_carteexpire = "<font color=red><b>*</b></font> Expire le: </font>";
$field_carteexpire = "notok";
} else {
$font_carteexpire = "<font color=red><b>*</b></font> Expire le: </font>";
$field_carteexpire = "ok";
}
if ($cartenumero == "") {
$font_cartenumero = "<font color=red><b>*</b></font> Carte Numéro: </font>";
$field_cartenumero = "notok";
} else {
$font_cartenumero = "<font color=red><b>*</b></font> Carte Numéro: </font>";
$field_cartenumero = "ok";
}



if ($email == "") {
$font_email = "<font color=red><b>*</b></font> Email: </font>";
$field_email = "notok";
} else {

$split = explode("@", $email);

if (IsSet($split[1])) {
$check = explode(".", $split[1]);
if (IsSet($check[1])) {
$font_email = "<font color=red><b>*</b></font> Email: </font>";
$field_email = "ok";
} else {
$font_email = "<font color=red><b>*</b></font> Email: </font>";
$field_email = "notok";
}
} else {
$font_email = "<font color=red><b>*</b></font> Email: </font>";
$field_email = "notok";
}
}


if (($field_name == "ok") && ($field_address == "ok") && ($field_email == "ok") && ($field_zip == "ok") && ($field_country == "ok") && ($field_city == "ok")){

if ($mobile == "") {
$mobile = "non";
}

$active = "non";

$split = explode(",",$list);

foreach ($split as $item) {
$check = explode("+",$item);
$query = mysql_query("SELECT nom,prix,frais FROM $sbbproduit WHERE id='$check[0]'");
$row = mysql_fetch_row($query);


$price = $row[1] * $check[1];
$price = sprintf("%0.2f", $price);

if (!IsSet($total)) {
$total = 0;
}

$total = $total + $price;
$total = sprintf("%0.2f", $total);
if (!IsSet($order)) {
$order = "$check[1] x $row[0]";
$quantite = $check[1];
} else {
$order = "$order,; $check[1] x $row[0]";
$quantite = ($order + $check[1]);
}
}

$price = $total;

$query = "SELECT MAX(id) FROM $sbbcmde";

$result = mysql_query($query) or die ("ERROR: [$query]<br>" . mysql_error());
$row = mysql_fetch_row($result);
$num = $row[0] + 1;

$ordercode = mt_rand(1000000000,9999999999);

$insert = mysql_query("INSERT INTO $sbbcmde (articles,qte,prix,nom,adresse,cp,ville,pays,tel,mobile,email,typecarte,titulaire,carteexpire,cartenumero,comments,active,commande,hid) VALUES ('$order','$quantite','$price','$nom','$adresse','$cp','$ville','$pays','$tel','$mobile','$email','$typecarte','$titulaire','$carteexpire','$cartenumero','$comments','$active','$ordercode','$hid')") || die (mysql_error());

$subject = "Votre commande $boutique";
$body = "<font color=navy><b>Cher(e) $name,<br><br>Ci-dessous, votre commande<br><br>";
$body .= "Articles commmandés : <b>$order</b<br>";
$body .= "Total de la commande: <b>$price TTC</b><br>";
$body .= "Merci pour votre commande sur $boutique.<br>Veuillez cliquer sur l'URL ci-dessous pour activer votre commande. Si vous n'avez pas activé votre commande, celle-ci sera annulée!<br><br>";
$body .= "<a href=\"$active_url?id=$num&ordercode=$ordercode\">Activer la commande</a>";


mail($email,$subject,$body,"From: $boutique\nMime-Version: 1.0\nContent-Type: text/html; charset=ISO-8859-1\n");

} else {

?>

<form action="valide.php" method="post">

<table border="0" width="90%">
<tr>
<td colspan="2" align="center">Formulaire de commande</td>
</tr><tr>
<td colspan="2" align="center"> </td>
</tr><tr>
<td><? echo "$font_name"; ?></td>
<td><input type="text" name="name" size="40" value="<? echo "$name"; ?>"></td>
</tr><tr>
<td><? echo "$font_address"; ?></td>
<td><input type="text" name="address" size="40" value="<? echo "$address"; ?>"></td>
</tr><tr>
<td><? echo "$font_zip"; ?></td>
<td><input type="text" value="<? echo "$zip"; ?>" name="zip" size="40"></td>
</tr><tr>
<td><? echo "$font_city"; ?></td>
<td><input type="text" name="city" size="40" value="<? echo "$city"; ?>"></td>
</tr><tr>
<td><? echo "$font_country"; ?></td>
<td><input type="text" name="country" value="<? echo "$country"; ?>" size="40"></td>
</tr><tr>
<td><? echo "$font_phone"; ?></td>
<td><input type="text" name="phone" size="40" value="<? echo "$phone"; ?>"></td>
</tr><tr>
<td>   Mobile: </td>
<td><input type="text" name="mobile" value="<? echo "$mobile"; ?>" size="40"></td>
</tr><tr>
<td><? echo "$font_email"; ?></td>
<td><input type="text" name="email" value="<? echo "$email"; ?>" size="40"></td>
</tr>
<tr>
<td><? echo "$font_typecarte"; ?></td>
<td><input type="text" name="typecarte" value="<? echo "$typecarte"; ?>" size="40"></td>
</tr><tr>
<td><? echo "$font_titulaire"; ?></td>
<td><input type="text" name="titulaire" size="40" value="<? echo "$titulaire"; ?>"></td>
</tr><tr>
<td><? echo "$font_carteexpire"; ?></td>
<td><input type="text" name="carteexpire" value="<? echo "$carteexpire"; ?>" size="40"></td>
</tr><tr>
<td><? echo "$font_cartenumero"; ?></td>
<td><input type="text" name="cartenumero" value="<? echo "$cartenumero"; ?>" size="40"></td>
</tr>
<tr>
<td colspan="2">Commentaires: <br>
<textarea name="comments" rows="6" cols="61"></textarea>
</td>
</tr><tr>
<td colspan="2"></td>
</tr>
</table>

<?

echo "<table border=\"0\" width=\"90%\">";
echo "<tr>";
echo "<td align=\"center\">Votre commande</td></tr>";
echo "<tr bgcolor=#dedede><td align=left>Articles</td><td align=left>Quantité</td><td align=left>Prix HT</td><td align=left>Prix TTC</td>";

$split = explode(",",$list);

foreach ($split as $item) {
$check = explode("+",$item);
$query = mysql_query("SELECT nom,prix,frais FROM $sbbproduit WHERE id='$check[0]'");
$row = mysql_fetch_row($query);
echo "</tr><tr>";
echo "<td class=\"standard\">$row[0]</td>";
echo "<td class=\"standard\">$check[1]</td>";

$frais = $row[2];
$price = ($row[1] + $row[2]) * $check[1];
$price = sprintf("%0.2f", $price);
$prixht = $price / $tva;
$prixht2 = sprintf("%0.2f", $prixht);
echo "<td align=\"left\">$prixht2</td>";
echo "<td align=\"left\">$price</td>";

if (!IsSet($total)) {
$total = 0;
}

$total = $total + $price;
$total = sprintf("%0.2f", $total);


$totalht = $total / $tva;
$totalht2 = sprintf("%0.2f", $totalht);

}

echo "</tr><tr>";
echo "<td> </td>";
echo "<td> </td>";
echo "<td><hr size=\"1\" color=\"black\"></td>";
echo "<td><hr size=\"1\" color=\"black\"></td>";

echo "</tr><tr>";
echo "<td> </td>";
echo "<td> </td>";
echo "<td align=\"left\"><b>$totalht2</b> $devises</td>";
echo "<td align=\"left\"><b>$total</b> $devises</td>";
echo "</tr></table><hr><center>
<input type=hidden name=hid value='$check[0]'>
<input type='submit' value='Confirmer la commande'></center><br></form>";
}
?>



MERCI DAVANCE

Autres pages sur : probleme php

9 Février 2008 08:50:15

Salut,
Ton session_start(); doit être la première instruction.

Place le avant ton "echo", juste après la balise PHP "<?"
10 Février 2008 01:23:29

j'ai corriger mais je crois qu'il ya d'autres ,pouvez faire un tour dans le site , commandez et ditez moi qu'elles problemes persistent .

Merci
Tom's guide dans le monde
  • Allemagne
  • Italie
  • Irlande
  • Royaume Uni
  • Etats Unis
Suivre Tom's Guide
Inscrivez-vous à la Newsletter
  • ajouter à twitter
  • ajouter à facebook
  • ajouter un flux RSS