Jump to content

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.
Link to comment
https://forums.phpfreaks.com/topic/6918-_post-woes/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.