By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,613 Members | 1,890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,613 IT Pros & Developers. It's quick & easy.

Value of $_POST variable is null, but shouldn't be.

P: 5
hi everyone,
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.  $CompanyName=$_POST['CompanyName'];
  3.  echo $CompanyName;
  4. ?>
[Please use CODE tags when posting your code. Thanks! --pbmods]

I have been using this code to get values from forms.It was working fine.But lately it is not getting what has been entered in the field named CompanyName.
It displays nothing.
May 18 '07 #1
Share this Question
Share on Google+
6 Replies


shidec
P: 26
can u write down the form code?
May 18 '07 #2

pbmods
Expert 5K+
P: 5,821
Changed thread topic to better match contents.

Is your form using POST or GET to send its contents? Try checking for:

Expand|Select|Wrap|Line Numbers
  1. echo "Get: $_GET[CompanyName]<br />";
  2.  
May 18 '07 #3

P: 5
I have tried both GET as well as POST method in my form.In both cases, it displayed nothing.The same code is working fine on my friends computer.But doesnt work on my computer.
May 19 '07 #4

pbmods
Expert 5K+
P: 5,821
Hm. Couple of things I would try.

First thing, I would set error_reporting to E_ALL:
Expand|Select|Wrap|Line Numbers
  1. error_reporting(E_ALL);
  2.  
This will display NOTICE and STRICT errors that are normally turned off by default.

Also, try this:
Expand|Select|Wrap|Line Numbers
  1. print_r($GLOBALS);
  2. // Or...
  3. print('<pre>' . print_r($GLOBALS, true) . '</pre>');
  4.  
This will output your entire $GLOBALS array, which includes $_GET, $_POST, etc. If your input made it to your script, it'll be in here somewhere.

If not, take a look at this thread.
May 19 '07 #5

P: 1
srf
Getting an error when logging in

Parse error: parse error, unexpected T_STRING in /home/content/a/z/r/azreff/html/login.php on line 18


//Connect to database

mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

session_start();
$username = $_POST['username'];
$password = md5($_POST['password']);
$query = “select * from users where username=’$username’ and password=’$password’”;

$result = mysql_query($query);

if (mysql_num_rows($result) != 1) {
$error = “Bad Login”;
include “login.html”;

} else {
$_SESSION[‘username’] = “$username”;
include “memberspage.php”;
}

?>
May 20 '07 #6

P: 5
As per your suggestion,I did error_reporting(E_ALL); and print_r($GLOBALS),
the array displayed the values passed on by the form.
But it displayed warning:Undefined variable: _REQUEST and Use of undefined constant .
May 20 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.