Jump to content

mogosselin

Members
  • Posts

    116
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mogosselin

  1. This would be really easier to help you if you could give us a link directly to the page that doesn't work. There are some stuff in your PHP file that calls other files and since we don't have them, it's not really helpful.
  2. It depends what you mean by "automatically updates". Like WebStyles said, if you meant "without refreshing the page", then you'll need to use JavaScript. You could use something like: <script> function updateNewPrice() { var oldPrice = document.getElementByName("old_price"); var discountPrct = document.getElementByName("percent"); var discount = ($old_price / 100) * discountPrct; document.getElementByName("new_price").value = discount;< } </script> Then, in your 2 input fields (old_price and discount), add an attribute like: onChange="updateNewPrice()"; Example: <input onChange="updateNewPrice()" type="number" name="old_price" min="1" max="5" value="<?php echo $old_price; ?>"> If you meant "update price with PHP", then you'll almost there. Adding something like: $percent = $_POST["percent"]; $old_price = $_POST["old_price"]; if (empty($percent)) $percent = 50; if (empty($old_price)) $old_price = 100; Note that I didn't test the code, but I hope it can help you a little bit
  3. Hello herghost! Character encoding problems can be a pain hu!? So, you need to find where the problem is coming from in all the chain of "events". Here's what I understood from your post and code. Please feel free to correct me if I misunderstood something: 1. You press a button or do another action? (here I'll need more details) 2. Some data about hotels is selected in the database 3. This data is then inserted in another table 4. The data is not well displayed (?) at #1, what is the action that starts all the process? Where does it come from? at #4 : Where and how are you looking at the data? From a web page or did you logged in using a tool? at #3 : Before inserting the data into the database, did you try to print it out to see what it looked like? I would try something like: echo "accents: éàô?'"; echo $yourStringFromSelect; The variable "yourStringFromSelect" should contains the data you selected from the table. You could also try that in a standalone PHP script just to see the result. This way, you'll see if the problems comes from the "select", from the "insert" or if it's in the configuration of the table. Just be sure that your files are saved in the same encoding as the string you are trying to print.
  4. I don't know how WP works but... why can't you give your functions 2 different names?
  5. At line 12, you should change "userId" for "$userId" Just a note that your code is not secure, so please don't use it in production code 1. Passing password in clear AND in URLs is not good 2. You're not validating user inputs and your code is vulnerable to XSS vulnerability. 3. You should never write code related to logins, sessions and security yourself. Don't worry about it if you're just doing it for fun on your computer
  6. Welcome! If the lessons in school are as bad as they were when I started, it's normal that you struggle. Web development is nothing near Desktop development. You need to know a lot of concepts and "languages" (HTML, JavaScript, CSS) just to display stuff and one server side language. Another thing that school and beginner tutorials rarely teach is how the HTTP protocol works. If you didn't read about it, I suggest that you read a little bit about that: http://code.tutsplus.com/tutorials/http-the-protocol-every-web-developer-must-know-part-1--net-31177 http://www.jmarshall.com/easy/http/ If you still need help, don't hesitate we are here to help you Happy coding!
  7. I would say it depends on your experience with Web application languages. First, I would get better by learning the HTTP protocol and everything related (client side VS server side, how does the HTTP protocol works, cookies, etc.) Now, for back-end development, you could learn a bit more about Web services like REST with PHP. You could also learn a couple of lightweight frameworks like Laravel and Codeigniter. I don't include Drupal or WP in the "framework" group, those are CMS platforms IMO. Also, you could read this Website: http://www.phptherightway.com/ It's not complete but there are a lot of subjects that you could deepen by yourself (security, OO programming, etc.). After you're more comfortable with those advanced subject, it will be time to delve into topics like performance testing, scalability and architecture. Good luck! Don't hesitate if you have any other questions
  8. Just 2 PHP files and one text file. One PHP file to start the process and write the progress to a text file. And another one just to read the "progress" file. Not that difficult. You can do it!
  9. You can easily strip all the line breaks with this piece of code: $output = "abc def hij"; echo preg_replace('/^\s+|\n|\r|\s+$/m', '', $output);
  10. Like ginerjm said, you should use prepared statements or PDO. Do not try to write your own code to prevent SQL injections. That can be a fun side project, but I would not use that in production code. A rule of thumb about security in Web applications: Never try to write your own security code. You'll lose time reinventing the wheel and worse, you'll probably leave massive security holes.
  11. You are right when you say "flush command sent them directly to the browser". But this flushes the response "so far". It doesn't create a "new response" each time. This piece of code: success: function (data) { $('#content').html(data); } will be called only when the response is totally received. So even if you flush the response from time to time, the browser is still waiting for the response to be completely received before calling the "success: ..." piece of code. So lets say that I would like to print the result of a long process, here's what I would do : - Call a PHP script from Ajax that starts the long process - the "long process" will write its progress in a text file (or in session, or a database). - Then, each 2-3 seconds, an Ajax call to another piece of PHP code would get the actual progress from the text file and print it on the page. - When the first Ajax call enters in it's "success:..." piece of code, it means that the process is done. So you can kill the 2-3 seconds timer and print "Done" on the page.
  12. Hi everyone! I've been a Web developer since more than a decade now and I decided to spend more of my free time learning and teaching PHP / Web development. Now that my professional work is getting less and less "code oriented", I still need my "code fix" from time to time. Anyway, my main area of expertise is with Java, but I coded in other languages too (C#, PHP of course, the old ASP, etc.). And of course, I know the basics of HTML, CSS, JS, JQuery, etc.
×
×
  • 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.