Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable value disapears

Status
Not open for further replies.

Mthales

Technical User
Feb 27, 2004
1,181
GB
I am very new to php so this is probably me just getting something simple wrong but here is my problem.

I have a page with a form that displays records from a database and on this page I have a form with buttons to let the user go on to the next record or back to the previous one. The method I'm trying to employ to do this is using a hidden item in the form that holds the record number. However when the page refreshes following the pushing of a button the record number variable is set but doesn't contain anything.
Could someone please point me to where I'm going wrong?

Here is my code and it's saved in a file called Review.php.
Code:
<?php    
    $scanNo = 1;
    if(isset($_POST['submit']))
    {
        if(isset($_POST['ScanNo'])&& ($_POST['ScanNo']) != "" && ($_POST['ScanNo']) != null)
        {        
            $scanNo = $_Post['ScanNo'];
            if($_POST['submit'] == "Next"){        $scanNo = $scanNo +1;}
            if($_POST['submit'] == "Previous"){    $scanNo = $scanNo -1;}
        }
    }
?>

<html>
<head>
    <title>View database records</Title>
</head>
<body>
<form action="Review.php" method="POST">
                    <input type="hidden" name="ScanNo" value="<?php echo $scanNo; ?>">
                    <input type="submit" name="submit" value ="Next">    
<input type="submit" name="submit" value ="Previous">
                </form>
</body>
</html>

Thanks

M [wiggle]
 
It's this line:

$scanNo = $_Post['ScanNo'];


Variable names are case-sensitive in PHP. $_Post is not the same variable as $_POST.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Yes! Thank you so much for spotting that for me.

M [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top