bayans
Messages postés14Date d'inscriptionmardi 17 novembre 2009StatutMembreDernière intervention 2 décembre 2012
-
1 déc. 2010 à 17:16
bodo2011
Messages postés9Date d'inscriptionmardi 25 janvier 2011StatutMembreDernière intervention11 juin 2012
-
3 févr. 2011 à 14:28
Je n’avais jamais entendu parler de PHP jusqu’a ce que mon professeur en parle. Un travail nous a déjà était donne par mon professeur mais mon code me donne toujours les même erreurs et je ne sais pas du tout quoi faire même si je suis les instructions qui m’on était donne. Voici le code et que j’ai écrit ci-dessous ainsi que les erreurs que je ne cesse d’avoir. Les erreurs ceux trouvent a la fin du code.
1:<hmtl>
2:<head>
3:<title> Order confirmation</title>
4:
5: Your order has been successfully confirmed
6:<marquee>Thank you!!!!</marquee>
<?php
$suitqty = $HTTP_POST_VARS['suitqty']; //These are a new variables
$shoeqty = $HTTP_POST_VARS['shoeqty'];
$jacketqty=$HTTP_POST_VARS['jacketqty'];
$beltqty = $HTTP_POST_VARS['beltqty'];
$waistcoatqty = $HTTP_POST_VARS['waistcoatqty'];
$address = $HTTP_POST_VARS['address'];
?>
<?php
echo ' Order processed at'; // I passed string to the date function and it will display the time, date and month of the customer's order
echo date('H:i, jS F');
echo '
';
echo'Your order is as follows:
'; //The customer will be able to see the items that he/she order
echo $suitqty.'suits
';
echo $shoeqty.'shoes
';
echo $jacketqty.'jackets
';
echo $beltqty .'belts
';
echo $waistcoatqty .'waistcoat
';
echo 'Customer Address: '.$address. '
';
$totalqty = 0; // I assigned a values to those variables
$totalqty = $suitqty + $shoeqty + $jacketqty + $beltqty + $waistcoatqty;//The totalqty variable will calculate the total number of items
echo 'Items ordered: '.$totalqty.'
'; //It will display the total amount
if( $totalqty ==0 ) //The condition will be true if $totalqty is equal to zero,
{
echo'';
echo'You did not order anything on the previous page!
';
echo'';
exit;// It stops PHP from executing remainder of the script
}
else
{
if ( $suitqty < 0 )
$discount = 0;
if (isset($discount)){
echo "you will get\t" , $discount , " % off your order";
}
$totalamount = 0.00;
define('SUITPRICE', 150); // I define constants using the define function and I stored the price for each item
define;
define('SHOEPRICE', 60);
define('JACKETPRICE', 20);
define('BELTPRICE', 20);
define('WAISTCOATPRICE', 35);
<?php
$myfile = fopen('orders.txt', 'a');
if (!$myfile)
flock($myfile, LOCK_EX); //Lock the file for writing
$outputstring = date('H:i jS F'). "|\t Suit: ".$suitqty." |\t Shoe: ".$shoeqty."|\t Jacket: ".$jacketqty." |\t Belt: ".$belt."|\t Waistcoat: ".$waistcoatqty." \n";
fwrite($myfile, $outputstring);
flock($myfile, LOCK_UN); // Release write lock
fclose($myfile);
if (!$myfile)
{
echo ' Your order could not be processed at this time. Please try again later.
';
exit;
}
echo '
';
?>
</html>
</head>
Erreurs:
Warning: fopen(orders.txt) [function.fopen]: failed to open stream: Permission denied in /u2.bristol/s09/abkh536/public_html/ee2505/processorder.php on line 164
Warning: flock() expects parameter 1 to be resource, boolean given in /u2.bristol/s09/abkh536/public_html/ee2505/processorder.php on line 166
Warning: fwrite(): supplied argument is not a valid stream resource in /u2.bristol/s09/abkh536/public_html/ee2505/processorder.php on line 168
Warning: flock() expects parameter 1 to be resource, boolean given in /u2.bristol/s09/abkh536/public_html/ee2505/processorder.php on line 169
Warning: fclose(): supplied argument is not a valid stream resource in /u2.bristol/s09/abkh536/public_html/ee2505/processorder.php on line 170
cod57
Messages postés1653Date d'inscriptiondimanche 7 septembre 2008StatutMembreDernière intervention11 septembre 201319 1 déc. 2010 à 19:13
bonsoir
a++
$HTTP_POST_VARS n'est plus utilisé en php5
1:<hmtl>
2:<head>
3:<title> Order confirmation</title>
4:
5: Your order has been successfully confirmed
6:<marquee>Thank you!!!!</marquee>
<?php
/*$suitqty = $HTTP_POST_VARS['suitqty']; //These are a new variables
$shoeqty = $HTTP_POST_VARS['shoeqty'];
$jacketqty=$HTTP_POST_VARS['jacketqty'];
$beltqty = $HTTP_POST_VARS['beltqty'];
$waistcoatqty = $HTTP_POST_VARS['waistcoatqty'];
$address = $HTTP_POST_VARS['address']; */
if(isset($_POST['suitqty'],$_POST['shoeqty'],$_POST['jacketqty'],$_POST['beltqty'],$_POST['waistcoatqty'],$_POST['address'])){
$suitqty = $_POST['suitqty']; //These are a new variables
$shoeqty = $_POST['shoeqty'];
$jacketqty=$_POST['jacketqty'];
$beltqty = $_POST['beltqty'];
$waistcoatqty = $_POST['waistcoatqty'];
$address = $_POST['address'];
} else {
$suitqty = "";//These are a new variables
$shoeqty = "";
$jacketqty="";
$beltqty = "";
$waistcoatqty = "";
$address ="";
}
?>
<?php
echo ' Order processed at'; // I passed string to the date function and it will display the time, date and month of the customer's order
echo date('H:i, jS F');
echo '
';
echo'Your order is as follows:
'; //The customer will be able to see the items that he/she order
echo $suitqty.'suits
';
echo $shoeqty.'shoes
';
echo $jacketqty.'jackets
';
echo $beltqty .'belts
';
echo $waistcoatqty .'waistcoat
';
echo 'Customer Address: '.$address. '
';
$totalqty = 0; // I assigned a values to those variables
$totalqty = $suitqty + $shoeqty + $jacketqty + $beltqty + $waistcoatqty;//The totalqty variable will calculate the total number of items
echo 'Items ordered: '.$totalqty.'
'; //It will display the total amount
if( $totalqty ==0 ) //The condition will be true if $totalqty is equal to zero,
{
echo'';
echo'You did not order anything on the previous page!
';
echo'';
exit;// It stops PHP from executing remainder of the script
}
else
{
if ( $suitqty < 0 )
$discount = 0;
if (isset($discount)){
echo "you will get\t" , $discount , " % off your order";
}
$totalamount = 0.00;
define('SUITPRICE', 150); // I define constants using the define function and I stored the price for each item
define;
define('SHOEPRICE', 60);
define('JACKETPRICE', 20);
define('BELTPRICE', 20);
define('WAISTCOATPRICE', 35);
<?php
$myfile = fopen('orders.txt', 'a');
if (!$myfile)
flock($myfile, LOCK_EX); //Lock the file for writing
$outputstring = date('H:i jS F'). "|\t Suit: ".$suitqty." |\t Shoe: ".$shoeqty."|\t Jacket: ".$jacketqty." |\t Belt: ".$belt."|\t Waistcoat: ".$waistcoatqty." \n";
fwrite($myfile, $outputstring);
flock($myfile, LOCK_UN); // Release write lock
fclose($myfile);
if (!$myfile)
{
echo ' Your order could not be processed at this time. Please try again later.