Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. no difference, therefore I don't think you HAD to change that code. I don't know what you are defending in your code. The fact that you do two fetches in a row to different vars is puzzling. No reason, especially since you only have one record to be fetched.
  2. Makes no sense. Talk about 'less code the better'. That code is meaning-less unless you are actually expecting input from a GET at some point in this limited script's lifetime.
  3. You should NOT have removed the value attribute. You need it! You need to develop good habits and that is one of them. What will you code up when you create a form that is supposed to give the user two actions that can be done? Both (un-valued) submit buttons will have the same default label, but your intent is to have them do different things. Without meaningful labels they are indistinguishable and your php script will not know what to do. As for using request_method that too is worthless since you won't know which button was clicked with that code. My code is very correct. It will only respond to a POST method since there won't be any POST values if the method was not a post. Why check request_method if I'm looking for post vars - THAT would be a waste of code.
  4. Your submit field had no value clause, so what does the submit have for a value when it comes in? And when checking for the submit you should be checking to be sure that it is the button you expected, regardless of whether there is only one, imho. This is standard practice to ensure you are handling the form correctly (in all situations) and to ensure that what you are getting is what you expect.
  5. not bad if it's your first effort. Judging from what we can see here: 1 - you should use quotes around array indices such as $cinf[quantity]. 2 - you do the bindvalue of quantity as a string - why not an int? 3 - you grab the first row of your query result then you grab a second row but you limited the results to only 1. Wassup with that? You should be checking the results of your query executions before doing anything with the results to ensure they ran. You should also have php error checking turned on, but it may just not be shown here.
  6. Many confusing things in your code, so I cleaned It up so I could read it, but I still don't understand what your goal is. Pleae note the changes I made. <?php error_reporting(E_ALL | E_STRICT | E_NOTICE); ini_set('display_errors', '1'); $error_msg = ''; if (isset($_POST['submit'] && $_POST['submit'] == 'Submit')) { if (isset($_POST['fax'])) { $option = $_POST['fax']; if ($option <> 'interfax' && $option <> 'metrofax') { $error_msg = "invalid fax choice"; } } else { $error_msg = "Fax choice not made"; } // switch ($option) { case 'interfax': $file = "fax.php"; //$fax_client = "interfax"; // already have a value for the above $faxmsg = "?????"; if(file_put_contents($file,$faxmsg)) echo "$option Successful"; else die("$option Can't write file"); break; // By defualt all the orders go to metrofax so by selecting the variable it resets it self case 'metrofax': $file = "fax.php"; // $fax_client = "metrofax"; // $faxmsg = "<?php ".'$fax_client = "' . NULL . '"'."endphp"); // You are already in php mode, so no idea what this is supposed to do. file_put_contents($file,$faxmsg); if(file_put_contents($file,$faxmsg)) echo "$option Successful"; else die("$option Can't write file"); break; } } echo $error_msg; ?> <!-- --> <!-- --> <!-- more html preceding this I hope --> <!-- --> <!-- --> <form method="POST"> <input type="radio" name="fax" value="interfax">Switch To Interfax<br> <input type="radio" name="fax" value="metrofax">Switch To Metrofax<br> <input type='submit' name="submit" value='Submit'> <!-- --> <!-- --> <!-- You need an end form tag --> <!-- --> <!-- --> <!-- --> </form> (more html???) 1 - check for a submit button , not a request method2 - add a value to the submit button 3 - radio buttons must all be grouped under the same name otherwise you will have two values. 4 - you need an end of form as well as much more html 5 - ALWAYS DEVELOP WITH PHP ERROR CHECKING ON ! So - what are you trying to write to that fax.php file? Actual php tags?
  7. Actually for your example, you don't need to include the ip. The link will work with just this: <link rel="stylesheet" href="/main.css" type="text/css">
  8. Not by any means an OOP guy, but I have the basic understanding to say this. When designing a class you look for the common denominators of the thing(s) that you are creating it for. If everything you know about your objects can produce a set of properties and methods that are the same for all, then those are things in your "starting" class. When you start to say to yourself - ok, I need to handle b,c,d differently that's when you start to identify a subset of properties and methods for those things and create a sub class that a) inherits the base functionality from the first class and b) adds some new functionality for the new oddballs. You don't begin to modify the methods of the main parent class to accommodate, but rather build a new object that is more flexible. That is polymorphism wherein you morph your object by adding new features to the child class which "extends" the overall functionality of the first class. (Extends - as in "Class mynewclass Extends OldClass"). The key is to recognize ALL the properties and actions that the set of things has in common so that you don't duplicate method/props in a second class. I'm sure you will get many responses to this post now, with many telling me I'm way off base ( I don't think so) and others giving you a more detailed, technical oriented description, but IMHO I think I have given you some food for thought on how to proceed.
  9. ginerjm

    safety

    And PLEASE use the proper code tags on this forum. Read the rules!
  10. ginerjm

    safety

    Just by looking at the size of this query, your table design may need some re-thinking as well. I see several repeated fields - formul#, wwspel#,overigew#..... If you are trying to store multiple groups of the same data in one record, you mis-understand the whole concept of relational databases. One should never have multiple copies of the same "data" in a single record. Rather than putting 4 values of formul# in one 'main' record, the 'main' record should link to a second table that will contain 4 records that will be part of the 'main' record. By having a 'main' record id of some sort, you can then put that id into the second table and use it to 'join' the two tables in a query and end up with all the data you need for that 'record id'.
  11. $con is not in scope inside your function. Either make it global or pass it in as a function parameter And - I think you want to remove the single quotes from the value $date. And - you probably need backticks on the field name date since date is probably a reserved word
  12. I'm guessing that either movie_id is not the field name or it is not defined as numeric value.
  13. null given suggests that the query call failed. Add this: $r = mysqli_query($q, $dbc); if (!$r) { echo "Query did not run - error msg is: ".mysqli_error(); exit(); } while ($row = mysqli_fetch_assoc($r)) { ... One should always CHECK the results of things to be sure they ran. Also you should not have a semi after the while statement.
  14. Try "$row['movie_id'] instead of $r['movie_id']
  15. In your lines after the prepare call you build an array with a set of php vars. Where are they provided with values? And what I meant about providing a value - you are grabbing $values items from your foreach loop but how do those input values get validated and then placed into the simple vars you are using in the array of inputs for the query? Your foreach only creates a $values element for the inputs that are found in the POST array. That means that $values will not have anything to validate nor to populate the corresponding var in the array of inputs. Getting deeper and deeper.....
  16. My last post on this matter. You are spending a lot of time trying to create something and having trouble because it is all so new to you. There is nothing like the feeling of getting that first script working to your satisfaction. This new method you are trying would be a wonderful thing to accomplish I'm sure, but you are showing a lot of confusion in trying to build it at this time. One of the most important and most tedious parts of developing is pulling the data together and ensuring that it is what you expect, what will work, and isn't going to harm you. Repetitive code chunks all doing similar things to like fields are a fact of life UNTIL you get to the point that you understand all those nuances of 'editing' and can at that time build yourself a working machine to help you accomplish this now and for the future. My point is - why not take the time to write the code needed to complete this script, learning all the things that need to be done for each field and learn from it? Then take that knowledge and use it again on your next script and gain more knowledge and when you get to the point that you feel comfortable building a sensible, efficient and safe tool, do it. Beginning coders always look back at their work from their early projects and wonder WTH they were doing. Don't belabor this project with attempts at code that you may regret investing so much time in.
  17. Ok - so now you are pulling in the input from post and stroring it in values for later use. But at this same time you need to be doing the validations and grabbing the correct error messages and storing them somewhere to be used in your html. And as others said, you need to be doing the specific type of validation that each field requires. I also noticed in your original post (of this new method) that you are just using simple vars in the array of values which I don't see being defined anywhere. Forgot something else? And remember - you have to have a value for every ? you placed in your prepared query statement and currently your logic doesn't handle that, unless you add code to ensure that every field is input.
  18. What is the $values array? Perhaps you meant to use $_POST as your array name, not $values?
  19. Are you that worried about electricity outages where you are? Data saved in the session or in the db will be saved since both are at the server, not at your clients. And yes - if the data is saved in either you can re-build the input for the users from either the session or the db. From what you are saying this form is so long it takes the users too much time to complete and you must be worried that the clients will 'time out' and lose everything they are working on . To me that indicates that I need to build my pages differently.
  20. 1 - you need to use something other than the MySQL_* functions since they are deprecated. 2 - you need to either use the newer database functions that support prepared queries or sanitize your input filename before using in your query. 3 - why do you use $filename when you already have a perfectly good variable in $cdocdocb? 4 - if you put out a header that says the upcoming output is a pdf, why would you expect html to be recognized? 5 - if you are seeing the html but no pdf, then I suspect that the filename is either invalid or unreachable. View the source of your page as it is being displayed and show us the line where the img tag is. You do realize that you CANNOT reference a file that is outside of your web tree in html?
  21. Why not simply make the form shorter and let them take a break between multiple input pages? Then you can simply use one script to collect all the data (in batches) and store it in a table or session array and post it when the process is complete.
  22. And the function is buried inside a block of code of an if statement. Never done that myself - suggest you move the function for the sake of clarity at the least.
  23. You haven't defined the function yet when you make the call.
  24. What do you think that message is telling you????
×
×
  • 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.