Jump to content

Archived

This topic is now archived and is closed to further replies.

ScrollMaster

$_POST Woes

Recommended Posts

I was just making a simple test page to see if I could get a variable to carry from one page to another using $_POST but no matter what I attempt I never see the result.

I do not have javascript disabled and I using PHP 5.

Now to show you my code

index.html (The page with one feild)
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="content-type" content="text/html;charset=utf-8" />
        <meta name="generator" content="Notepad++" />
        <title>Post Test</title>
        <link href="css/basic.css" rel="stylesheet" type="text/css" media="all" />
    </head>

    <body>    
        <div class="container">            
                <form id="frm_test" action="results.php" method="POST">
                    <fieldset>    
                        <legend>Use Post!</legend>
                        <input type="text" id="test"/>
                        <input type="submit" id="sbt_results" value="Query"/>
                    </fieldset>                
                </form>
        </div>
    </body>

</html>
[/code]

results.php
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="content-type" content="text/html;charset=utf-8" />
        <meta name="generator" content="Notepad++" />
        <title>Post Results</title>
        <link href="css/basic.css" rel="stylesheet" type="text/css" media="all" />
    </head>

    <body>    
        <div class="container">            
            <?php
                $test = $_POST['test'];
                echo $test;
            ?>
        </div>
    </body>
</html>
[/code]

Am I forgetting something?

EDIT: SOLVED!
I have spent too much time not knowing what was wrong when I thought of adding in the NAME attribute and not everything works. I did not know name was responsible as the variable.

I think this confusion all lead because of the new 1.1 Strict standards. Name is no longer used in 1.1 and if you have it in validation your page will fail. Even though I do not use the 1.1 Strict bceause 1.0 Strict the the current standard being use I had in mind to omit it anyway always because it would not be used in the future.

Share this post


Link to post
Share on other sites
[code] <input type="submit" id="sbt_results" value="Query"/> [/code]

try changing "id" to "name"

EDIT -> looks like I type too slow ;)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.