Cannot display vars in php which was called form shtml

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
PingLeeQuan
Forum Commoner
Posts: 58
Joined: Tue Sep 03, 2002 8:08 am

Cannot display vars in php which was called form shtml

Post by PingLeeQuan »

I have 2 very very simple scripts, 1. is the shtml file and the other is a php file. The index.shtml was huge. for the sake of debugging, I tore it down to a simple form and 2 fields (username and password). on a click of the submit button, I call displayalues.php which is nothing but 3 lines to display the value of username and password which were entered in entered in index.php. How can i get the variable to display or to be transferred to displayvalues.php.... code follows:

index.shtml

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<TITLE>Home</TITLE>
</HEAD>

<BODY>
    <TABLE>
        <TR>
                <FORM NAME="Login" ACTION="./authlib/displayvalues.php" METHOD="POST"
>
                <input type=text name=username2 value="2222">
                <input type=hidden name=mode value=in>
                <br>Username :<input type=text name=username value=wwww>
                <br>Password :<input type=password name=password>
                <p><input type=submit value=Login name=submit>
                </form>
        </TR>
    </TABLE>
</BODY>
</HTML>
displayvalues.php

Code: Select all

<?
//require("backend.php");
 $jack = $_server&#1111;"username"];

print "1- = $jack";
print "2- = $username";
print $_SERVER&#1111;"username"];

?>
it only displays the strings 1- 2- with empty values

Any suggestions?
TIA
--


feyd | :roll: Moved to PHP - Code
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

use code tags provided to post code in forum :!:
using your example :

Code: Select all

<? 
//require("backend.php"); 
$jack = $_POST&#1111;"username"]; 
$pass = $_POST&#1111;"password"];
print "1- = $jack";
print "2- = $pass"; 
?>
For method=POST use $_POST["varname"]
For method=GET use $_GET["varname"]
PingLeeQuan
Forum Commoner
Posts: 58
Joined: Tue Sep 03, 2002 8:08 am

Post by PingLeeQuan »

Thanks n00b Saibot... that was it. Thanks a million...
Post Reply