Form POST PHP. Notice: Undefined index:

6

I have a problem when it comes to getting the values of a form using the POST method to a PHP.

The form is in a modal window created with BootStrap:

<form action='../php/editCardPatient.php' method='POST' role="form" data-toggle="validator">
<div class="row form-group">
    <div class="col-xs-6 col-sm-6">
        <label for="inputName" class="control-label">Nombre</label>
        <input name='name' type="text" class="form-control" id="name" value="<?php 
            if(isset($_SESSION["name_patient"])) {
                echo $_SESSION["name_patient"];
            }?>" required disabled>
    </div>
</div>

<div class="modal-footer" id='buttonAccept' style="display: none;">
    <button type="button" class="btn btn-primary" onclick="funcionCancelCard()">Cancelar</button>
    <button type='submit' value='EditAcc' class="btn btn-primary" onclick="funcionButtons()">Aceptar</button>
</div></form>

And in the file editCardPatient.php the first thing I do is declare the variables:

/* Recogemos las variables introducidas en el formulario de patientCard.php */
$nameCardPatient     = trim($_POST['name']);

/* Creamos la conexión BD */
include("../php/conectionBD.php");
session_start();

The problem is that on the page, when I press the button to send the form I get an error on the PHP page:

Do you think it could be?

    
asked by JCarlos Balaguer 15.02.2016 в 21:26
source

1 answer

8

The problem is that the field is disabled, the disabled fields are not sent by the form. Instead of disabling it you can only put it in "read mode".

<input name='name' type="text" class="form-control" id="name" value="<?php 
            if(isset($_SESSION["name_patient"])) {
                echo $_SESSION["name_patient"];
            }?>" required readonly="readonly">
    
answered by 15.02.2016 / 21:51
source