Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. Did you get an error message? Try doing the arithmetic outside of the array reference.
  2. 1 - Four posts at once? Really? 2 - You showed us a bunch of code. 3 - You mentioned that you just found out about the existence(?) of Sessions in PHP. 4 - You didn't ask a question. EDIT - My bad. After posting I re-read the topic heading and see that there is a (sorta) question there. So - use my reference to the manual to learn about sessions. As for how one writes a secure login script there is lots of info out there and samples too. Everyone does their logins differently so do some research and pick the one that makes sense to you and then read up on the functions/features it uses to learn from it and then ask for tips once you have written something. A good point of reference as a newcomer to PHP would be the official PHP manual. Go to 'php.net'. Plenty of knowledge there for you to read up on. PS - It is good practice to separate your html & JS code from your php code - for logical sense and readability and maintenance purposes.
  3. And with Cronix's tip making sense out of these posts, your code needs to reference the cid element like this: foreach ($items as $item) { $a = $item['cid']; ... ... } Your array is not an object nor does it contain objects, so no 'object notation' is necessary. It is simply an array reference. PS: Are you really constrained into using an array to store your data instead of a much more sensible and practical db table?
  4. Uh.... How is your $items array related at all to the second snippet of code you posted that reads a file into $file? And what do you expect to be read and stored from that snippet? You are simply reading a php file as a 'text' file and storing it as a string(s) in $file. $file will not be an array - it will be a string. Am I missing something?
  5. When you say "new to coding PHP" that means it is time to sit down with a good book or online tutorial and start learning. You'll never learn to code if you don't do it. Nobody here is going to write code for you. But - the people here are very happy to help you correct your attempts. Have fun and good luck!
  6. Probably by writing some php code that includes some db connection and a query and a while loop to handle the query results and some more php to output the data and some html to wrap it all up in a proper web page.
  7. Didn't you post this same question last month? At least post some code for us to work with.
  8. When it "doesn't work", what exactly does happen? Do you get your error 404 message? When one types in "..../registration" how does one get to 'page.php'? Did you replace 'index.php' as your default home page? Did you try to do some echoes to see where you are ending up?
  9. This code: $stmt->bind_param('issssssib', $escola, $form, $data, $horas,$local,$dest, $datas, $visto, $file_path ); if (!$stmt->execute()) { echo json_encode(array('status' => 'error', 'message' => 'Opppss...A formação não foi gravada')); } } else { echo json_encode(array('status' => 'error', 'message' => 'Opppss...A formação não foi gravada')); } $stmt->close(); is flawed and is probably causing your script to not execute. You think that the file is being saved but I suggest that it was already there. Try adding some echo statements to verify what is happening - after you fix the flaw above.
  10. As I said - you can do that and save them in the session vars. BTW - you don't need a session to have a cookie. The term 'session cookies' is incorrect.
  11. Who changed the permissions? If what you say is completely accurate, the error message is spot on. You don't have permission to access that file or folder. Did someone remove a user from that folder? Did someone change the user that php is running under? Did your folder name change for some other reason and your access is now flawed?
  12. IMHO you are getting confused by your attempts to use session for something it is not appropriate for. A session is just that. It is a period of time when there is usage of a browser to connect to your site. It lasts only as long as that activity continues. It can disappear via a timeout if there is no activity on the browser (I believe) but it will continue to live and exist as long as there IS activity on that browser. That's a session. It has no life after the browser is closed so concern about getting rid of certain values is misplaced I believe. (I'm sure if I have made a misstatement here it will be brought to our attention!). As for your desire to retain some information BETWEEN sessions you need to focus on cookies. Cookies are actually there to help you retain something that you want to last longer than a session. You can create the cookie with an expiration date so that it will eventually go away from lack of use and you can re-set the expiration date every time it is accessed. Sounds like something that already does what you are trying to do. Now the connection that is missing is how will the cookie relate to the data that you want to 'remember' between sessions? Well if it is simply a username (and id?) then one cookie s/b sufficient. Your script begins, looks for a specific cookie and uses the value of the cookie as the username. If they successfully complete the 'login' and prove that they are eligible to use this app then you can re-write that cookie with an updated expire date. Your last statement above said you 'need is for username and id to be unset'. Why do you need both in the first place? If you give the user his username and he supplies the password - YOU can then verify the signon and get the id from the db. No need for it to be stored anywhere else between sessions. But if you do need the id saved for some reason, a cookie will work. As for removing them at the close of the browser - I'm confused since your whole effort seems to be how to retain them between sessions and now you're concerned with removing them at the end of the session. Well - a simple session var already does that if you use the normal default settings for sessions. Hopefully I am not mis-informing you. This is my experience with sessions, which I've never played with and worried about timeout and retentions, etc. If you want something retained between sessions, use a cookie. For stuff during a single session, use session vars. For removing something in a cookie, delete it when you want to un-remember the info. Seems like this should do everything you want.
  13. You don't mention Ajax in your post. Since php is doing the update on the server, it is difficult to have your client produce a pop-up window as a direct result of an insert. The only way to have a pop-up is to do this via an Ajax connection and then you can setup a popup notification or a simple js/jq alert box. The main point is that you must be using Ajax (via JS or JQ) Of course if you don't want to use ajax, then your script will simply call the server via POST and do the update and return a response page to the client and there you can show whatever message you want whether it is on a popup, an alert box, or a simple box/div on your main page, which is what it appears you are currently doing. The main point is you can't do a popup directly from php. You have to utilize js/jq to get that, either using ajax or as part of the page load in the ensuing page load.
  14. Barand has provided some great code that normally would be perfect for you Proba. But as you said originally the input can be in 'random order' so this code will not work. Are you sure the input is in "random order"? Seems strange to have a process that produces random input like you describe.
  15. I don't understand your dilemma. You said that you 'created (a) click tracking system' but then you asked for help with '(a) unique click tracing script'. What's the difference? And what is an 'impression'?
  16. Actually you are using fgetcsv to READ the incoming data. As I said in my other response to you, the incoming data must be in a recognizable order or you can not do this. Whether the data has identifiers within it or there is a row of headers at the start, either way. But to be completely random is not possible. I have to wonder how this data was prepared for you with no thought given as to how it would be used.
  17. I'm confused. Are you trying to replace some specific content in a pdf document or are you trying to provide input for designated fields inside a pdf, ie, fill out a pdf form?
  18. My bad - the reference to JS was not from the OP. But my immediate thought was that IE was not recognizing something in his js code since I can't imagine where PHP would have a problem based upon the browser source
  19. So - if it is not homework, then it must be for work. Ask your boss for clarification if you don't understand it.
  20. And perhaps post it on a JS forum, not php.
  21. Yes - your test email code should work. As for your last post, a blank page usually indicates that you had an error. Check the browser page source, or be sure that you have error checking properly engaged. (See my signature)
  22. Is this an HTML problem with the links? Or is it the php that is receiving the page and trying to re-direct the page? If the former, try an html forum perhaps. If the latter, do you have php error checking on? Have you echoed out any info from your script that might help debug the problem? Can you post the RELEVANT code (in proper forum tags) that attempts to handle your input from the html?
  23. You should study the manual where it describes the syntax of the mail() function. Your header parm is not correct, unless your 'applicant_name' form field is inappropriately named. Going further than I have ever before, here is what you need to send: to address (of course and you have done so) subject (you got it) message body (you have the contents of 'applicant address' here) headers - usually the from address (you have the applicant name here)
  24. Your call to a 'query' function is not going to return an exception, as boompa tried to say. The 'query' function of yours returns the object (??). Try adding your exception check to the actual query execution statement if you want to see the exception. Kind of a lot of code to perform a simple pdo query.
  25. Tis better that you read the manual and Learn from your trial and error(s) than for me (or someone else here) writing it for you. Good luck and have fun. Besides if I show you how to separate out your 3 values from this string what the heck are you going to then? Have someone write the next piece of the puzzle for you? C'mon!
×
×
  • 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.