Brite Roy
Brite Roy

Reputation: 425

$_POST not showing results

I'm using the simple following code to create a form and receive its values in another page:

firstpage.php

<form action="checklogin.php" method="post" >
<table border=1>
<tr><td>Username </td><td><input type="text" name="txtuser" /></td></tr>
<tr><td>Password </td><td><input type="text" name="txtpwd" /></br>
</td></tr>
<tr><td><input type="submit" value="Login now"  name="btnsub"/>
</table> 
</form>

checklogin.php

<html>
<body>
Welcome <?php echo $_POST['txtuser']; ?>
</body>
</html>

This code does not show the value of the input txtuser in the nxtpage.php in all browsers.

Upvotes: 1

Views: 2305

Answers (3)

nunu
nunu

Reputation: 2871

Read this passing variable to another page.

Upvotes: 0

Shadikka
Shadikka

Reputation: 4286

Is your form target checklogin.php or nxtpage.php? Since if it is checklogin.php, quite naturally nxtpage.php will not receive the POST variables sent to checklogin.php.

Unless you're just doing something very simple, you want to use sessions - for example, see this tutorial about sessions.

Upvotes: 0

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799190

You're POSTing to checklogin.php. Of course nextpage.php won't have the POST value. Try sticking it in the session.

Upvotes: 3

Related Questions