Hello I have some input but one of them is disabled ( yes and i need it for my time sheet )but how do I send it autocomplete.php to insert.php I've this error Undefined index: client1 in C:\wamp\www\testlp\insert.php on line 30
Here my code autocomplete.php
<form action = 'insert.php' method="post" >
<input type="text" name="client1" class = "client" size="12" id ="client1" disabled />
</form>
here my code insert.php
session_start();
$date = $_POST['data'] ;
$client1 = $_POST['client1'] ;
echo($client1);
echo($date);
EDIT I tried this :
<input type="text" name="client1" class = "client" size="12" id ="client1"readonly />
here the error : Notice: Undefined index: client1 in C:\wamp\www\testlp\insert.php on line 12
If you want it disabled so it does not change in the DB, then you do not have to POST it. Use the SELECT to populate the
<input>
and add the attribute "disabled".use the attribute
readonly
instead ofdisabled
.you get an error because an disabled element is not sent when the form is submitted and thus is not present in
$_POST
(there simply is no$_POST['client1']
in your case)edit edited: the examples were not complete - as the accepted answer states, the
name
attribute must be present, tooor
if you want to have a more xml-like syntax.
Here is an idea of how you can solve this
You can even remove name from the first input.
With this, your disabled input will still be displayed but php will post the value in your hidden input field.
You can use
<?php echo !empty($text)?$text:'';?>
to populate thevalue
fields as shown in some answers hereTLDR;
use the answer from cypherabe: https://stackoverflow.com/a/22990008/2780941