Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. Your final test of chkerrors is incorrect. == As for the whole logic - you set chkerrors to true if any one of the values is present. Then at the end you are looking to see if chkerrors is false. Your handling of this obviates the need to even have $chkerrors at all. Plus - you output an error message AND a link for every error. You could end up with a rather silly looking page having 4-5 error messages with the same link repeated 4-5 times. If I may offer a re-design: To make it easier to follow, I'd use a var called $no_errors and set it to true to start. I'd also initialize $errmsg to ''. Then as I checked each value, if it was invalid I would set $no_errors to false and add an error message to $errmsg. ($errmsg .= "this field is bad<br>";) When I finished checking each value I would then check if $no_errors was still true. If not I would then echo $errmsg and the <a> tag and exit.
  2. I have no idea what you are proposing. Sorry, I think I'm done here.
  3. The php manual has a great page on all the different sorts available. http://us.php.net/manual/en/array.sorting.php You have chosen assort which is intended for associative arrays, but I think your actual array is not an associative one. I think you want to sort by value, so you need to use "sort" instead.
  4. Don't understand at all what your $search string is doing. As for showing the whole line - of course it does. What would make it NOT do that? Your run a stristr but you don't capture the result and don't use that result to limit the output.
  5. The first page does a scandir to get all the article/file names and the keywords(?) and the second page processes one selected article and displays the entire contents. No? Read up on scandir and fopen - two php functions that will do what you want to do
  6. Actually if you look up insert query in the MySQL website (just google MySQL insert) you will see an example of this exact thing. google is your friend - use it.
  7. I think you're describing have <a> tags around your "variables" so that when they click on one of them you can take them to the article they want to see. No? <a href=(url/pagename?article=$var1)>variable1</a> <a href=(url/pagename?article=$var2>>variable2</a> where $var1 and $var2, etc are set to some keyword or filename that tells your receiving page what to do. Your receiving page simply does: $article = $_GET['article']; to get the value and then it runs with that info. Hope I'm close.
  8. YOu already know how to write the html. Just bury php vars in where you want the dynamic data to show up. I do this by using a function that simply displays the html page. I use global vars to pass the data into it, use heredocs statement to make it easy to setup and to read later on and then just call the function after my php code has done it's thing. <? (startup php stuff) if (no submit button) { $step =1; DisplayPage($step); exit(); } if (submit == "get user") { (retrieve the user id input by the user on the first page display) (get the user info from the db) (assign data to vars) $phoneno= $qrslts[0]['phone_number']; $createdt = $qrslts[0]['create_date']; $step = 2; DisplayPage(2); exit(); } if (submit == "try again") { $step = 1; DisplayPage($step); exit(); } function DisplayPage($step) { global $phoneno,$createdt,$morevars......; ( the rest of this function is your html layout with some php stuff inserted) $code =<<<heredocs <doctype html>..... <meta tag> <meta tag> <head> (js) (css) </head> <body> <h1>asdfasdf</h1> <h2>asdfasdfasdf</h2> <p blah blah blah</p> heredocs; echo $code; // if step is 1 just show the user the input box for an id if ($step==1) { $code=<<<heredocs <form> <input type='text' name='uid' value='$uid'> <input type='submit' name='btn' value='Get User'> </form> heredocs; echo $code; } if ($step ==2) { $code=<<<heredocs <p> For user id $uid the following was found on file:</p> <table border=1> <tr><th>Phone #</th><th>Create Date</th></tr> <tr><td>$phoneno</td><td>$created</td></tr> </table> <br><br> <form> <input type='submit' name='btn' value='Try Again'> </form> heredocs; echo $code; } echo "</body></html>"; return } Note the php vars embedded in ordinary html code, which are passed into the function using the global statement. Also note the use of the heredocs syntax to make it easier to combine html and php code in your display logic I user this model for *every* one of my pages. Serves me well. Created a template in my IDE to help me begin every page with all the usual stuff I need.
  9. #1 - you don't check the result of your "mail" statement. Why not? It should return a False value since you have not followed the syntax of the "mail" function. Per the php manual, the "to", "subject" & "message" args are to be followed with "headers" which must all be separated with a newline. Also there is a requirement that one of the headers contain a From address. Since you didn't begin with the "from" address, the Mail function is probably not recognizing it all the way at the end of the long concatenated string of info that you are including. Try doing this: $mail_ok = mail(......); if (!$mail_ok) { echo "Could not send mail"; exit(); } header(.......);
  10. Your script runs very straight-forward right thru a query to verify that your selected event type exists. Well, you don't have any <input> tag in your html with that name, so this query will not return any rows. Hence your message when you check the row count. As for you prev statement that Event_type has nothing to do with the form, if so, why do you refer to it as part of the $_POST array?? It's always a good idea to validate all incoming data before proceeding on with the work at hand. In this case you are not.
  11. So you do have access to an sql database. That means you can create whatever tables you need to store data in. Then you can use those tables to get the data you need to put on your "dynamic pages" all using one script. You make a script that displays an html page containing several php vars around the page. Then you use php to take the selected user id and look up the data in your sql db and place that data into those php vars. That's a dynamic page, all generated by one script
  12. You could use a var to hold the "and" clause and just leave the var empty when you need to. It would still be nice to see the actual code - you gave us but one more line when I asked before. Apparently somewhere you are using a var $q which Barand has asked to see, but I haven't seen that part of the code.
  13. In your previous posting you mentioned that you didn't have SQL. How are you going to maintain the data necessary to create a dynamic website such as trq is suggesting? It's tougher to do with just a straight text file or something to read as a reference. And surely you will want to branch out and expand on this simple approach after awhile. In general you would use a db to store the individual data you want to put into these "separate" pages you have in mind. Then your select box gives you the user as you already know how to do. But then you would take the selection and read your db and put that data into your standard page template. Basically just one or two scripts.
  14. ok - you have a site available to you, but no sql database to use. Hmmm. You could easily create a script that browses a folder containing your articles - text files I presume, or pdfs perhaps. This script can then build a small paragraph of text, say the first 100 chars, from each article/file. The script finishes by creating an html page containing all those paragraphs in a grid perhaps and displays it. Now the user clicks on a "read more..." button and your script then builds a different page with all the text of that specific article in one textarea/div/paragraph or whatever. At the bottom you have a return button that takes you back to the previous page. Sound doable?
  15. It sure would be helpful to actually see the code around this query process. Not the whole script but the part that we are trying to debug for you.
  16. Why aren't you checking for the success of your query?? Might tell you that you have a problem with your query statement. What's a "valg"?? Don't know what you are attempting, but your query definitely looks bad.
  17. litebearer - My point was more about the OP loading up his entire project(?) and expecting someone else to do what he should have already done such as some debugging and isolation of the problem instead of dumping it onto the net. S&H - haven't heard that name in a veeery long time
  18. I presume that you are not doing any error checking when you execute this query, because I'm sure it will fail to run. $qrslts = MySQL_query($q); if (!$qrslts) { echo "Error running query - error msg is: ".MySQL_error(); exit(); } should catch this. Meanwhile - your query will only return two fields - id & url. Also you session vars are not entered properly. S/b $_SESSION['index']
  19. You would put the test and header in each page that you are afraid of people bypassing security by typing in the url directly to the page. BTW - what is this doing: // username and password sent from form $myusername = mysql_real_escape_string ($_POST['myusername']); $mypassword = mysql_real_escape_string ($_POST['mypassword']); $myusername = stripslashes ($_POST['myusername']); $mypassword = stripslashes ($_POST['mypassword']); You've protected yourself from injection with the first two lines, but then you are removing non-existent slashes in the last two lines. Basically you use the first two when using the fields in a query, and when storing in your db. You would use the last two lines when you take already "sanitized" data from your db and are showing it to the user again. Not both at the same time!
  20. When you say "click the print button" are you talking about a button that you put on the page, or the browser's print button?
  21. Are you in fact getting the error message "please try later"?? Cause if you are not, then how do you know you didn't? Plus you should add MySQL_error() to that echo statement to help you out. BTW - your insert has more values than field names.
  22. Are you all set with this question? I can't tell from the posts so far. If not, I have questions. Like - are you uploading images or not? Kinda sounds like you are not which means how do you expect to display them? AFAIK you can't keep them on your pc and display them on your webpage. The pic files need to be stored on your server and then your script creates html tags that point to the folder holding your images and looks up any data about the pics in your db, using the filename as the lookup value.
  23. Are you kidding me/us? You submit 9 files and tell us some vague problem exists and expect US to do your problem solving???? And what are we supposed to do with your 50 points??
  24. That's programming!! A never-ending educational experience.
×
×
  • 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.