Jump to content

roldahayes

Members
  • Posts

    287
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

roldahayes's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. No, awr100-1322.php is the page URL. I want the code within the page to read the url and populate itself with the page url (minus the .php) i.e $CODE = "Page URL Here"; At the moment, I have to manually open the page and change the $CODE to what ever the page Url is - I want this to happen dynamically
  2. I just want to make sure that I have explained myself correctly in my original post. My full URL's are like this: http://mysite.com/PPP/awr99-1322.php Within my code I have: $CODE = "awr99-1322"; (This then generates everything on my page to be working correctly) I need the $CODE="---------"; to be generated every time depending on url name. So for example, if the url was: http://mysite.com/PPP/awr100-1322.php Then the code would end up as, $CODE = "awr100-1322";
  3. Yes, the htaccess appears to be loading (I have it doing other things to different urls on the site)
  4. Is there a way to test this is working? I was thinking I could use: echo 'Display: ' . htmlspecialchars($_GET["id"]); But not sure if this is just not working or it is wrong?
  5. Ok, so do I have to use .htaccess to set this up? I'm a little confused by different examples after searching URL rewriting.
  6. Hi, Is it possible to dynamically change a variable depending on the URL of the page? i.e my code on the page is: $CODE = "somethinghere"; if the page url is www.domain.com/654321.php it chages it to $CODE = "654321"; I hope I've explained this correctly!
  7. Sorry, worked it out again.... // For each value pair, output value to LOG $firstvalue=TRUE; foreach ($_POST as $key => $value) { if (!$firstvalue) { fwrite($log, "\n") ; }
  8. Just one last question, how would I be able to get a line break after each output to make it more readable? I'm assuming I need "\n" somewhere in // For each value pair, output value to LOG $firstvalue=TRUE; foreach ($_POST as $key => $value) { if (!$firstvalue) { fwrite($log, ", ") ; }
  9. Solved, // Open LOG File$log = fopen ("formdata.log" , "a"); // For each value pair, output value to LOG$firstvalue=TRUE;foreach ($_POST as $key => $value) {if (!$firstvalue) { fwrite($log, ", "); } // If value is array (multiple select list)// Output array to LOG (elements sep by -)if (is_array($value) ) {$firstelement=TRUE;fwrite ($log, "\" ");foreach ($value as $element) {if (!$firstelement) {fwrite ($log, "-");$firstelement=FALSE;}fwrite ($log,$element); }} else { // Not array, output simple valuefwrite ($log, "\" $value ");$firstvalue=FALSE;} } // Line Feed and Close LOG fwrite ($log, "\n");fclose ($log); Thanks for looking
  10. Hi, I am having an issue with certain browsers not being able to receive the data from a $POST form. Could anyone advise a way of getting it to log what is being passed from the form and place it in a text file please? <html> <body onLoad="document.myForm.submit();"> <form action="https://secure2.epdq.co.uk/cgi-bin/CcxBarclaysEpdq.e" method="post" name="myForm"> <?php $user_agent = "Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)";?> <? foreach($_POST as $i => $v) { ?> <input type="hidden" name="<?= $i ?>" value="<?= $v ?>" /> <? } ?> <input type="submit" value="If you are not automatically redirected, please click here" /> </form> </body> </html>
  11. ​Ha! Thats what I am finally getting round to doing! Please ignore the html and the way I have posted, I have just cleared out the code to post here. I'll go through your post and see what I can do, Many thanks for helping (again)
  12. Hi, I have this code that runs a simple shopping cart. I'm having an issue where the basket quantities are only updating when there is 1 or 2 lines of products in there. Any more than that and the line keep defaulting back to quantity 1 Is there anything obvious that I have got wrong here? Thanks. <?phpheader("Content-type: text/html; charset=utf-8");session_start(); include_once("head.php");include_once("usr_conn.php");if(!connectDB()) { echo "<p>Unable To Connect To Database</p>"; return; } if (isset ($_GET['src'])) { $_SESSION['returnTo'] = $_GET['src']; } $urlref = $HTTP_REFERER; $prodID = htmlentities ($_GET['productID']); $delete = htmlentities ($_GET ['delete']); $quantity = htmlentities ($_GET['quantity']); $updateQuantity = htmlentities ($_GET['updateQuantity']); $update = htmlentities ($_GET ['update']); $currency = "£"; // maximum querys per user basket $MAXBASKETQUERY = 25; // start the html table?> <?php// check if user has no cookie set if ($userID == "") { ?><div class="alert alert-danger">No Product Querys made yet </div> <?php return; } //if the updated quantity is 0 or blank remove item from basket if ($updateQuantity == '0'){ $delete = 'yes'; } if (($update == 'yes')&& ($updateQuantity == '')){ $delete = 'yes'; } // if delete parameter set to yes run the delete code if ($delete == 'yes') { // if prodID is set, delete that specific product from this userID's basket if ($prodID != "") { $sqlquery = "DELETE FROM basket WHERE userID = '" . $userID . "' AND productID = '" . $prodID . "'"; $result = mysql_query($sqlquery); if ($result) { ?> <div class="alert alert-danger">Item Deleted. Click <a href="update.php"><font color="#990000">Here</font></a> to refresh the basket </div><?php } else { ?> <div class="alert alert-danger">Unable To Delete <br /> Item Click <a href="update.php">Here</a> to refresh the basket</div> <?php } mysql_close(); return; } } //update the shopping basket quantity if ($update == 'yes') { // if prodID is set, delete that specific product from this userID's basket if ($prodID != "") { $sqlquery = "UPDATE basket SET quantity = '" . $updateQuantity . "' WHERE productID = '" . $prodID . "'AND userID = '" . $userID . "'"; $result = mysql_query($sqlquery); if ($result) { ?> <div class="alert alert-danger">Your basket has been updated.</div> <?php } else { ?> <div class="alert alert-danger">Your basket has NOT been updated</div> <?php } } } // find the number of rows in this userID's basket $sqlquery = "SELECT * FROM basket WHERE userID = '" . $userID . "'"; $result = mysql_query($sqlquery); if (!$result) { echo "<p><font class=error>Could not find any entrys for this Basket</small></p>"; mysql_close(); return; } else $rowCount = mysql_num_rows($result); // if prodID is set new product is passed in, add/update the userID's basket if ($prodID != "") { // find if the prodID already exists in this userID's basket $sqlquery = "SELECT * FROM basket WHERE userID = '" . $userID . "' AND productID = '" . $prodID . "'"; $result = mysql_query($sqlquery); $rowCount = mysql_num_rows($result); // if no matches insert the product into the userID's basket if ($rowCount == 0) { // find number of items in basket $sqlquery = "SELECT * FROM basket WHERE userID = '" . $userID . "'"; $result = mysql_query($sqlquery); $rowCount = mysql_num_rows($result); // check if the maxquery's has been reached if ($rowCount > ($MAXBASKETQUERY - 1)) { echo ("<p><font class=error>Only $MAXBASKETQUERY overall orders are allowed, your product could not be added to basket</font></p>"); } else { $expiretime = time() + 7200; $sqlquery = "INSERT INTO basket" . $basketFields . "VALUES ('" . $prodID . "', '1', '" .$userID . "', '" . $expiretime . "')"; $result = mysql_query($sqlquery); if (!$result) echo "<font class=error><p>Could not add item to Basket</p></font>"; } } } // select the userID's basket query and the Product Reference relating to each of the basket's productID's $sqlquery = "SELECT products.Prod_REF, basket.productID, basket.quantity, products.Prod_Make, products.Prod_Model, products.Prod_Type, products.Car_Make, products.Car_Model, products.Price_ExVat, products.Post_ID, Product_Desc FROM basket INNER JOIN products ON basket.productID = products.Prod_ID WHERE ((basket.userID) = '" . $userID . "')"; $result = mysql_query($sqlquery); $rowCount = mysql_num_rows($result); // echo $sqlquery; // *debug // assign the table headers //$dbFields = array( "Reference", "Product Query"); // check if no entries in basket if (!$result || (mysql_num_rows($result) == 0)){ ?> <div class="alert alert-danger">No Product Queries In Basket.</div> <?php } else //*************display contents of basket////////////////////////////////////////////////////// { // echo each header from array //foreach ($dbFields as $headIndex) // echo an extra blank header for the delete item column // fetch each row as an associative array $counter = 1; $price = 0; //set default postage value outside loop$postagerate = 15.00; while ($row = mysql_fetch_assoc($result)){ //decide which postage value is the highest and use that to calculate overall price //get the postage values for each product $sqlpostquery = "SELECT * FROM postage WHERE Post_ID = '" . htmlspecialchars($row['Post_ID']) . "'"; //get the postage values from the database $postresult = mysql_query($sqlpostquery); $rowpost = mysql_fetch_assoc($postresult); // check if postage value was available if ($postresult || !(mysql_num_rows($postresult) == 0)) { $rawpostage = htmlspecialchars($rowpost['Post_Cost']) ? htmlspecialchars($rowpost['Post_Cost']) : 0.00; //get the lowest postage rate. if ($postagerate > $rawpostage) { $postagerate = $rawpostage; } } else { $postagerage = 0.00; } //round postage rate of 2 decimal places $postagerate = $postagerate; //release the postage resultset array mysql_free_result($postresult); echo "<form action=basket.php method=get name=form".$counter."> <input name=update type=hidden value=yes> <input name=productID type=hidden value=". $row['productID'] ."><tr class=stdtable>"; ?> <form method="post" action=""> <table border="0" cellspacing="0" cellpadding="0" width="100%" class="responsive shop_table cart" data-responsive-mode="stack"> <thead> <tr> <th>Part No.</th> <th >Description</th> <th>QTY</th> <th>ex vat</th> <th>inc vat</th> <th>Total Price</th> <th>Remove</th> </tr> </thead> <tbody> <tr> <!-- This is the block that will echo the basket columns --> <td class= partno table-striped mb-none><?php echo("" . htmlspecialchars($row['Prod_REF']) . "");?></td> <td class= descrip table-striped mb-none><?php echo("" . htmlspecialchars($row['Product_Desc']) . "");?></td> <td class= table-striped mb-none><?php echo (" <input name=updateQuantity onchange=submit(); type=text size=2 value=". htmlspecialchars($row['quantity']));?> </td> <td class= table-striped mb-none><?php echo ("". $currency . number_format(htmlspecialchars($row['Price_ExVat']), 2) ."");?></td> <td class= table-striped mb-none><?php echo ("". $currency . number_format(calcVAT($row["Price_ExVat"]), 2) ."");?></td> <td class= table-striped mb-none><?php echo ("". $currency . number_format(((calcVAT($row["Price_ExVat"]* $row['quantity']))), 2) ."");?></td> <td class= table-striped mb-none><?php echo " <a href=\"basket.php?delete=yes&productID=" . $row['productID'] . "\"> <i class=\"fa fa-times\">"; ?></td> </tr> </table> <!-- End of this section --> <?php $counter ++; //get a cumulative value of the price as items are added to the basket and multiply by quantity as we go. $price = $price + (calcVAT (htmlspecialchars($row['Price_ExVat']))) * htmlspecialchars($row['quantity']); } //assign subtotal and round to 2 decimal places $subtotal = $price; $total = $subtotal + $postagerate; //pick overall postage type if ($postagerate == 5) $postage = 3; else if ($postagerate == 9) $postage = 2; else if ($postagerate == 10) $postage = 1; } //update shopper table with new/changed info $sqlshopper = "SELECT * FROM shopper WHERE User_ID = '" . $userID . "'"; //echo "query: " . $sqlshopper; $result = mysql_query($sqlshopper); $rowCount2 = mysql_num_rows($result); //add shopper if ($rowCount2 == 0) { $sqladd = "INSERT INTO shopper" . $shopperFields . "VALUES ('" . $userID . "', '" . $total . "', '" . $postage . "')"; //echo "noshopper: " . $sqladd; $shopadd = mysql_query($sqladd); if (!$shopadd) echo "<font class=error><p>Your basket has not been processed</p></font>"; } else { //update details $sqlupdate = "UPDATE shopper SET Basket_total = '" . $total . "', Postage = '" . $postage . "' WHERE user_ID = '" . $userID . "'"; //echo "shopper: " . $sqlupdate; $shopupdate = mysql_query($sqlupdate); if (!$shopupdate) echo "<font class=error><p>Your basket has not been updated</p></font>"; } // finish table ?> <?php echo $currency; echo number_format($subtotal, 2); ?></span></td></tr><tr class="shipping" style="font-size: 18px"><th>Delivery</th><td><span class="header"> <?php echo $currency; echo number_format($postagerate, 2); ?></span></td></tr><tr class="total"><th><strong>Order Total</strong>(inc vat)</th><td><strong><span class="amount"><?php echo $currency; echo number_format($total, 2); ?></span></strong> </form><?php mysql_free_result($result); mysql_close(); ?>
  13. Ok, That makes sense. That is exactly what I am trying to do - doing it is another thing altogether! I will start to clear up the code as you have suggested and see what I can do.
  14. This code was written years ago so I am now trying to sort the styling out with CSS and removing all the inline stuff. Also, there is so much code that as you've advised, needs streamlining...... Ok, I have made a quick example image of what I am trying to achieve, The database is populated by uploading a CSV file. Each section of the results has a unique code (RB, BH, RA etc) I want each section to appear in the divs as in the picture (div-RB, div-BH, div-RA)
  15. Thanks, I do want the data displayed in a table but I want the sections separated into different coloured divs. At the moment, the code just tells each section which header image to use.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.