Reputation: 91
Please see the following simple code.
<?php
$a = $_POST['a'];
$b = $_POST['b'];
$c = $_POST['c'];
$d = $_POST['d'];
$e = $_POST['e'];
...... ?>
And in html
file we have only the following fields:
<form action="file.php" method="POST">
<p>A</p> <input type="text" name="a">
<p>B</p> <input type="text" name="b">
</form>
the above html
code we have only two fields but in the php
file we have several $_POST[]
variables and the global variables are more than the fields in html
code. Now I want to know the additional $_POST[]
variables values.
Is the value as the ""
(empty string)? Does the web server crash? Perhaps my question is simple but it is for me ambiguous.
Upvotes: 1
Views: 94
Reputation: 3013
The $_POST['c']
,... are not set so you get a NOTICE
. (Their value are null
)
it is better to change your code to something like:
if(isset($_POST['c'])) $c=$_POST['c']; else $c='';
or
$c=isset($_POST['c'])?$_POST['c']:'';
Upvotes: 0
Reputation: 715
The first thing you need to check : var_dump($_POST)
are
$_POST['c'];
$_POST['d'];
$_POST['e'];
empty? or may be c,d,e
are hidden variable sent from that form.
if your form is not sending c,d,e
you'll most probabely going to get Notice: Undefined index: in
if not , remove those variables
Upvotes: 1
Reputation: 2528
See $_POST
is a global variable but its a array.
when you submit your form via POST method
then you get post variable with a limited time period as the page changes all your previous post variable are gone.
If you are posting a form
see all post data using
print_r($_POST);
or
var_dump($_POST);
it gives a human readable array of post data. which will tell you what is in $_POST
Upvotes: 0
Reputation: 2500
To know any variable status try var_dump:
var_dump($_POST['d']);
will output what you need.
Upvotes: 1