Jump to content

phppup

Members
  • Posts

    632
  • Joined

  • Last visited

Everything posted by phppup

  1. Updated with same issue: echo "<td> <form method='POST' action=''>"; echo "<textarea name='comment' cols='30' rows='5'> " . $row['comments'] . " </textarea></td>"; echo "<td> <input type='submit' name='submit' value='Save text' />"; //echo "<td> <input type='submit' name=' " . $row['id'] . " ' value='Save text' />"; //tried but didn't work echo " <input type='hidden' name='IDs' value=' " . $row['id'] . " '> "; echo "</form></td>"; Either way, I get a success message at every button in every row when I want a message ONLY at the clicked button.
  2. i currently have the submit name corresponding to the $row["id"] so I'm not sure if venturing away from that course is going to resolve the issue. The problem seems to be more with using the write IF statement to segregate the selected button.
  3. I believe this is a PHP issue and NOT an HTML question based on the source of my frustrations. I am populating a table with data from a database. if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["comment"]. "<br>"; echo "<input type='submit' name='submit' />" ; each row has a submit button for comments pertaining to the specific ID so that comments can be edited with an UPDATE statement. I have a success message that displays at the top of the table after the db is updated with new comment text. I would like have the success message displayed next to the associated button that was clicked. So far, I have used this if(isset($submitted) { echo "SUBMITTED DATA"; } but it displays the SUCCESS message next to every button that exists for submitting updates. How can I restrict this so that the message is ONLY displayed at the effected button?
  4. @kicken I'm beginning to see your point. And thank you for your patience. One last thing, since you mention the temporary directory with random file naming: Assuming the same scenarios, are random names somehow discarded after use? Is there a possibility of a random name being repeated? If I used a naming convention of timestamp and sequence number and temp_name could a conflict STILL occur (albeit a slim chance) when multiple uploads occurred simultaneously? PS: I am realizing the benefit of using a db, but the addition will take some re-tooling. Thanks again for the help.
  5. @kickenMy example was only meant to indicate that the uploaded images for each person would be sequentially numbered as a full batch without interruption regardless of quantity. If Linda uploaded 4, her four files would remain together, if Ricky uploaded 132, all 132 would run the next sequence of numbers. So getting back to my original question, how will PHP handle an instance where two (or more) uploads occur at exactly the same time and create the same file name (which is possible even when using a timestamp or random number)? [I mean, I haven't actually tried it, but what will happen in a directory if you run a PHP script to rename each file TEST. Will an appended message be created by default (ie. Copy1, Copy 2)?] What are the pros and cons between storing the image as a file in the directory versus in the DB table? Thanks for all the info.
  6. @mac_gyver @kickenI guess I should elaborate somewhat, by clarifying that I want all the uploads in one single folder. For example, I go to a concert and stand at center of the audience. Linda is on the left aisle and Ricky on the right. We each take 20 photos that we all upload to a single folder. They will all be stored and renamed as "Concert" followed by the sequence number (ie. Concert_1, etc). My only real concern (at this point) is an attempt to avoid sequence conflict or shuffling of images. Ideally, I would want the total of 60 photos to be numbered so that the first 20, middle 20, and last 20 can be attributed to each individual person with a limited amount of mish-mash, interloping, or shuffling involved (even if we all begin the upload process at the exact same moment).
  7. @mac_gyverI suppose that size ought to be enough, to start. LoL Taken a step further, if persons Anne, Bill, and Charlie began their uploads ten minutes apart, then image numbers 1 thru 10 would be Anne's images, 11 - 20 would belong to Bill, and 21 - 30 would be from Charlie. If they begin simultaneously, what is the likelihood that the same result is achieved? How likely is it that the end result would be a shuffling resulting in Anne's first, Bill's first, Charlie's first, Anne's second, etc? Or worse? Will using a db eliminate a situation like this, or simply make it easier to unscramble the result?
  8. @gw1500se can you give me more info on how PHP handles this automatically? After upload, every file needs to be "moved". Are you saying that my concern is actually a non-issue because PHP will 'magically' eliminate the potential for conflict? Even without using a db safety net?
  9. @gw1500se can you give me more info on how PHP handles this automatically? After upload, every file needs to be "moved" to the destination directory, so I am trying to avoid doing double work. @mac_gyver. Thank you for pointing out the timestamp issue. I am trying to minimize database involvement. If I record a users name and other random info when they upload, it will involve a single row in a table. Are you suggesting that I repeat this info and add a row for every image that the user uploads? Won't that add a significant storage problem?
  10. I have created a script that will upload and reminder images. Currently, the script gives each image a common name (myPhotoSample) and a timestamp. Now, I want to replace the timestamp with a number so that each image is listed sequentially with more easily recognized values (1,2,3,etc). My concern is the effect this could have if several uploads were coincidentally started simultaneously. I doubt the script (or directory) would allow duplicate names to be rendered, so would I lose files because of overwriting? If 3 uploads of 10 images each were all started at exactly midnight what could go wrong? How can I best resolve the risk and ensure that I get 30 complete files sequentially numbered?
  11. @Barand: Glad to see your doing well. I won't have access to the code until weekend, but after struggling with it Sunday, I had an idea while driving in the car that might resolve my issue. Of course, any additional hints and tips will be welcomed. Stay safe.
  12. @Steve Oliver:. That is not EXACTLY the set-up, but the problem is the same. I am actually establishing the session variable on page 2, but I believe it is getting set to NULL when the page reloads. The question now, is how to escape the problem and create a solution.
  13. Perhaps my problem is with implimentation. Does establishing a form variable for SESSION require connecting it to $_POST? What needs to be done to pass the SESSION variable when the page is refreshed (in an instance like submitting an incorrect password)?
  14. $name = $_POST['name']; $_SESSION['name'] = $name; Apparently the value of $name is being lost or erased rather than stored in the session because I have created echo's to troubleshoot. After submission of the password, the $name value is gone.
  15. Yes, at top of ALL pages. I have success when I hardcode the name variable in my SELECT statement, but as a passed variable if is present to say "Hello John, please enter password." Then I enter password and I get a FAILURE. echo statement for troubleshooting have shown that "John" is no longer present and the password is available. Naturally, I am requiring BOTH criteria for validation. Trying an IF statement as a work-around seems tro be incorrect also. But I'm certain there's something simple that is missing.
  16. Mostly because I wanted to learn more about passing variables from page to page. Does each session variable need to be re-introduced on every page or are they contained in the session after the first introduction? Should a session variable be readily available everytime a page is refreshed (attempts at password entry) or are they removed after the first attempt?
  17. Trying to create a simple login page (and my code is embarassingly disgraceful at this point). In simple terms, I have start_session on three pages. The first page asks for name, the second for password, the third welcomes user. The second page contains $name=$POST['name']; $_SESSION['name']= $name; When I access the page 2, the name is echoed with a greeting and request for password. But after a password submission (whether correct or incorrect) the $name disappears. I am at a loss for why it is not being refreshed or maintained in the session. Any ideas for me?
  18. What will my result be if I try to reverse it enlarge ajpeg (which seems to be the most common format) ?
  19. As a point of curiosity, I am seeking some clarification. I have developed code to resize an image, thus reducing the file size by a percentage of it's original. My first question is, what exactly is being done to the file? I understand that some data is being removed (or condenced) but how does this effect the image when compared with the original on a webpage? Next, what should my expectation be if I wanted to reverse the process? If I am 'shrinking' an image for a faster upload speed and reduced storage capacity, how successful will I be if I wanted to 'restore' the file size before printing a physical photograph? Will this provide a 'better' end result?
  20. Any other opinions? PS: there are TWO questions that I inquired about.
  21. I am setting up a new form with more updated PHP code and seek some opinions: Is using FILTER_VALIDATE_EMAIL FILTER_SANITIZE_EMAIL just as good or better than the predisposed methods of the acceptable Regular Expression Pattern ie: '/^\ [A-Za-z0-9_]([\.-]?\w+)*@\ [A-Za-z0-9_]([\.-]?\ [A-Za-z0-9_])*(\.\w{2,3})+$/' On a slightly related topic, during testing I used PHP to create a SQL table and discovered that if the table already exists, an error message stating that the "table already exists" will be produced and the existing table will stay in tact. Does this eliminate the need to use code that would state if($exists !== FALSE) { echo("This table already exists"); } or is it suggested as a "best practice" as either a safeguard or coding approach?
  22. An order would ONLY be placed on webpage_2 (along with pricing). So, the distinction isn't the status of the order, but rather the classification of the visitor (ie: browser or customer). Does that change your thinking? If I get 100 visitors and only 20 become customers (on their first visit) do I want one single table of all visitors, or two distinctly different tables [BasicInfo with 80 rows, CustInfo with 20 and an association to their placed orders]?
  23. @Requinix.... Sorry, I'm just so used to posting in the coding section and the question arose while I was considering the code that needed to be written. I will be more careful in the future. As for my concern, I'm more interested in how to structure the USER data accumulated from visitors that enter partial information versus those that provide additional information (and an order). The idea being that if webpage_1 gathers basic information, then a visitor that declines providing more data on webpage_2 (after seeing cost/pricing) can be contacted with a survey to determine what discouraged him. Obviously, a visitor that DID provide additional information and became a customer would NOT be sent the same survey. So, from a coding perspective, do I insert all webpage_1 data into a table BasicInfo and then move it OR duplicate it into a table CustomerInfo if the customer completes webpage_2 ? Or do I simply lump everyone into a table of BasicInfo (for ALL visitors), perhaps with a column indicating whether they were only a visitor or an actual customer?
  24. I am considering a two step order form. The first webpage would require basic information such as name and email. The second webpage would include pricing and submission. The reason for the two step separation is so that the basic data can be inserted into a table. In the event that an order is not submitted, these people can be solicited separately (perhaps with discounted pricing or a survey). The real question pertains to the best architecture for such a database. My initial thought is that I need a table for data [BasicInfo] generated from webpage_1, and another table for people that actually place orders [CustomerTable] with an associated table for the actual order and pricing [OrderTable]. Does every completion of webpage_1 go into the BasicInfo table, with a repeat of basic info and order info being directed to CustomerTable and OrderTable, respectively?(This seems unnecessarily redundant where BasicInfo is really a list of both costumers and visitors) So what is the best way to trim the fat? Put everyone in BasicInfo and then move the row if they place an order? Put everyone in BasicInfo with a column named 'order' that is updated for future referencing? Some other method that I haven't thought of yet? Advice please.
×
×
  • 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.