Results 1 to 5 of 5
  1. #1

    PHP $_Get method only returns partial value

    Good evening,

    I have an assignment due that involves taking input from a form and being able to update products in a backend mysql database.

    The only problem is that for some reason my app only allows me to update and delete products that are one word long. The items I want to delete have two words. It's almost like there's something I need to do to deal with spaces. I notice the product name in the url cuts off the second word of the product like urls below should both say "Jasmine Oil" not just "Jasmine". See below for an example:

    301 Moved Permanently

    301 Moved Permanently

    When I did an echo on $_GET["ProductName"] for testing purposes, I noticed that it only returns the first word in the Product Name and not the rest of the Product Name. Here's the specific $_Get code below:

    if (isset($_GET["ProductName"])) {
    $toDelete = $_GET["ProductName"];

    Does anyone know how I can address this?

    Here's my entire code below:

  2. #2
    Junior Member
    Join Date
    Feb 2016
    Location
    New Zealand
    Posts
    0

    PHP $_Get method only returns partial value

    Always use quotes for HTML attributes. Always. Of either type.
    PHP Code:
    echo "<a href='InsertApp.php'> Insert Another Product </a>";


    Also, when you put values into HTML you need to use htmlspecialchars(). If the value is in a URL then urlencode() it first.
    If you use single quotes for the attributes then you need ENT_QUOTES for htmlspecialchars() so using double quotes is easier.
    PHP Code:
    echo "<td> <a href=\"UpdateApp.php?ProductName=" . htmlspecialchars(urlencode($data->getProductName())) . "\"" .

  3. #3

    PHP $_Get method only returns partial value

    • Thanks! Is this a tip or will this fix the problem I'm having?







  4. #4
    Junior Member
    Join Date
    Feb 2016
    Posts
    0

    PHP $_Get method only returns partial value


  5. #5

    PHP $_Get method only returns partial value

    Yep that took care of it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •