Jump to content

a_bains

Members
  • Posts

    12
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

a_bains's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. my second CURL POST is already there, echo curl_exec($ch); // process security question
  2. I am trying to login to the website in the below example. This script logs in using a username and password but then is directed to a page with a security question. This is where the problem is, I am unable to POST my answer on this page. The result of my output is just the page with the security question. $username = 'XXXX'; $password = 'XXXX'; $loginUrl = 'https://www.dandh.ca/v4/dh'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $loginUrl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'Login='.urlencode($username).'&PW='.urlencode($password).'&Request=Login&formName=Login&jsEnabled=0&queryString=&Platform=Full&btLogin='.urlencode('Log In')); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookies.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookies.txt"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_exec($ch); // process main login curl_setopt($ch, CURLOPT_POSTFIELDS, 'securityAnswer=XXXX&Request=postForm&formName=loginChallengeValidation&btContinue=Continue'); echo curl_exec($ch); // process security question curl_close($ch); Here is the source code of the security question HTML form: <form name="securityForm" id="secForm" method="post" action="/v4/dh"> <input type="hidden" name="Request" value="postForm"><input type="hidden" name="formName" value="loginChallengeValidation"> <table border="0" align="center" cellpadding="10" cellspacing="0"> <tr> <td><span style="font-weight:bold;">Security Response</span> <br> <p> Please answer the following security question. Once the answer is confirmed you can continue. </p> <p style="margin-left: 20px;"> Question: What is the name of your best friend from childhood?</p> <p style="margin-left: 20px;"> Answer: <input type="text" id="securityAnswer" name="securityAnswer" size="50" maxlength="50"> </p> <p style="margin-left: 20px;"> <input type="submit" name="btContinue" value="Continue"> </p> <p> <i>If you do not know the answer to the security question, please email <a href="mailto:passwords@dandh.com">passwords@dandh.com</a> and they will send you a temporary password. <a href="/v4/dh?Request=postForm&formName=LogOut">Click here</a> to return to login page.</i> </p> </td> </tr> </table> </form>
  3. Hello, I have 3 tables consisting of products from suppliers, I am trying to merge all my supplier tables into one table. In the merged products table every product should be unique (all having different mfgpartno). Some suppliers carry the same product having the same mfgpartno as another supplier. The merged products table needs to only have the product containing the lowest price of all the 3 tables. In example, I need the entire row of the product with the lowest price between all 3 tables in the merged table. Here is an example based on the table below, the product with mfgpartno HA-MODEMCOM from table #3 would end up in the merged products table because it has the lowest price of all. Table #1 +----------------------+--------------+--------------+-------------------------------+-------+------+-------+ | mfgpartno | manufacturer | vendorpartno | description | price | msrp | stock | +----------------------+--------------+--------------+-------------------------------+-------+------+-------+ | HA-MODEMCOM | Asrock | HA-MOD | ASROCK AMR MODEM/COM PORT | 6.3 | 0 | 0 | | DUAL LOW PROFILE BRA | Asus | DUAL-L | LOW PROFILE BRACKET SUPPORT | 9.6 | 0 | A | | AS/IO-PLATE | Asus | IO-PLA | ASUS UNIVERSAL IO PLATE | 12.6 | 0 | A | | 13-010041000 | Touch | K8N-DR | ASUS CPU RETENTION MODULE FOR | 16.1 | 0 | 0 | | 319110 | Touch | SILVER | ARCTIC SILVER 5 HEAT COMPOUND | 28.6 | 0 | A | +----------------------+--------------+--------------+-------------------------------+-------+------+-------+ Table #2 +----------------------+--------------+--------------+-------------------------------+-------+------+-------+ | mfgpartno | manufacturer | vendorpartno | description | price | msrp | stock | +----------------------+--------------+--------------+-------------------------------+-------+------+-------+ | HA-MODEMCOM | Asrock | HA-MOD | ASROCK AMR MODEM/COM PORT | 9.6 | 0 | 0 | | DUAL LOW PROFILE BRA | Asus | DUAL-L | LOW PROFILE BRACKET SUPPORT | 43.6 | 0 | A | | AS/IO-PLATE | Asus | IO-PLA | ASUS UNIVERSAL IO PLATE | 51.6 | 0 | A | | 13-010041000 | Touch | K8N-DR | ASUS CPU RETENTION MODULE FOR | 26.1 | 0 | 0 | | 319110 | Touch | SILVER | ARCTIC SILVER 5 HEAT COMPOUND | 18.6 | 0 | A | +----------------------+--------------+--------------+-------------------------------+-------+------+-------+ Table #3 +----------------------+--------------+--------------+-------------------------------+-------+------+-------+ | mfgpartno | manufacturer | vendorpartno | description | price | msrp | stock | +----------------------+--------------+--------------+-------------------------------+-------+------+-------+ | HA-MODEMCOM | Asrock | HA-MOD | ASROCK AMR MODEM/COM PORT | 4.2 | 0 | 0 | | DUAL LOW PROFILE BRA | Asus | DUAL-L | LOW PROFILE BRACKET SUPPORT | 63.6 | 0 | A | | AS/IO-PLATE | Asus | IO-PLA | ASUS UNIVERSAL IO PLATE | 41.6 | 0 | A | | 13-010041000 | Touch | K8N-DR | ASUS CPU RETENTION MODULE FOR | 26.1 | 0 | 0 | | 319110 | Touch | SILVER | ARCTIC SILVER 5 HEAT COMPOUND | 38.6 | 0 | A | +----------------------+--------------+--------------+-------------------------------+-------+------+-------+
  4. Hello, I am new to Curl but I just have a simple question. The below script logs into a website and then downloads a PDF from the downloads folder. I have no problem building a login script and checking authentication on each php page but the downloads folder is different and could contain PDF files. I am wondering why I couldn't just download a PDF straight away without logging in. I want to know how I would go about protecting files like that. I have heard about .htaccess but I am unsure if that is what I should use. For my business I would like to give only my customers access to a file on my server requiring the same authentication as the login.php page (which would verify against a mysql database). I intend for them to use a script like below, but I am unsure of how to protect the downloads folder. Thanks! <?php // INIT CURL $ch = curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'http://www.external-site.com/Members/Login.php'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'fieldname1=fieldvalue1&fieldname2=fieldvalue2'); // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); # Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL # not to print out the results of its query. # Instead, it will return the results as a string return value # from curl_exec() instead of the usual true/false. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); // EXECUTE 1st REQUEST (FORM LOGIN) $store = curl_exec ($ch); // SET FILE TO DOWNLOAD curl_setopt($ch, CURLOPT_URL, 'http://www.external-site.com/Members/Downloads/AnnualReport.pdf'); // EXECUTE 2nd REQUEST (FILE DOWNLOAD) $content = curl_exec ($ch); // CLOSE CURL curl_close ($ch); ?>
  5. Yep, your right I just figured that out from searching a previous post. Thx alot!
  6. I get this error with the code below: Could not update PC serials: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'case='case', psu='psu', cpu='cpu', mobo='mobo', ram='ram', hdd='hdd', video='vid' at line 1 <?php $title="Update PC"; include("header.php"); echo "<div id='nav'><a href='details.php'>Details</a> | <a href='workorder.php'>Add Work Order</a> | <a href='addpc.php'>Add PC</a> | <a href='index.php'>Search</a></div>"; require("connect.php"); if ($submit == "yes") { $sql_serial = "UPDATE computers SET case='case', psu='psu', cpu='cpu', mobo='mobo', ram='ram', hdd='hdd', video='video', drives='drives', pci='pci', other='other' WHERE computer_id=$computerid"; mysql_query($sql_serial) or die('Could not update PC serials: ' . mysql_error());
  7. not too sure what you mean, is this what you mean? $serialcase = $_POST['serialcase'] "INSERT INTO computers (case, psu, cpu, mobo, ram, hdd, video, drives, pci, other) VALUES('$serialcase','$serialmobo',................ thx for all the help
  8. With each of your suggestions i am getting this error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ']' in C:\xampp\htdocs\wdt\cci\addpc.php on line 13
  9. still same error, Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\xampp\htdocs\wdt\cci\addpc.php on line 13 thx tho..
  10. I keep getting this error: Could not add customer: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''computers'('case', 'psu', 'cpu', 'mobo', 'ram', 'hdd', 'video', 'drives', 'pci'' at line 1 I have tried many different variations, like '$_POST[mobo]', ..... no success in any way The code is below, <?php $title="Add PC"; include("header.php"); echo "<div id='nav'><a href='details.php'>Details</a> | <a href='workorder.php'>Add Work Order</a> | <a href='addpc.php'>Add PC</a> | <a href='index.php'>Search</a></div>"; if ($submit == "yes") { require("connect.php"); $sql = "INSERT INTO 'computers'('case', 'psu', 'cpu', 'mobo', 'ram', 'hdd', 'video', 'drives', 'pci', 'other') VALUES('" . $_POST['serial-case'] . "', '" . $_POST['serial-psu'] . "', '" . $_POST['serial-cpu'] . "', '" . $_POST['serial-mobo'] . "', '" . $_POST['serial-ram'] . "', '" . $_POST['serial-hdd'] . "', '" . $_POST['serial-video'] . "', '" . $_POST['serial-drives'] . "', '" . $_POST['serial-pci'] . "', '" . $_POST['serial-other'] . "')"; mysql_query($sql) or die('Could not add customer: ' . mysql_error()); mysql_close($con); } ?> <form name="create" method="post" action="<?=$PHP_SELF?>"> <table class="form"> <tr style="text-align:center"> <td></td> <td>Serial</td> <td>Description</td> </tr> <tr> <td><label for="case">Case</label></td> <td><input name="serial-case"></td> <td><input name="info-case"></td> </tr> <tr> <td><label for="psu">Power Supply</label></td> <td><input name="serial-psu"></td> <td><input name="info-psu"></td> </tr> <tr> <td><label for="cpu">Processor</label></td> <td><input name="serial-cpu"></td> <td><input name="info-cpu"></td> </tr> <tr> <td><label for="mobo">Motherboard</label></td> <td><input name="serial-mobo"></td> <td><input name="info-mobo"></td> </tr> <tr> <td><label for="hdd">Hard Drive</label></td> <td><input name="serial-hdd"></td> <td><input name="info-hdd"></td> </tr> <tr> <td><label for="video">Video Card</label></td> <td><input name="serial-video"></td> <td><input name="info-video"></td> </tr> <tr> <td><label for="ram">Memory</label></td> <td><input name="serial-ram"></td> <td><input name="info-ram"></td> </tr> <tr> <td><label for="drives">Drives</label></td> <td><input name="serial-drives"></td> <td><input name="info-drives"></td> </tr> <tr> <td><label for="pci">PCI</label></td> <td><input name="serial-pci"></td> <td><input name="info-pci"></td> </tr> <tr> <td><label for="other">Other</label></td> <td><input name="serial-other"></td> <td><input name="info-other"></td> </tr> <tr> <input type="hidden" name="submit" value="yes" /> <td colspan="2" align="center"><br><input type="submit" value="Add PC"></td> </tr> </table> </form> <?php include("footer.php"); ?>
  11. Correct, therefore what would be the best way to store something like that? I am looking to have a list of feature/specs for my products and would like to store them in a mySQL database. I was thinking of having ONE table with all products with fields like (ID, NAME, PRICE, ... ), should SPECS be another field? If so, how would I print it out in a list format?
  12. Hello, I would like to create a details.php page that displays all my products. I understand how to get the title, price, description etc from mySQL. But my problem is how do I get a list of data? For example say I want to display the features of a product in point form (list). What is the best way to do this? How do most common websites do this? OK, sorry if I am unclear. Here is an example http://www.simplyfta.com/indvitem.php?item_id=10 That site uses PHP and mySQL, it has sections for SPECS and FEATURES. Description is easy you would just use the fetch array function and print it out. But if I want display my data as a list, how would i do that. I am supposing that SPECS and FEATURES are data in an mySQL table row. How do they input that data into mySQL table row to display it on a page using PHP in a list format. I really just want to know the method they used to display a point form list, may also look like its in a table format from a mysql database. Thanks, in advance Aaron
×
×
  • 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.