Jump to content

wolfcry

Members
  • Posts

    106
  • Joined

  • Last visited

Everything posted by wolfcry

  1. Thanks for the answers all. I figured as much lol. @mac_gyver: I would but in the end I would still have to redirect or reload which is what I was trying to stay away from.
  2. This can only be done with JS/Ajax correct?
  3. Sorry Jessica, I was trying to get multiple things done at once and completely spaced it. My apologies. Here is the tidbit of code. Obviously there's more before and after but none of that pertains to this portion. { echo '<table><tr><td>'; for($i=1; $i<=$Sets; $i++){ $Calcs = CalcType($SpecId, $min, $CQuantity, $CType); echo 'Calculations for '.$SetText[$i]; foreach ($Calcs as $key => $DisplayCalcs) { $SetCalcs[] = $DisplayCalcs; echo $DisplayCalcs.', '; } if($Sets == 1){ $SetResults = implode(',',$Calcs); DB_Insert($EData,$Total,$Modified,$Counter,$Sets,$SetResults,$TimeStamp); }else if($Sets >= 2){ echo '</td><td> => <input type="button" name="SelectThis" value="Keep This Set"></td><tr><td>'; } } echo '</td></tr></table>'; if(isset($_POST['SelectThis'])){ DB_Insert($EData,$Total,$Modified,$Counter,$Sets,$SetResults,$TimeStamp); } } As previously stated, everything works up to the point of trying to select a specific calculation from multiple options. I'm sure I'm just spacing something and I'll most likely need an OnClick JS handler for this, which is fine, but I was really hoping I could do it strictly using PHP. I'm sure it's due to the fact that I'm not using <form> tags with the buttons and redirecting back to the page, but I was hoping there was a way to do it without needing to use them.
  4. Hello all, I'm not really sure if this should be in the SQL portion or not. I don't think so because I'm not having issues with SQL syntax, just the proper PHP (?) coding to achieve a specific result. What I'm trying to do have the user perform a randomized calculation that outputs multiple results; displaying those results on the screen and have them select the result they wish to keep. This result is then inserted into the database accordingly. To give a better example, let's say the user performs the action and the following results are displayed (I'm using names just as an example): David Josh Carrie Spike and they wish to keep "Spike". When they click on the link that states, "Save", Spike is then inserted into the database. I can get the multiple calculations to perform; have them show up on the page with the "save" link next to each one, but nothing is inserted when the link is clicked. Can PHP perform this action or will I need to use JavaScript for this?
  5. while-do That made me chuckle . It's actually called a "do-while" loop because the script will "do" something at least once and keep doing it it "while" a certain condition remains true.
  6. If you don't really care about duplicate data, store it all in one database that way it'll make querying a bit easier (not requiring JOINs etc.) A basic DB structure I've done for this sort thing was like: Table: ClanMatches Team_A | Team_B | Scheduled_Match_Name | Match_Date_Time | Winning_Team | Losing_Team | Winning_Score | Losing_Score | Then you simply query the rows and display them as you see fit. Mind you, this isn't the best method if you're looking for cardinality but it's more than enough if you're running a simple clan site.
  7. Without seeing your actual form code, are you sure this: $_POST['Item_Number']; is spelled correctly or actually exists in the form?
  8. There are a variety of ways to do it, but the easiest in my opinion is simply placing it in a secured directory and using .htaccess to deny direct access. Here is a great site on writing .htaccess permissions: http://www.askapache.com/htaccess/htaccess.html And here's an example about protecting your include file from being directly accessed if you don't want that to happen: http://davidwalsh.name/htaccess-security-include-files
  9. I've always used it and never had an issue but then again, I use it with other conditionals as well.
  10. And you should do some validation as well: if ($Item_Number) { /// } Should be: if (is_int($Item_Number)) { /// } To ensure that the $Item_number is in fact an integer if only integers is what you want. I'd also do the following with submit just for additional validation purposes: if (is_int($Item_Number)) { if (isset($submit)) { // do something } } As for your undefined index warning, define $Item_Number at the top like so: "$Item_Number = 0;". Either that, move "$Item_Number = $_POST['Item_Number'];" into the $submit if() statement.
  11. Have you tried comparing it against NULL? if ($row['fieldname'] == NULL){ do something. }
  12. Yeah, Pikachu2000 hit the nail on the head with the manual reference and you need to bookmark that site. Though, sometimes it can be confusing for those just learning PHP IMHO. If you like books, one of my favorites is Beginning PHP and MySQL and if you're more of a visual type of learner through "live video" teaching, http://thenewboston.org/tutorials.php has awesome tutorials on quite a few languages, including PHP (It's under the Computer Programming) section on that page.
  13. That's because the form is submitting back upon itself (to the same page). To accomplish this use the name of the file in the form action like so: <form action ="same_page_of_form.php" Method="POST"> When the user submits the form, it will simply submit back to same_page_of_form.php. So if your form is on index.php and you want to stay on index.php, simply use index.php in the action.
  14. Wow, I sense a bit of bitter impatience there. Considering I didn't even get the code I requested until nearly 7 hours after the fact around 8pm my time and when I'm trying to spend time with my family... Anyways, since I'm getting the gloomy feeling that our help is more expected rather than appreciated, good luck with your script, I hope you fix the issue.
  15. Is this the same code you sent me? And What error are you receiving? Also, as a security precaution, you shouldn't use $_SERVER['PHP_SELF']; without some form of validation / sanitization because it's exploitable to XSS attacks. I usually just reference the actual page I want to post back to. Here's a pretty good read about it: http://seancoates.com/blogs/xss-woes
  16. Generally one can simplify it by asking themselves, "Do I trust this code / file and those who are distributing it?" If not, then make your own. If yes, then use it. You also have to make sure that if you do use code someone else wrote, make sure it doesn't have security exploits, intentional or not and never forget to give credit where credit is do.
  17. You beat me to the punch Mikosiko lol. You need to define $data and populate it with the mysqli_query then use that variable inside your mysqli_num_rows function.
  18. Hey Matt, You wouldn't mind PM'n me all of your code would you? As in your connection variables (just change the sensitive stuff like password and username), your DB schema and what not. What I will do is create a dummy test DB on my server, duplicating your structure exactly, and see if I can track down your bug.
  19. As for sanitizing, yes, it appears correct to me. if (!isset($_GET['id'])) { $query = "SELECT * FROM ncmr WHERE id = '$id'"; } else { $query = "SELECT * FROM ncmr WHERE id = '" . $_GET['id'] . "'"; } perform a var_dump to see if that query is actually populating the $id variable, if it is, perform another var_dump after submission to see if it's still populated by an integer. If either are empty (or NULL), then you need to debug and find out where it's not being populated. If you have an IDE with a debugger, it will make your life sooo much easier to do this. $query = "UPDATE ncmr SET ab = '$ab', date = '$date', part = '$part', rev = '$rev' , partdesc = '$partdesc' , ncmrqty = '$ncmrqty' , comp = '$comp' , ncmrid = '$ncmrid' , rma = '$rma' , jno = '$jno' , fdt = '$fdt' , cof = '$cof' , fab1 = '$fab1' , fab2 = '$fab2' , fab3 = fab3' , non = '$non' , dis = '$dis' , comm = '$comm' , caad = '$caad' , po = '$po' , pod = '$pod' , dri = '$dri' WHERE id = '"$id"'"; Try removing the double quotes around $id and see if that helps if both var_dumps return the $id value.
  20. Yeah, you're right, my answer is off. I originally intended to say "In short, they both basically do the same thing as far as printing output to the browser with the exception of blah, blah blah." My bad. And that's an excellent point ManiacDan regarding relying on forums for "accurate answers" where all one has to do is read the manual. Especially when it comes to having others do the research for them. Because in the end, we all perceive things differently and do things in ways others would not...
  21. I have already answered your question in my post above. You can use whatever method you want to pass the data along, that's up to you, but remember, there are limits to how much data can be stored in the URL if strictly using GET. The issue, from what I can tell when clicking submit on your form, is you're using POST to send the data correct? Like so: <form action="same.page.php" method="POST"> I'm assuming this because I no longer see the id variable passed in the URL. Then you need to use POST to extract the data after it's been sent. You cannot use GET to extract POST'd data because GET only extracts data that has been streamed in the URL or URI if you want to be extremely technical. Here's a great example of POST and GET methods, it seems you're confused about the two: http://www.tizag.com/phpT/postget.php Ok, so, IF you're using a query to obtain the id at the beginning and attaching that to your URL, which you are, and IF you have your form method set to POST you must pass that along so it can be stored into the global array POST as well because as soon as you click submit, that value is lost. Both GET and POST are simply arrays, if you stored data in array1, you wouldn't try to extract that data by calling array2 would you? Same thought process here. This is where the hidden form field comes into play. IF you were using GET as your method, you'd simply extract it using GET after submission because it'd remain in the URL but so would everything you just did and from how I see your form is set up, you'd most likely have too much data for the URL to hold all that data (again, there is a limit). Simply do as I suggested above about storing the id value into a hidden form field and extract or call, however you want to say it, the data after it's been submitted by using something like this: $id = $_POST['id']; then use that after the form as been set to update your database accordingly. With all that said, I'm going to throw another wrench at you, . You could send the id along a POST form in the URL by echoing the id in the form's action. Like so: <form action="p.php?id=<?php echo $id;?>" method="POST"> That way you can still use GET to extract that from the URL (after submission) and still be able to post via POST the rest of the stuff. The downside is, it will cache on their end in the browser's URL and you will have to refresh the form if you want varying id numbers for each post submitted even by the same person. Hopefully, I didn't confuse you too much lol. In short, do the following if you want to keep it as simple as possible: form method = GET / use $_GET['']; to extract data. form method = POST / use $_POST['']; to extract data. or use a combination of GET and POST if echoing data dynamically in form's action if method is set to POST
  22. Hey kicken, That's exactly what I ended up doing. Went the ole' regex route. Though, I have to admit, I was really excited when I "thought" I had read that a filter would do that for me without needing to write additional code. It's a cruel world
  23. Echo and print do exactly the same thing, though print is a reminiscent function based off C / C++. Print_r prints the data of a variable (like an array) that's readable, kinda like var_dump and include will not kill the page if the include file is not found whereas require will. If you use include_once, or require_once, that means the server will only include that file once rather than multiple times if you have called it multiple times in your page. Also, go here and search for those terms: http://php.net/manual/en/index.php
  24. It's working as it should, you just have your messages flipped. Change echo "Hi" with echo "Bye" and vice versa. The 'else' part is what's supposed to happen IF json['Poster'] IS set. To get a better understanding of this, instead of using "Hi and Bye" as your test messages, try this: if (!isset($json['Poster'])){ echo "Poster is NOT set!"; } else { echo "Poster IS set!"; } Hope that helps
×
×
  • 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.