Does not load the class .php call

0

I have 2 files:

load.html and colors.php

The load.html file is:

<html>

<head>
    <script type="text/javascript" src="../jquery.js"></script>
    <script type="text/javascript">
        var x;
        x=$(document);
        x.ready(inicio);
        
        function inicio(){
            var x;
            x=$("a");
            x.click(muestrame);
        }
        
        function muestrame(){
            var pagina=$(this).attr("href");
            var x=$("#hablame");
            x.load(pagina);
            return false;
        }
    </script>
    <style type="text/css">
        
    </style>
</head>

<body>
    <a href="colores.php?color=verde">Hablame del verde</a>
    <a href="colores.php?color=rojo">Hablame del rojo</a>
    <a href="colores.php?color=azul">Hablame del azul</a>
    <div id="hablame"></div>
</body>
    
</html>

And the colors.php file is:

<?php
if($_GET['color'] == "verde"){
    echo "El color verde es muy relajante";
}
if($_GET['color'] == "rojo"){
    echo "El color rojo es muy pasional";
}

if($_GET['color'] == "azul"){
    echo "El color azul es muy templado";
}

?>

When the load.html web is loaded and I click on hyperlinks, the sql code does not work and does nothing.

Thank you in advance for the support provided.

Slds Luis

    
asked by Luis Miguel Sanchez Alzamora 18.12.2017 в 09:50
source

1 answer

-1

You can start by checking that the correct PHP code is called correctly:

<?php
echo "Entrando en el PHP colores.php";
echo "He recibido el color: " . $_GET['color'];

if($_GET['color'] == "verde"){
    echo "El color verde es muy relajante";
}
if($_GET['color'] == "rojo"){
    echo "El color rojo es muy pasional";
}

if($_GET['color'] == "azul"){
    echo "El color azul es muy templado";
}

?>

If the PHP path does not take you directly, try to force the URL by typing in your HTML code:

...
    <a href="./colores.php?color=verde">Hablame del verde</a>
    <a href="./colores.php?color=rojo">Hablame del rojo</a>
    <a href="./colores.php?color=azul">Hablame del azul</a>
...

Note: You can also use $ _ REQUEST , which collects both $ _POST, $ _GET and $ _COOKIE

    
answered by 18.12.2017 в 11:39