Jump to content

benanamen

Members
  • Posts

    2,134
  • Joined

  • Last visited

  • Days Won

    42

Everything posted by benanamen

  1. The following is my further attempt to learn OOP. Is there anything technically wrong with it or is there any better practices in the code or its use? Purpose is to display dev/debugging data. Your feedback is appreciated. * Code in forum is on one page so you can easily run it if desired. <?php /** * Displays data from $_COOKIE, $_SESSION, $_GET, $_POST, $_REQUEST * @param string $debug COOKIE, SESSION, GET, POST, REQUEST */ class DebugDisplay { private $title; private $debug; public function __construct($title, $debug) { $this->title = $title; $this->debug = $debug; } public function ShowDebug() { echo '<pre><span style="color:red;font-weight:bold">'; echo $this->title . '<br>'; print_r($this->debug); echo '</span></pre>'; } } //---------------------------------------------------------------------------------------- // Test Data //---------------------------------------------------------------------------------------- $_COOKIE[] = 'COOKIE Data'; $_SESSION[] = 'SESSION Data'; $_REQUEST[] = 'REQUEST Data'; $_GET[] = 'GET Data'; $_POST[] = 'POST Data'; //---------------------------------------------------------------------------------------- // Debugging //---------------------------------------------------------------------------------------- define("DEBUG", true); // Toggle Debugging define("SHOW_DEBUG_PARAMS", DEBUG); // Display Sql & Sql Parameters define("SHOW_SESSION_DATA", DEBUG); // Display Session Data define("SHOW_POST_DATA", DEBUG); // Display Post Data define("SHOW_GET_DATA", DEBUG); // Display Get Data define("SHOW_COOKIE_DATA", DEBUG); // Display Cookie Data define("SHOW_REQUEST_DATA", DEBUG); // Display Request Data if (DEBUG === true) { echo '<div class="error_custom"><H1>DEBUGGING IS ON !!!</H1></div>'; } if (SHOW_COOKIE_DATA === true) { $show = new DebugDisplay('COOKIE', $_COOKIE); echo $show->ShowDebug(); } if (SHOW_SESSION_DATA === true) { if (isset($_SESSION)) { $show = new DebugDisplay('SESSION', $_SESSION); echo $show->ShowDebug(); } } if (SHOW_POST_DATA === true) { $show = new DebugDisplay('POST', $_POST); echo $show->ShowDebug(); } if (SHOW_GET_DATA === true) { $show = new DebugDisplay('GET', $_GET); echo $show->ShowDebug(); } if (SHOW_REQUEST_DATA === true) { $show = new DebugDisplay('REQUEST', $_REQUEST); echo $show->ShowDebug(); } Application Output
  2. You have several other issues but as to your problem. Your button group is named name='RadioGroup1' but you are trying to insert ans. There is no $_POST['ans']. There is also no $_POST['value'] either. You also gave two buttons the same value. You also have a ridiculous amount of unnecessary escaping. Your opening form tag is in the completely wrong place. The whole bit of code is quite a mess. You need to take a minute and study some basic tutorials. The whole thing needs a complete re-write. And while you're at it you should do it in PDO. https://phpdelusions.net/pdo Edit * It looks like you were already give good information on this in your other posts but you did not listen to what you were told. Your were even given code by @gingerjm that you ignored. You are just wasting our time if you're not going to do what we tell you. After seeing the other posts and responses you got you have now irritated me for wasting my time on this post.
  3. If you dont know html and CSS, start here :https://www.codecademy.com/learn/web Then go here https://www.codecademy.com/learn/php When you get farther along study this: https://phpdelusions.net/pdo Install XAMPP to run, test and learn on your local computer https://www.apachefriends.org/index.html
  4. Why are you storing the time separately? Just use a datetime column.
  5. You are expecting a POST array so look for a POST array. Do not use REQUEST. That includes POST, GET and COOKIES. if (isset($_POST ["flavour]) )
  6. If you did what @Jaques1 said you wouldn't have answered what you did. Go learn Database Normalization, ...then come back if you have problems after updating your DB.
  7. Aside from what @Jaques1 said, when you start numbering things something1, something2 etc. you are doing something wrong.
  8. How about posting an sql dump of your DB so we can work with it.
  9. Just noticed that you are looking up ICD codes. That data is way to huge to select everything. You are going to have to do something like a chained select where you select a category and work your way down the dropdowns. @barand makes a good point about the DB structure. What does the current DB look like? One big spreadsheet type table or something else?
  10. For starters, you don't need two queries to do the same exact thing. Dont SELECT *. Name the columns specifically. You are also opening your form AFTER the first select. In the posted code you don't close the form and there is no submit button. And next time, use the code tags when you post code.
  11. This is just for learning OOP. It is not about the function itself really, but how to handle superglobals in a class. The issue actually came up in a login logging class that uses $_SERVER['REMOTE_ADDR'], another superglobal. Several code analyzers (scrutinizer, codacy, code climate ) pointed out a problem with using them in the class. * As far as what the function is for, it is used to display messages to the user after certain actions such as a db record added or deleted
  12. How would I to convert the following function to a class? What is the proper way to deal with GET and POST in a class since they are globals? My start class ShowActionMessage { } Function to convert function show_action_messages() { if (isset($_GET['insert'])) { $action = 'Added'; } if (isset($_GET['edit'])) { $action = 'Updated'; } if (isset($_GET['deleted'])) { $action = 'Deleted'; } if (isset($_GET['emailed'])) { $action = 'Emailed'; } if (isset($action)) { ?> <div class="row"> <div class="col-md-8 col-md-offset-2"> <div class="success">Record <?= $action ?></div> </div> </div> <?php } }
  13. Change if (isset($_POST['submit']=="Sign Up")) To if ($_SERVER['REQUEST_METHOD'] == 'POST') You are also trying to use variables in your form without checking if those variables exist.
  14. Not even going to try and decipher your code. If you're doing an INSERT you have no need to know what the last insert id is.
  15. @pieterjandc, we all know you don't know what your talking about. Just stop already. You're starting to look foolish.
  16. You already lose "best answer ever" by using $_SERVER['PHP_SELF'] which is vulnerable to an XSS attack.
  17. Oh no, no, no, your problem is the entire database structure. Seriously, stop what you are doing right now and go back to the drawing board and start working on a sensible DB Schema. We will be happy to help you get going. What you have is an XY problem to the extreme. Start with a project summary of what this application is and what it should do then create a requirements document and post it. Once we know what you want and need we can offer the correct direction.
  18. In a nutshell, development server you turn on all error reporting and display errors on the page. Production it is off and errors are logged.
  19. The SSH is for a remote connection. Your script will run on the server. No SSH needed.
  20. If you had gone the Vagrant route first you would have saved yourself a lot of time and trouble. Install Xammp locally for development. If you want to develop or test on the exact server setup that you use in production, use Vagrant with your virtual box. The particular OS doesn't make a lot of difference as far as a LAMP stack. Apache is Apache is Apache. Php is Php is Php. Mysql is Mysql, is Mysql. My personal Linux choice for production is Debian. Ubuntu and many others are derivatives based off Debian.
  21. I have not used anything else recently to be able to tell you another way. Looks like Flowplayer has changed their model since I used it last.
  22. You might be interested in Flowplayer or Jplayer https://flowplayer.org/ http://jplayer.org/
×
×
  • 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.