-
Posts
2,527 -
Joined
-
Last visited
Everything posted by DeanWhitehouse
-
Read up on CURL and how to post to a page using it.
-
Add error_reporting(E_ALL); at the top of the code
-
I change some of it. If their are any errors in the script post the error message here and the surrounding lines. <?php function printHiddenVars() { $dbcnx = mysql_connect("mysql", "", ""); mysql_select_db("mas_products", $dbcnx); $result = mysql_query("SELECT id, name FROM component;"); if(!$result) die("<p>Error performing query: " . mysql_error() . "</p>"); else { while($row = mysql_fetch_array($result)) { echo "<input type=hidden name=\"".trim($row['name'])."\" value=\"".str_replace("\\\\\\","",$_POST[trim($row['name'])])."\" />\n"; } } mysql_close($dbcnx); } function printOrder() { $dbcnx = mysql_connect("mysql", "", ""); mysql_select_db("mas_products", $dbcnx); $result = mysql_query("SELECT id, name FROM component;"); if(!$result) die("<p>Error performing query: " . mysql_error() . "</p>"); else { while($row = mysql_fetch_array($result)) { if(strlen($_POST[trim($row['name'])]) != 0) echo "<br />".str_replace("\\\\\\","",$_POST[trim($row['name'])])."\n"; } } mysql_close($dbcnx); } if(isset($_POST['action'])) { $dbcnx = mysql_connect("mysql", "", ""); mysql_select_db("mas_products", $dbcnx); $strComments = ""; $result = mysql_query("SELECT id, name FROM component;"); if(!$result) die("<p>Error performing query: " . mysql_error() . "</p>"); else { while($row = mysql_fetch_array($result)) { $strComments .= $_POST[trim($row['name'])]."\n"; } } $sql = "INSERT INTO user_purchase (Product, BillName, BillAddress, BillAddress2, BillCity, BillState, BillZip, ShipName, ShipAddress, ShipAddress2, ShipCity, ShipState, ShipZip, Email, Phone, CCName, CCNumber, CCType, CCSec, CCExpMonth, CCExpYear, DateCreated, ConfiguredPrice, Comments) VALUES ('".mysql_real_escape_string($_POST['product'])."', '".mysql_real_escape_string($_POST['billname'])."', '".mysql_real_escape_string($_POST['billaddress'])."', '".$_POST['billaddress2']."', '".mysql_real_escape_string($_POST['billcity'])."', '".mysql_real_escape_string($_POST['billstate'])."', '".mysql_real_escape_string($_POST['billzip'])."', '".mysql_real_escape_string($_POST['shipname'])."', '".mysql_real_escape_string($_POST['shipaddress'])."', '".mysql_real_escape_string($_POST['shipaddress2'])."', '".$_POST['shipcity']."', '".mysql_real_escape_string($_POST['shipstate'])."', '".mysql_real_escape_string($_POST['shipzip'])."', '".mysql_real_escape_string($_POST['email'])."', '".mysql_real_escape_string($_POST['phone'])."', '".mysql_real_escape_string($_POST['ccname'])."', '".mysql_real_escape_string($_POST['ccnumber'])."', '".mysql_real_escape_string($_POST['cctype'])."', '".mysql_real_escape_string($_POST['ccsec'])."', '".mysql_real_escape_string($_POST['ccmonth'])."', '".mysql_real_escape_string($_POST['ccyear'])."', NOW(), '".mysql_real_escape_string($_POST['compprice'])."', '".mysql_real_escape_string($strComments)."' ) "; if(mysql_query($sql)) { $ordernumber = mysql_insert_id(); mail("morrison5891@hotmail.com", "You Have A New Order Waiting", "You have 1 new order waiting. Login to view this order. http://www.ictindy.com/ssl/purchaseview.php \n\n"); mail("dmorrison@ictindy.com", "You Have A New Order Waiting", "You have 1 new order waiting. Login to view this order. http://www.ictindy.com/ssl/purchaseview.php \n\n"); mail($_POST['email'], "Your order has been received.", "Your credit card has not been charged yet. You will receive an e-mail when your order has been processed.\n\nYour order number is: ".$ordernumber."\n\nIf you have any questions about your order, please e-mail us at orders@ictindy.com or visit http://www.ictindy.com/ssl/trackorder.php to check the status of your order. Thank You - Extreme PC"); header("Location: https://p2.secure.hostingprod.com/@ictindy.com/ssl/thankyou.php?ordernumber=".$ordernumber); } else { die(mysql_error()); } mysql_close($dbcnx); } else { if($_POST['billstate'] == "IN") { $price = $_POST['compprice']; $price = round($price * .07 + $price, 2); } else $price = $_POST['compprice']; ?> <!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" /> <!-- TemplateBeginEditable name="doctitle" --> <title>Extreme PC - Confirm Order And Check Out</title> <meta name="robots" content="noindex, nofollow"> <!-- TemplateEndEditable --> <!-- TemplateBeginEditable name="head" --> <!-- TemplateEndEditable --> <style type="text/css"> <!-- body { font: 100% Verdana, Arial, Helvetica, sans-serif; background: #666666; margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */ padding: 0; text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */ color: #000000; background-image: url(https://p2.secure.hostingprod.com/@ictindy.com/ssl/Pictures/bg9_3.gif); } td { font: 100% Verdana, Arial, Helvetica, sans-serif; color: #000; } /* Tips for Elastic layouts 1. Since the elastic layouts overall sizing is based on the user's default fonts size, they are more unpredictable. Used correctly, they are also more accessible for those that need larger fonts size since the line length remains proportionate. 2. Sizing of divs in this layout are based on the 100% font size in the body element. If you decrease the text size overall by using a font-size: 80% on the body element or the #container, remember that the entire layout will downsize proportionately. You may want to increase the widths of the various divs to compensate for this. 3. If font sizing is changed in differing amounts on each div instead of on the overall design (ie: #sidebar1 is given a 70% font size and #mainContent is given an 85% font size), this will proportionately change each of the divs overall size. You may want to adjust these divs based on your final font sizing. */ .twoColElsLt #container { width: 910px; /* this width will create a container that will fit in an 800px browser window if text is left at browser default font sizes */ background: #FFFFFF; margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */ border: 1px solid #000000; text-align: left; /* this overrides the text-align: center on the body element. */ } /* Tips for mainContent: 1. If you give this #mainContent div a font-size value different than the #sidebar1 div, the margins of the #mainContent div will be based on its font-size and the width of the #sidebar1 div will be based on its font-size. You may wish to adjust the values of these divs. 2. The space between the mainContent and sidebar1 is created with the left margin on the mainContent div. No matter how much content the sidebar1 div contains, the column space will remain. You can remove this left margin if you want the #mainContent div's text to fill the #sidebar1 space when the content in #sidebar1 ends. 3. To avoid float drop, you may need to test to determine the approximate maximum image/element size since this layout is based on the user's font sizing combined with the values you set. However, if the user has their browser font size set lower than normal, less space will be available in the #mainContent div than you may see on testing. 4. In the Internet Explorer Conditional Comment below, the zoom property is used to give the mainContent "hasLayout." This avoids several IE-specific bugs that may occur. */ .twoColElsLt #mainContent { margin: 0 1.5em 0 4px; /* the right margin can be given in ems or pixels. It creates the space down the right side of the page. */ } /* Miscellaneous classes for reuse */ .fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */ float: right; margin-left: 8px; } .fltlft { /* this class can be used to float an element left in your page */ float: left; margin-right: 8px; } .clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */ clear:both; height:0; font-size: 1px; line-height: 0px; } a:link { color: #0000FF; text-decoration: none; } a:visited { text-decoration: none; color: #0000FF; } a:hover { text-decoration: none; color: #FF0000; } a:active { text-decoration: none; color: #0000FF; } .style4 {font-size: xx-small} .style5 { font-size: x-small; font-weight: bold; } .style6 { color: #0000FF; font-size: small; } .style7 {font-size: small} .style8 {color: #0000FF} .style10 {font-size: x-small} .style11 {font-size: 12px; } .style12 { color: #FF0000; font-weight: bold; } .twoColElsLt #container #mainContent form table tr td p .style9 .style12 { color: #00F; } .style13 { font-weight: bold; font-size: x-small; } .style14 { font-size: small; color: #0000FF; font-weight: bold; } .dfgdfgg { color: #000; } .style15 { color: #0000FF; font-weight: bold; left: 10px; } .style16 { color: #00F } --> </style> <script language=javascript> function copyBill() { document.getElementById('shipname').value = document.getElementById('billname').value; document.getElementById('shipaddress').value = document.getElementById('billaddress').value; document.getElementById('shipaddress2').value = document.getElementById('billaddress2').value; document.getElementById('shipcity').value = document.getElementById('billcity').value; // document.getElementById('shipstate').value = document.getElementById('billstate').value; document.getElementById('shipstate').selectedIndex = document.getElementById('billstate').selectedIndex; document.getElementById('shipzip').value = document.getElementById('billzip').value; } </script> <!--[if IE]> <style type="text/css"> /* place css fixes for all versions of IE in this conditional comment */ .twoColElsLt #sidebar1 { padding-top: 30px; } .twoColElsLt #mainContent { zoom: 1; padding-top: 15px; } /* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */ </style> <![endif]--></head> <body class="twoColElsLt"> <p><img src="https://p2.secure.hostingprod.com/@ictindy.com/ssl/Pictures/header-info.jpg" width="910" height="115" /></p> <div id="container"> <div id="mainContent" style="width:910px; font-size:x-small; text-align: left; color: #333; font-weight: bold;"> <p align="left"> <input type="hidden" name="action2" value="submitted" /> <input type="hidden" name="compprice" value="<?= $price ?>" /> <input type="hidden" name="product2" value="<?= $_POST['product']; ?>" /> <? printHiddenVars(); ?> <input type="hidden" name="billname2" value="<?= $_POST['billname'] ?>" /> <input type="hidden" name="billaddress3" value="<?= $_POST['billaddress'] ?>" /> <input type="hidden" name="billaddress3" value="<?= $_POST['billaddress2'] ?>" /> <input type="hidden" name="billcity2" value="<?= $_POST['billcity'] ?>" /> <input type="hidden" name="billstate2" value="<?= $_POST['billstate'] ?>" /> <input type="hidden" name="billzip2" value="<?= $_POST['billzip'] ?>" /> <input type="hidden" name="shipname2" value="<?= $_POST['shipname'] ?>" /> <input type="hidden" name="shipaddress3" value="<?= $_POST['shipaddress'] ?>" /> <input type="hidden" name="shipaddress3" value="<?= $_POST['shipaddress2'] ?>" /> <input type="hidden" name="shipcity2" value="<?= $_POST['shipcity'] ?>" /> <input type="hidden" name="shipstate2" value="<?= $_POST['shipstate'] ?>" /> <input type="hidden" name="shipzip2" value="<?= $_POST['shipzip'] ?>" /> <input type="hidden" name="ccname2" value="<?= $_POST['ccname'] ?>" /> <input type="hidden" name="ccnumber2" value="<?= $_POST['ccnumber'] ?>" /> <input type="hidden" name="cctype2" value="<?= $_POST['cctype'] ?>" /> <input type="hidden" name="ccsec2" value="<?= $_POST['ccsec'] ?>" /> <input type="hidden" name="ccmonth2" value="<?= $_POST['ccmonth'] ?>" /> <input type="hidden" name="ccyear2" value="<?= $_POST['ccyear'] ?>" /> <input type="hidden" name="email2" value="<?= $_POST['email'] ?>" /> <input type="hidden" name="phone2" value="<?= $_POST['phone'] ?>" /> </p> <p align="left">Selected System: <?= $_POST['product']; ?> </p> <p align="left"> <? printOrder(); ?> </p> <hr /> <form method=post action=https://p2.secure.hostingprod.com/@ictindy.com/ssl/confirmorder.php> <table border=0 cellpadding=0 cellspacing=0 width=851> <tr> <td colspan=2> </td></tr> <tr><td width="434" valign=top> <p><b>Billing Information</b> <br /> <?= $_POST['billname']; ?> <br /> <?= $_POST['billaddress']; ?> <br /> <?= $_POST['billaddress2']; ?> <br /> <?= $_POST['billcity']; ?> , <?= $_POST['billstate']; ?> <?= $_POST['billzip']; ?> </p></td> <td width="377" valign=top> <p><b>Shipping Information</b> <br /> <?= $_POST['shipname']; ?> <br /> <?= $_POST['shipaddress']; ?> <br /> <?= $_POST['shipaddress2']; ?> <br /> <?= $_POST['shipcity']; ?> , <?= $_POST['shipstate']; ?> <?= $_POST['shipzip']; ?> </p> <p align="right"><a href="javascript:history.go(-1);" class="style10">Click here to make changes</a></p></td></tr> <tr><td colspan=2> <p align="left"><span class="style14"> </span></p> <hr /> <p align="left"><span class="style5">Payment information</span> </p> <p align="left" class="style4"><span class="style6">Name On Card:</span> <span class="style7"> <?= $_POST['ccname']; ?> <br /> <span class="style8">Card Type:</span></span> <span class="style7"> <?= $_POST['cctype']; ?> <br /> <span class="style8">CC Number:</span></span> <span class="style7"> <?= $_POST['ccnumber']; ?> <br /> <span class="style8">CC Code:</span></span> <span class="style7"> <?= $_POST['ccsec']; ?> <br /> <span class="style8">Exp. Date:</span></span> <span class="style7"> <?= $_POST['ccmonth']; ?>/<?= $_POST['ccyear']; ?> </span></p> <hr /> <p align="left" class="style11">Shipping: UPS Ground 5 Day Select </p> <p>Price as configured: <span class="style9"><span class="style12">$<?= $price ?> <?= (($_POST['billstate'] == "IN")?"":""); ?> </span> </span></p> </p> <p> <input type="image"src="https://p2.secure.hostingprod.com/@ictindy.com/ssl/checkout1.gif" /> <br /> </p></td></tr></table> </form></div></p></div> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-6282394-2"); pageTracker._trackPageview(); } catch(err) {}</script> </body> </html> <? } ?>
-
I think me means how does CURL go to a site and interact like click on links and post forms. Although from what i understand it doesn't you tell it the page to go to and you tell it if it should post a form.
-
if ($i = $cartProdQY) should be if ($i == $cartProdQY)
-
Copy image from URL to my server (5 million times)
DeanWhitehouse replied to brm5017's topic in PHP Coding Help
The database won't need to be broken up, just your queries might need changing. Google database optimisation and normalisation. -
[SOLVED] Win or Loose based on percentage
DeanWhitehouse replied to DeanWhitehouse's topic in PHP Coding Help
Yeah, i took a similar approach $random = rand(0,100); if($chance >= $random) echo "win"; else echo "loose"; -
Erm. ok. Another logic question. I have a percentage, and i need to work out if a player wins or looses based around this percent. The higher it is the more chance they have to win. What i thought is that: If they had 50% chance then i would generate a random number between 0 or 1, if 0 they loose if 1 they win? But then how would i get this to work with any number?
-
I ended up doing, it just came to me A lot simpler than i thought <?php $sql = mysql_query("SELECT * FROM rank ORDER BY end DESC"); while($rows = mysql_fetch_assoc($sql)) { $sql1 = "SELECT exp FROM user_stats WHERE exp >= '".$rows['start']."' AND exp <= '".$rows['end']."'"; $sql1 = mysql_query($sql1); ?> <tr> <td><?=$rows['rank']?></td> <td><?=round((mysql_num_rows($sql1)/$total_users)*100)?>% (<?=mysql_num_rows($sql1)?>)</td> </tr> <?php } ?>
-
Ok this is a logic problem. I need to find out how many users have a certain rank (which is got from the users exp), and to add to the confusion once i have done that i need to print on screen the percentage of users with that rank. The ranks are also dynamic. To explain better with diagrams Diagram 1: Rank 1 50%(400) Rank 2 25%(200) Rank 3 25%(200) Diagram 1 is what it should look like At the moment i was planning on looping through each user, and adding their rank to an array and then looping through the ranks and then i don't know :s Any ideas?
-
For my forum i order the topics by when they were posted. Now i need to order them by when the last reply was, and put sticky and important at the top. What would be the logic behind this?
-
Try using the logout code i gave you earlier just put that if statement in. Also try the debug thing i showed you to find out if the session is destroyed.
-
try removing $_SESSION = array();
-
Don't use it then Just do $row[row_name];
-
Did you try the above
-
Then it is working You must be resetting the session on another page, although change if(!$_SESSION['logged_in']) to if(isset($_SESSION['logged_in']))
-
ok, do <?php session_start(); session_unset(); session_destroy(); echo $_SESSION['user_id']; exit(); header( "Location: index.php" ); ?> Does it print anything?
-
try <?php session_start(); session_unset(); session_destroy(); header( "Location: index.php" ); ?>
-
Not sure where to post this, but it might come in handy for some people. If you use a custom 404 page, etc. Then here is an array containing the error message and error description. <?php if(isset($_GET['error'])) { $error = $_GET['error']; $error_ids = array( 400 => "Bad Request", 401 => "Authorization Required", 402 => "Unknown Error", 403 => "Forbidden", 404 => "Not Found", 405 => "Method Not Allowed", 406 => "Not Acceptable", 407 => "Proxy Authentication Required", 408 => "Request Timed Out", 409 => "Conflicting Request", 410 => "Gone", 411 => "Content Length Required", 412 => "Precondition Failed", 413 => "Request Entity Too Long", 414 => "Request URI Too Long", 415 => "Unsupported Media Type", 500 => "Internal Server Error", 501 => "Unknown Error", 502 => "Bad Gateway", 503 => "Service Unavailable", 504 => "Gateway Timeout", 505 => "HTTP Version Not Supported" ); $error_det = array( 400 => "a syntax error in the request.", 401 => "you not having permission to access this data.", 402 => "unknown reasons.", 403 => "you not having permission to access this data or the server being unable to server the requested data.", 404 => "this document either no longer existing, or never existing on the server, or being moved or renamed.", 405 => "the method you are using to access the document not being allowed.", 406 => "this browser does not accept this document format", 407 => "this browser not beening authenticated on the required proxy server required to access the data", 408 => "the server closing the socket due to communications between you and server taking too long.", 409 => "too many requests for the same file at one time, or there is a conflict with an established software rule or, a DNS issue.", 410 => "the file not being found, but the file may be being updated and therefore should return.", 411 => "trying to send a document to the server but the server did not recieve a Content-Length specification in the header.", 412 => "a precondition setting required by you or server has not been met.", 413 => "the process being too large to process.", 414 => "the URL requested being too long.", 415 => "the server not supporting the type of media you are requesting.", 500 => "the server encountered a problem, most likely caused by a script.", 501 => "unknown reasons.", 502 => "the document being requested resides on a 3rd party server and our server received an error from the 3rd party server.", 503 => "the server being overloaded or down for maintenance.", 504 => "connectivity issues.", 505 => "our server not supporting the HTTP version used by this browser." ); if(array_key_exists($type,$error_ids)) echo $error_ids[$error]." - ".$error_det[$error]; } ?>
-
o` Thanks had the manual open but was looking near the bottom of the list of functions :s
-
Is it possible to check an array for a certain key rather than just the value. E.g. $array = array("test",50 => "tester"); if(in_array_key(50,$array)) echo "In array key"; That will return true because the key is named 50. Any ideas?
-
Speed difference is hardly noticeable if at all.
-
oopz, tbh ignore me i am very tired
-
Sorry my bad, should be file();
-
try changing the header to header("Content-type: image/jpg"); and then echo read_file("logo.jpg");