How do I get a PHP to run from HTML?

Posted on 2011-10-22
Last Modified: 2012-08-14
I have an HTML menu where the menu items are an unnumbered list. Here is one of the list items:

<li><a href="verifycart.php?ukey=12345">Verify Cart</a></li>

When I select this option from the menu the verifycart.php code executes. BUT, the variable is NOT passed. Question 1 - How do I pass data/variable to the PHP from here?
Here is the .php code:

    include ("");
    $ukey = htmlspecialchars(trim($_POST['ukey']));
    $conn = mysql_connect("localhost", "X", "Y.") or die('Verify DB Failure ' . mysql_error());
    $result = mysql_query("SELECT * FROM itemhdr WHERE itemhdr.ukey = '$ukey'");
           if (!$result) {
               die('QUERY ERROR: verifyupload ' . mysql_error());
          $row = mysql_fetch_assoc($result);
          $vcount = $row['verifycount'];
echo "INSIDE PHP " .$ukey;
echo "|";                                             
echo "VCOUNT " .$vcount;                        

Question 2 - Why doesn't $ukey get set via the POST?

Thanks in advance for your help.
Question by:kbios
    LVL 7

    Accepted Solution

    you use $_GET['ukey'] to get url varibles
    you normally use POST for forms


     $ukey = htmlspecialchars(trim($_GET['ukey']));

    Open in new window

    LVL 82

    Assisted Solution

    by:Dave Baldwin
    Variables passed in URLs are defined as $_GET variables.  In PHP, you can also use $_REQUEST to pick up both $_GET and $_POST variables.  However, $_GET and $_POST variables are separate variables otherwise.  This page shows the different predefined variables that are available in PHP.

    Author Comment

    Thanks to both of you. The $_GET did the trick.

    Author Closing Comment


    I have a followup question that I will be posting in a minute.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
    In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now