Notice: Undefined index: address in
Meve
Messages postés
1
Statut
Membre
-
Utilisateur anonyme -
Utilisateur anonyme -
Bonjour,
Je suis très très débutante en programmation PHP5 et depuis quelques jours j'essais de trouver le problème.
J'obtient toujours l'erreur suivante : Notice: Undefined index: address in [...] on line 7
Aussi à la ligne 61, une adresse est supposé s'incrire lorsque la personne l'inscrit dans le formulaire mais lorsque je le test rien n'y fait.
<?php
// crée des noms de variables abrégées
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty = $_POST['sparkqty'];
$find = $_POST['find'];
$address = $_POST['address'];
$document_root = $_SERVER['DOCUMENT_ROOT'];
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
$date = date ('j F H:i');
echo '<p>Order processed at ';
date('j F H:i');
echo '</p>';
echo '<p>Your order is as follows: </p>';
$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
echo 'Items ordered: '.$totalqty.'<br />';
if( $totalqty == 0 )
{
echo '<font color=red>';
echo 'You did not order anything on the previous page!<br></font>';
exit;
}
else
if ( $tireqty>0 )
echo $tireqty.' tires<br>';
if ( $oilqty>0 )
echo $oilqty.' bottles of oil<br>';
if ($sparkqty>0)
echo $sparkqty.' spark plugs<br>';
echo 'Items ordered: '.$totalqty. '<br />';
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);
$totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE;
$totalamount=number_format($totalamount, 2, '.', ' ');
$taxrate = 0.10; // le taux de la taxe est de 10 %
$totalamount = $totalamount * (1 + $taxrate);
echo 'Total including tax: $'.number_format($totalamount,2).'<br />';
echo '<p>Address to ship to is : '.$address.'</p>';
if ($find == 'a')
echo '<p>Regular customer. </p>';
elseif($find == 'b')
echo '<p>Customer referred by TV advert. </p>';
elseif($find == 'c')
echo '<p>Customer referred by phone directory.</p>';
elseif($find == 'd')
echo '<p>Customer referred by word of mouth. </p>';
else
echo '<p>We do not know how this customer found us.</p>';
$outputstring = $date."\t".$tireqty." tires \t". $oilqty." oil\t". $sparkqty." spark plugs\t\$".$totalamount."\t". $address."\n";
//open file pour commandes
@ $fp = fopen("$DOCUMENT_ROOT//..//orders//orders.txt", 'ab');
if (!$fp)
{
echo '<p><strong> Your order could not be processed at this time. '
.'Please try again later.</strong></p>';
exit;
}
fwrite($fp, $str, $length($outpustring));
fclose($fp);
echo '<p>Order written. </p>';
?>
</body>
</html>
Merci pour l'aide que vous pourrez m'apporter.
Je suis très très débutante en programmation PHP5 et depuis quelques jours j'essais de trouver le problème.
J'obtient toujours l'erreur suivante : Notice: Undefined index: address in [...] on line 7
Aussi à la ligne 61, une adresse est supposé s'incrire lorsque la personne l'inscrit dans le formulaire mais lorsque je le test rien n'y fait.
<?php
// crée des noms de variables abrégées
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty = $_POST['sparkqty'];
$find = $_POST['find'];
$address = $_POST['address'];
$document_root = $_SERVER['DOCUMENT_ROOT'];
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
$date = date ('j F H:i');
echo '<p>Order processed at ';
date('j F H:i');
echo '</p>';
echo '<p>Your order is as follows: </p>';
$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
echo 'Items ordered: '.$totalqty.'<br />';
if( $totalqty == 0 )
{
echo '<font color=red>';
echo 'You did not order anything on the previous page!<br></font>';
exit;
}
else
if ( $tireqty>0 )
echo $tireqty.' tires<br>';
if ( $oilqty>0 )
echo $oilqty.' bottles of oil<br>';
if ($sparkqty>0)
echo $sparkqty.' spark plugs<br>';
echo 'Items ordered: '.$totalqty. '<br />';
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);
$totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE;
$totalamount=number_format($totalamount, 2, '.', ' ');
$taxrate = 0.10; // le taux de la taxe est de 10 %
$totalamount = $totalamount * (1 + $taxrate);
echo 'Total including tax: $'.number_format($totalamount,2).'<br />';
echo '<p>Address to ship to is : '.$address.'</p>';
if ($find == 'a')
echo '<p>Regular customer. </p>';
elseif($find == 'b')
echo '<p>Customer referred by TV advert. </p>';
elseif($find == 'c')
echo '<p>Customer referred by phone directory.</p>';
elseif($find == 'd')
echo '<p>Customer referred by word of mouth. </p>';
else
echo '<p>We do not know how this customer found us.</p>';
$outputstring = $date."\t".$tireqty." tires \t". $oilqty." oil\t". $sparkqty." spark plugs\t\$".$totalamount."\t". $address."\n";
//open file pour commandes
@ $fp = fopen("$DOCUMENT_ROOT//..//orders//orders.txt", 'ab');
if (!$fp)
{
echo '<p><strong> Your order could not be processed at this time. '
.'Please try again later.</strong></p>';
exit;
}
fwrite($fp, $str, $length($outpustring));
fclose($fp);
echo '<p>Order written. </p>';
?>
</body>
</html>
Merci pour l'aide que vous pourrez m'apporter.
A voir également:
- Notice: Undefined index: address in
- Notice gratuite - Guide
- Notice chromecast - Guide
- Notice télécommande universelle grundig - Forum Téléviseurs
- Uleway g381 notice - Forum Mobile
- Homday x-pert écouteur bluetooth notice ✓ - Forum Casque et écouteurs