Jump to content


Photo

$_POST Woes


  • Please log in to reply
1 reply to this topic

#1 ScrollMaster

ScrollMaster
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 09 April 2006 - 02:17 AM

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)
<!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>

results.php
<!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>

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.

#2 earl_dc10

earl_dc10
  • Members
  • PipPipPip
  • Advanced Member
  • 71 posts

Posted 09 April 2006 - 02:22 AM

<input type="submit" id="sbt_results" value="Query"/>

try changing "id" to "name"

EDIT -> looks like I type too slow ;)
got a problem? Google helps many of those in need




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users