Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

How do I get a PHP to run from HTML?

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:

<?php
    error_reporting(E_ALL);
    include ("config.inc.php");
    $ukey = htmlspecialchars(trim($_POST['ukey']));
    $ukey="12345";
                        
    $conn = mysql_connect("localhost", "X", "Y.") or die('Verify DB Failure ' . mysql_error());
    mysql_select_db("test");
                  
    $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;                        
                              
    mysql_close($conn);
                        
?>

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

Thanks in advance for your help.
0
kbios
Asked:
kbios
  • 2
2 Solutions
 
amiguraCommented:
you use $_GET['ukey'] to get url varibles
you normally use POST for forms

try

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

Open in new window

0
 
Dave BaldwinFixer of ProblemsCommented:
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 http://www.php.net/manual/en/reserved.variables.php shows the different predefined variables that are available in PHP.
0
 
kbiosAuthor Commented:
Thanks to both of you. The $_GET did the trick.
0
 
kbiosAuthor Commented:
Thanks.

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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now