Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Weird trigger_error is an internal php function, php -l does not flag up any such error here for me. . Strange it flagged the error on line 39. But you used that function on lines 8 and 20 previously I'm guessing there is some weird whitespace character used in the indentation which is causing the function name to not be recognized. Does the error persist if you remove the indentation before calling the function and/or retyping the function name?
  2. Yes. Look using empty as the condition for the if. Although a better alternative would be to modify your query so it does not return values which are empty.
  3. So you want us to do your homework assignment for you? Sorry we don't do that here. If you are getting any errors then post them here along with your code and we will be happy to help.
  4. Passing $_POST to htmlspecialchars will never work. That is because htmlspecialchars is expecting a string value, not an array - $_POST is a superglobal array containing the values submitted by your form. If you want to apply htmlspecialchars to all the values in $_POST then use array_map. Alternatively apply htmlspecialchars to $val inside the foreach loop.
  5. Your form only submits the the basket name in the form of a checkbox value <td> <input type="checkbox" name="basket[]" value="<?echo $m["basket_name"] ;?>" /> The foreach loop will be looping through the values from the submitted checkboxes. The $basket1 variable will only contain the value from the checkbox (which is the basket_name). You are seeing 0 in the basket_price field because its data type is an integer and its is being truncated to 0 because you are trying insert a string value into it (the baskek name). You need another input field to submit the basket price and insert that value into the basket_price field in your operationlog table. But you should not be inserting the basket name/price into another table you should ideally be referencing those values using the primary key of the basket table as the foreign key in the operationlog table. Later on when you go to display the data from the operationlog table you would use a join to get the basket name/price values. Also you should not be using raw $_POST data in your queries. You should be validating and sanitizing the input before using it in your queries. And note the mysql_ functions are deprecated (no longer supported) you should update your code to use PDO or MySQLi database api's
  6. Weird I cant seem to be able to send you a PM to inform you I have merged your topics seeing as they are similar. Also please do not bump old topics to "advertise" your new topics either.
  7. Sorry I meant to use $innerpage->find('.article-image') not $lt->find('.article-image') However I think step 2 actually means to get the thumbnail image shown with the headline link and not the actual image from the article of the headline? In which case the foreach loop needs to be // get headline link in <div class="imgBox"> foreach($html->find('.imgBox') as $lt) { // get the article url from the anchor tag href attribute $headline_link = $lt->find('a', 0)->href; // get the image url from the image tag src attribute $headline_image = $lt->find('img', 0)->src; $allimg[]['image'] = $headline_image; } Maybe you need to clarify what step 2 means.
  8. The output you see is what you get by passing $result to var_dump(), this will print the structure of the array and show the data types of the values stored in the array. You do not need to use explode to get the value from the array. You loop over the values in the the array using foreach and echo the value of the current item $result = $adldap->group()->all($includeDescription = false, $search = "*", $sorted = false); // this returns an array of results var_dump($result); // this will print the structure of the array // this loops over the items in the array and prints each value foreach ($result as $value) { echo $value . '<br />'; } Explode is used for splitting a string into an array.
  9. For step 2 all you need to do is pass $site_url . $url_inner to file_get_html() $html_innerpage = file_get_html($url_inner to file_get_html); // get the article html For step 3 you use $tl->find() to find the article image ( .article-image ). For step 4 echo the image.
  10. How is isInstalled() function being called? It should never need to be called from the installer. A work around would be to not redirect if the current page is setup.php function isInstalled() { if(!strstr($_SERVER['SCRIPT_NAME'], 'setup.php') && !file_exists($_SERVER['DOCUMENT_ROOT'].'/config/config.php')) { header('Location: http://'.$_SERVER['HTTP_HOST'].'/setup.php?step=0'); exit; } }
  11. I would say you would want to setup three tables in your database. users table - stores user info such as user id, username, password etc... items table - store the items in the checklist such as the item id, title, description etc... item_completed table - in this table you only record the user id along with the id of the completed item. You would use a join to know if the user has completed an item in the check list If you are new to joins I recommend you have a look at here first http://www.sitepoint.com/understanding-sql-joins-mysql-database/. You will want to use a Left Join (query the items table and left join the items_completed table where the logged in user id and item id matches).
  12. Not quite understanding you. I guess you want to replace the Delete ' . $result["BidIDFile"]; after the checkbox with your link? You can replace the checkbox line with this echo '<input type="checkbox" name="delete[]" value="BidIDFile"> <a href="http://uploads/'.$result["BidFile"].'" target="_blank" onclick="window.open (this.href, \'child\', \'height=800,width=850,scrollbars\'); return false" type="application/octet-stream">'.$result["Addend4"].'</a>';
  13. If you dont want to use session then do not advance the user pass the first step if the database credentials are not correct. If the credentials are correct save them to your config file (as was discussed in your previous thread). On the install steps that require a database you would include your config file. If you dont want the config file to be created until the install process has finished then use sessions for storing the credentials
  14. Ok looking at your code I assume only the file paths are stored in the following fields? BidIDFile <--- stores the filepath for BidFile TabSheet <--- " " " " TabSheet SignInSheet <--- " " " " SignIn Sheet Addend1 <--- " " " " Addendum 1 Addend2 <--- " " " " " 2 Addend3 <--- " " " " " 3 Addend4 <--- " " " " " 4 Addend5 <--- " " " " " 5 I couldn't find what fields stores the filepath for the form fields labelled Addendum 6 and Executed Contract in your form? I wont post the code for all 10 fields in your form. I will show an example for the Bid File field. <td class="td_input_form"><input type="file" name="BidIDFile[]" size="50"></td> Change the Bid File upload field (shown above) to to this <td class="td_input_form"> <?php // if the BidIDFile is empty, if(empty($result["BidIDFile"])) { //then show file upload field for Bid File echo '<input type="file" name="BidIDFile[]" size="50">'; } else { // Bid file already upload, show checkbox to delete it. echo '<input type="checkbox" name="delete[]" value="BidIDFile"> Delete ' . $result["BidIDFile"]; } ?> </td> This will show the file upload field if a Bid File has not been uploaded (the BidIDFile column is empty in the table row). If there is a value then it will show a checkbox for deleting the file. You will apply this code logic for the remaining upload fields. Changing BidIDFile to the corresponding column in your table for each field. To delete the file you need to loop over $_POST['delete'] array when the form has been deleted. This array contains the table columns for each uploaded files. You would perform a select query to get the file paths from these columns in your table. From the result of the query you would pass each file path to unlink to delete the file. Then to remove the file paths from the table you would run an update query setting the columns to an empty value. Example code // Connect to SQL Server database include("connections/Connect.php"); $strsID = isset($_GET["Id"]) ? $_GET["Id"] : null; if(isset($_POST['delete'])) { // whilelisted table columns $fileColumnsInTable = array( 'BidIDFile', 'TabSheet', 'SignInSheet', 'XConnect', 'Addend1', 'Addend2','Addend3','Addend4','Addend5', 'Addend6'); $fileColumns = array(); foreach ($_POST['delete'] as $fileColumn) { if(in_array($fileColumn, $fileColumnsInTable)) $fileColumns[] = $fileColumn; } // get the file paths for each file to be deleted $stmts = "SELECT " . implode(', ', $fileColumns) . " FROM bids WHERE ID = ? "; $querys = sqlsrv_query( $conn, $stmts, array($strsID)); $files = sqlsrv_fetch_array($querys,SQLSRV_FETCH_ROW); // loop over the files returned by the query foreach ($files as $file ) { //delete file unlink($file); } // now remove the values from the table $stmts = "UPDATE bids SET " . impload(' = '', ', $fields) . " WHERE ID = ? "; $querys = sqlsrv_query( $conn, $stmts, array($strsID)); }
  15. EDIT. In jcbones code change lines 8, 9 and 10 to $file_name = $_FILES['uploaded_file']['tmp_name']; //name of the saved file. $new_file = $_FILES['uploaded_file']['name']; // or set this variable to 'gps.txt' You should not need to modify the code provided by jcbones. The code should append the contents of the uploaded file to gps.txt. If the code is not working, then either the file is not being uploaded or it is unable to write to gps.txt. Check your servers error log to see if there are any errors.
  16. You have spelled from incorrectly on this line mail ( $email, $subject, $message, "From:".$form);
  17. The best place would be php.net/mysqli. That is the documentation for mysqli. Each function has an explanation of what arguments it requires, what it does, what it returns and a code example for how it is used. From there you should be able to convert your the mysql_* functions to the mysqli_* equivalent functions. Alternatively you may find http://codular.com/php-mysqli helpful.
  18. You're getting those notices because $_FILES wont be populated with any data until the form has been submitted. To prevent the notices you need wrap your form processing code inside a condition example if(isset($_FILES['csv'])) { // process form data // insert data from csv file into the database } You can automate the insertion of contents of the CSV file by using the MySQL LOAD DATA INFILE query clause. Example code if (isset($_FILES['csv'])) { // import the contents of the csv file into the database $result = mysql_query(" LOAD DATA INFILE {$_FILES['csv']['tmp_name']} # the tmp csv file INTO requisition # the table to insert the data to FIELDS TERMINATED BY ',' ENCLOSED BY '\'' # describe how the fields are separated and what character the values are enclosed by IGNORE 1 LINES # ignore the first line - which is usually used for the column headings "); // check the query did not fail if(!$result) { trigger_error('DB Error: Cannot import csv contents to database - ' . mysql_error()); } // check that query did add the data to the table if(mysql_affected_rows()) { header('Location: import.php?success=1'); exit; } // for some reason no data was added to the table else { echo 'Data was not added to the table!'; } }
  19. Are you sure you have uploaded all files correctly? Are there any JavaScript errors reported in your browsers console (F12 > console tab)?
  20. You could set session variable, $_SESSION['can_access'] to true in index.php $_SESSION['can_access'] = true; Then in secound.php check if this session variable exists at the top of the page <?php session_start(); // kill the page if the access variable doesn't exists // or if the access variable does exist but is not set to true if(!isset($_SESSION['can_access']) || (isset($_SESSION['can_access']) && $_SESSION['can_access'] !== true)) { die('You cannot directly access this page!'); // kill the page display error } // rest of page code
  21. If you're directly linking to secound.php in a hyperlink, like <a href="http://yoursite.com/secound.php">Link</a> then you cannot prevent direct access to that file, as you are linking directly to it. Are you only wanting to prevent access to secound.php if the user has not been to index.php first?
×
×
  • 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.