PHP $_GET super global variable

Joined
Aug 22, 2023
Messages
1
Reaction score
0
I appreciate some help that is it possible to access the <p> tag name with $_GET variable in PHP?
 
Joined
Sep 4, 2022
Messages
128
Reaction score
16
Hello !

can you be more accurate in a new question, please ? I don't get it like that.
 
Joined
Nov 13, 2020
Messages
302
Reaction score
38
The $_GET variable is used to find a passed PAIR of information sent from HTML to PHP, like ?country = Itaily. You could pass the info contained in a <p> tag, but this has to be done in HTML with JS before sending the information.
 
Joined
Jul 4, 2023
Messages
366
Reaction score
41
It possible e.g. like that, but this is a bit useless

HTML:
<p id="my_p_name">
    Lorem ipsum
</p>
<a href="https://somewebpage.com?pName=my_p_name">Lorem</a>

can you describe in more details why you need <p> name in php,
or maybe you are looking for functionality using AJAX e.g.

index.html
HTML:
<html>
    <head>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
    </head>
    <body>
        <ul>
            <li><a href="#">A</a></li>
            <li><a href="#">B</a></li>
            <li><a href="#">C</a></li>
        </ul>
        <p id="my_p_name"></div>

        <script>
            $(() => {
                $('ul a').click((e) => {
                    e.preventDefault();
                    var letter = e.target.textContent.toLowerCase();
                    $('#my_p_name').load(`letter.php?selected=${letter}`);
                });
            });
        </script>
    </body>
</html>

letter.php
PHP:
<?php
  echo "You chosen the letter {$_GET['selected']}!";
?>
 
Last edited:
Joined
Aug 22, 2023
Messages
42
Reaction score
7
Given that I am not certain as to what you are trying to accomplish, I can question your understanding of 'super global' variables! Perhaps use $-POST instead?
 
Joined
Sep 4, 2022
Messages
128
Reaction score
16
to pick a bigger element in your html, you have to pick it by Js first.
as an element could be 'parent' or 'child'.
 
Joined
Jul 4, 2023
Messages
366
Reaction score
41
with $_GET variable in PHP?
Perhaps use $-POST instead?
There is a slight difference between $_GET and $_POST.

  1. $_GET:
    • Data in the $_GET array is passed through the URL's query parameters. For example, if you have a URL like example.com/index.php?name=John&age=25, the data is being sent using the GET method.
    • It's suitable for passing small amounts of data and is often used for requesting data from the server. However, since the data is part of the URL, it can be visible to the user and may have length limitations depending on the browser and server configuration.
  2. $_POST:
    • Data in the $_POST array is sent through the HTTP request body and is not visible in the URL.
    • It's used for sending larger amounts of data and is more secure for transmitting sensitive information like passwords because it's not directly visible in the URL and doesn't have the same length limitations as GET.
but both can be accessed via $_REQUEST.
 
Joined
Aug 22, 2023
Messages
42
Reaction score
7
There is a slight difference between $_GET and $_POST.
I'm afraid you are not understanding what I was suggesting! There is certainly a significant difference between $_GET and $_POST, although I inquired as to if he was familiar with these variables, and if he should experiment to ultimately receive a solution!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top