开发者

passing values through the URL when using the $_GET just get blank page

this is the code used to get the information from the database, the images I have taken off the echo statement for the time being, and just the name of the product. When I click on the product name it sends me to cart.php and should pass the value in the URL it shows in the browser when I hover over the text but when i click it send me to cart.php and just shows a blank page

$product_types = get_all_subjects2(); function is just the query

  while($products = mysql_fetch_array($product_types))
{
   $name = $products['name'];
   $address = $products['image_location'];


    echo '<ul>';
    echo "<li><a href=\"http://localhost/project/cart.php?subj="  . 开发者_运维知识库  urlencode($products["name"]) . 
        "\">{$products["name"]}</a></li>";

The code

<?php

if (isset($_POST['subj']))
{

    $a = $_POST['subj'];
    echo $a;
}

 else {
            echo"error";
         }
?>


$_POST stored values following POST request. If you navigate via a plain link, you're doing GET requests. So look in $_GET.

Also it might be a good idea to always output valid HTML. Otherwise the browser might or might not render what you're outputing.


You send your arguments via GET. So asking for $_POST isn't the right idea ;).

For Debbugging it's nice to have this statement in your target site:

echo '<pre>', print_r($_REQUEST), '</pre>';

Best, Christian

Addition: tested the code.. just works fine:

<?php

echo '<pre>', print_r($_REQUEST), '</pre>';

if (isset($_GET['subj'])) {

    $a = $_GET['subj'];
    echo $a;

} else {

    echo 'error';

}

?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜