6 votes

Form POST PHP. Notice: Undefined index:

I have a problem to obtain 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 to 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 in the page, when I press the button to submit the form I get an error on the PHP page:

introducir la descripción de la imagen aquí

Do you know that you can be?

8voto

moscoquera Points 649

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">
 

HolaDevs.com

HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

Powered by:

X