Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. I do not think it is possible. You would have to have image recognition software to determine it. Although the site that is dishing the image may send some type of header with the image, which I do not know if you can parse it out, but yea that might get you something. The only thing I could think of to do, is ask the user to verify the uploaded image if they verify it, post it, if they say no, than dont add it. I would hope a user would not post a blank square image. Sometimes you would hope that users would be smarter than they are.
  2. This may be stupid, but I fail to see session_start <?php session_start(); // needs to be at the top of any page you want to use sessions in if($_SESSION['authen']) { $_SESSION['item'][] = $row['isbn']; echo $_SESSION['item'][]; // I want to print this just for checking echo "</td> <td valign=\"top\" align=\"center\"> <p align=\"center\"><font face=\"Tahoma\" size=\"2\"> <a href=\"../shopping/cart.php\"><img border=\"0\" src=\"../images/cart.jpg\" width=\"69\" height=\"132\" alt=\"add to cart\"></a> "; } else { echo "</td> <td valign=\"top\" align=\"center\"> <p align=\"center\"><font face=\"Tahoma\" size=\"2\"> <img border=\"0\" src=\"../images/spacer.gif\" width=\"69\" height=\"132\">"; } ?> Again I may just be missing something but yea.
  3. No, that doesnt work. If you wish to include a file with "get" data you can do this: <?php $_GET['action'] = "display"; $_GET['title'] = "test"; include("include/somefile.php"); ?> You just have to manually define the get data you want to put in.
  4. The simple solution to the problem with my method is rename privateplace.html to privateplace.php. Then add a check like in thropes to display the private stuff. Modified version of my script to set a session variable: <?php session_start(); $valid_username = "admin"; $valid_password = "password"; $username = isset($_POST['username'])?$_POST['username']:""; $password = isset($_POST['password'])?$_POST['password']:""; if ($username == $valid_username && $password == $valid_password) { $_SESSION['logged'] = true; header("Location: privatepage.html"); }else { $_SESSION['logged'] = false; header("Location: index.html"); } ?> Than your private page would be <?php sesson_start(); if (!$_SESSION['logged']) header("location: index.html"); // put the private data here, no one will see it unless they are logged in. ?> Basically everything you need is contained in this post, just pick and choose and implement.
  5. I guess what I am getting out is not necessarily a competition with prizes, just a fun piece of code for someone who wants to learn and get peer-critiqued to write. But yea, just an idea =)
  6. You should be pulling out the field name with either example, preferably I would use mysql_fetch_assoc. You can get all the fields by doing this: <?php $query = mysql_query("SELECT * FROM fd_users WHERE username = '$username' and password = '$password'") or die(mysql_error()); while($row = mysql_fetch_assoc($query)) { foreach ($row as $key => $val) { $stringOfData .= "&" . $key . "=" . $val; } echo $stringOfData; $stringCollection[] = $stringOfData; // put it into an array for fun. $stringOfData = ""; } echo "<pre>"; print_r($stringCollection); echo "</pre>"; ?> that should get you your desired result, you may have to substr the first & off. But yea.
  7. This is sort of complicated but I will give it a shot. <?php function createArchiveLinks($author) { $sql = "SELECT `date` FROM news WHERE author = '" . $author . "' ORDER BY `date`"; $query = mysql_query($sql); while ($row = mysql_fetch_assoc($query)) { $year = date("Y", $row['date']); $month = date("m", $row['date']); $month_full = date("F", $row['date']); $y_m_new = $month . $year; if ($y_m_new != $y_m_old) { $return[$x]['full_date'] = $month_full . '-' . $year; $return[$x]['url'] = '<a href="' .SERVER_URL. '/news_archive.php?year=' . $year . '&month=' . $month . '">'.$month_full ." ". $year .'</a>'; $return[$x]['month'] = $month_full; $return[$x]['year'] = $year; $y_m_old = $month.$year; $x++; } } } $archive_links = createArchiveLinks('author'); // grab links for user 'author' foreach ($archive_links as $key => $val) { echo $val['url'] . "<br />"; } ?> Not tested and the return array contains probably more information than needed but you can manipulate it how you want. This assumes SERVER_URL is a defined constant, you want it for a user, you have a SQL connection and your date field is called `date` and your table is called news. I am sure you can manipulate this to your needs...this is untested.
  8. Oh sorry, my mind isnt paying attention today. With the new code added you should be able to increment each ID by one by doing the following: $order->incrementIDsByVal(1); Should increment all the IDs by 1. Change 1 to be whatever value you want and it will increment each item by that.
  9. Probably because the color attribute has a # sign in it, and you are looking for only digits.
  10. Yea, I can sort have see it. But honestly if they can access the admin part of the table script than they can even access the admin table. Its all about SQL injection. I have never separated the admins/mods/users in any of my script and have yet to be hacked. The key is to make sure you cannot be SQL Injected, thats when the bad stuff comes. As long as the code does not allow for that I fail to see how a hacker can get into your site without having the right credentials. At least that is my 2cents, I think it is just extra work and not more secure.
  11. No, that is not alot of changes. You have the right idea. Instead of having the class hold 5 different ids, it now can hold 5 different objects (which can be as many objects as you want) and you can just iterate (move) through the items or print them out like above instead of having to call 6 different function like before. I hope that makes sense.
  12. Right thats how it should be...right? I do not see how one item can have 5 different ids....? This way you have a collection of items, this should replace the need to have multiple ids for an item, and just have one id. If that is not what is suppose to happen, than I am afraid I may have wasted alot of your time.
  13. It shouldnt increment the id's unless you tell it to Given your output from above: Those are the values you are passing to the array...so this is working like expected.
  14. So meallist is a multi dimensional array. try this. <?php session_start(); include('order.php'); // include the order class. if (isset($_SESSION['order'])) { $order = unserialize($_SESSION['order']); }else { $order = new Order(); } // incase we want to reset our test data. if ($_REQUEST['reset'] == "ok") { $order = new Order(); } $meallist = array(); foreach ($_REQUEST as $k=>$v) { if ($k=="meal") { $meallist[] = $v; } } $order->addMultipleItems($meallist[0]); //changed this to reference index of 0. $items = $order->getItems(); foreach ($items as $item) { echo $item->getID() . "<br />"; } $_SESSION['order'] = serialize($order); // now use $order as you wish $order->addItem(5); $item = $order->getItemByIndex(0); echo "Item ID of " . $item->getID() . " is at index of 0<br />"; echo "We currently have " . $order->getItemCount() . " items in your order.<br />"; ?>
  15. Not sure why you created a new topic here, but I posted a reply already on the original thread.
  16. date Put date around mktime with the format following the guidelines on the date page. <?php $three = date("FORMATHERE", mktime(0, 0, 0, date("n")/-date("j")+3/-date("Y"))); echo "$three"; ?> Should work, just replace the FORMATHERE part with the format you want.
  17. Not sure, I just tested it using the above code and it worked just fine. The only thing I can think of is meallist is an array... do me a favor and run this: <?php session_start(); include('order.php'); // include the order class. if (isset($_SESSION['order'])) { $order = unserialize($_SESSION['order']); }else { $order = new Order(); } // incase we want to reset our test data. if ($_REQUEST['reset'] == "ok") { $order = new Order(); } $meallist = array(); foreach ($_REQUEST as $k=>$v) { if ($k=="meal") { $meallist[] = $v; } } echo "<pre>"; print_r($meallist); $order->addMultipleItems($meallist); $items = $order->getItems(); foreach ($items as $item) { echo $item->getID() . "<br />"; } $_SESSION['order'] = serialize($order); // now use $order as you wish $order->addItem(5); $item = $order->getItemByIndex(0); echo "Item ID of " . $item->getID() . " is at index of 0<br />"; echo "We currently have " . $order->getItemCount() . " items in your order.<br />"; ?> Post the results that come from that.
  18. Post the code you are using please.
  19. First question: I am not understanding it. Are you asking that you want to change an oldID to a new one or increment all the ids in the order by 1? If the later a new function would need to be coded to loop through the items array and invoke the setID to equal getID + 1. Second question: If you name the object $meals = new order(); there should not be any type of issue with having multiple objects at all. For the code for the first add this inside the order class: public function incrementIDsByVal($val) { return $this->items->incrementIDsByVal($val); } Next add this to the Items class public function incrementIDsByVal($val) { if (!is_numeric($val) && $val < 1) { return false; }else { foreach ($this->itemArray as $key => $item) { $this->itemArray[$key]->setID(($item->getID() + $val)); } } } Untested so prone to errors of syntax but should work. Let me know if that was not what you were talking about.
  20. Entirely. Best way to find out, however, is try it yourself and see =)
  21. Doesnt look like it. phpinfo However you can extract certain parts, so you only pull the section you want. Might make it a little cleaner and less code to go through.
  22. foreach ($_REQUEST as $k=>$v) { if ($k=="meal") { $meallist[] = $v; } } print_r($meallist); $order->addMultipleItems($meallist); // change this to be just meallist (I do not think it should be multi-dimensional) To avoid this error in the future we can code this in: // takes in an array of IDs and creates each item. public function addMultipleItems($ids) { if (is_array($ids)) { foreach ($ids as $val) { $this->itemArray[$this->getItemCount()] = new Item($val); } } } That way it only processes if the item passed is an array.
  23. Add the ?reset=ok to the end of the usage.php so its like this: usage.php?reset=ok to reset the session object. What it seems like is the session is storing the old object order and not creating a new one.
  24. Ah didnt even think of that. Where are you setting $order to the class? I guess either way the full code would help out tremendously.
  25. Your form action should take you to valid.php valid.php <?php $valid_username = "admin"; $valid_password = "password"; $username = isset($_POST['username'])?$_POST['username']:""; $password = isset($_POST['password'])?$_POST['password']:""; if ($username == $valid_username && $password == $valid_password) { header("Location: privatepage.html"); }else { header("Location: index.html"); } ?> Something like that? As long as you have the form and the field names are username and password that should work.
×
×
  • 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.