0

I have two pages:

Page1.php (Portion of Code)

<a href="clienteEvolucionAgregar.php?rutCompleto='  . $rutCompleto    . 
                                                    '&rut='  . $rut  . 
                                                    '&dv='   . $dv   . 

I am successfuly getting that value in page clienteEvolucionAgregar.php, the code from this page is below: clienteEvolucionAgregar.php

<?php
    if(isSet($_POST['Ingresar']))
    {
        echo "<br>". "recibeRUT={" . $recibeRUT ."}";
        echo "<br>". "recibeDV={" . $recibeDV ."}";
    }
    $inputFechaEvolucion_error = $txtEvolucion_error = '';
    $recibeRUT = $_GET['rut'];
    $recibeDv  = $_GET['dv'];
?>
<html>
    <head>
        <title>Search Client</title>
    </head>
    <body>
        <br><a href="clienteAdd.php">Agregar Paciente</a>
        <br><a href="clienteSearch.php">Buscar Paciente</a>
        <div id="divAgenda"> 
        <form id="contact" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
            <fieldset>
                <input disabled id="recibeRUT" name="recibeRUT" type="text" tabindex="1" size="15" maxlength="8"
                       value="<?= $recibeRUT ?>" > 
                       -
                <input disabled id="recibeDv" name="recibeDv" type="text" tabindex="2" size="1" maxlength="1"
                       value="<?= $recibeDv ?>" ><br>
            </fieldset>
            <fieldset>
                <span class="error"><?= $inputFechaEvolucion_error ?></span><br>
                Fecha Evolución...<br>
                <input id='inputFechaEvolucion' name='inputFechaEvolucion' type='date' tabindex='3' maxlength='100' max='2999-01-01' min='1900-01-01' placeholder='Fecha Evolución...'
                       value="<?= $inputFechaEvolucion ?>" > 
            </fieldset>
            <fieldset>
                <span class="error"><?= $txtEvolucion_error ?></span><br>
                <textarea id="txtEvolucion" value="<?= $txtEvolucion ?>" name="txtEvolucion"  tabindex="2" cols="90" rows="7"><?= $txtEvolucion ?></textarea><br><br>
            </fieldset>
            <fieldset>
                <button type="Ingresar" value="Submit">Ingresar</button>
                </button><br><br>
            </fieldset>
        </form>
    </body>
</html>

I am reciving those two variables in $recibeRUT and $recibeDv and let them in two input fields. Now I want to make some validation with with inputs id "inputFechaEvolucion" and "txtEvolucion" and also variables $recibeRUT and $recibeDv. My problem is when I press the button it seams like my 2 variables ($recibeRUT and $recibeDv) got lost because it is not entering in this condition:

if(isSet($_POST['Ingresar']))

I have disabled inputs with ids recibeRUT and recibeDv because I don't want to be changed by the user. I also tried not disabling them but also the same issue is ocurring.

Could you please guide me to solve my problem, please? I just want to preserve the content of those two variables after pressing submit button.

Screenshot from my site

Shadow
  • 33,525
  • 10
  • 51
  • 64
felipe
  • 101
  • 1
  • 2
  • 9

1 Answers1

0

disable input will not submit data

try to change the inputs "disable" with "readonly"

<input readonly id="recibeRUT" name="recibeRUT" type="text" tabindex="1" size="15" maxlength="8"
                   value="<?= $recibeRUT ?>" > 
                   -
<input readonly id="recibeDv" name="recibeDv" type="text" tabindex="2" size="1" maxlength="1"
                   value="<?= $recibeDv ?>" ><br>

Also

echo "<br>". "recibeRUT={" . $_POST["recibeRUT"] ."}";
echo "<br>". "recibeDV={" . $_POST["recibeDv"]."}";

and in order to send post to the same page there is not need to get the page

 <form id="contact" action="" method="post">

Entire code:

<?php
    if(isset($_POST["recibeRUT"]) && isset($_POST["recibeDv"]))
    {
      echo "<br>". "recibeRUT={" . $_POST["recibeRUT"] ."}";
      echo "<br>". "recibeDV={" . $_POST["recibeDv"]."}";
    }

    $inputFechaEvolucion_error = $txtEvolucion_error = '';
    $recibeRUT = $_GET['rut'];
    $recibeDv  = $_GET['dv'];
?>
<html>
    <head>
        <title>Search Client</title>
    </head>
    <body>
        <br><a href="clienteAdd.php">Agregar Paciente</a>
        <br><a href="clienteSearch.php">Buscar Paciente</a>
        <div id="divAgenda">
        <form id="contact" action="" method="post">
            <fieldset>
                <input readonly id="recibeRUT" name="recibeRUT" type="text" tabindex="1" size="15" maxlength="8"
                       value="<?= $recibeRUT ?>" >
                       -
                <input readonly id="recibeDv" name="recibeDv" type="text" tabindex="2" size="1" maxlength="1"
                       value="<?= $recibeDv ?>" ><br>
            </fieldset>
            <fieldset>
                <span class="error"><?= $inputFechaEvolucion_error ?></span><br>
                Fecha Evolución...<br>
                <input id='inputFechaEvolucion' name='inputFechaEvolucion' type='date' tabindex='3' maxlength='100' max='2999-01-01' min='1900-01-01' placeholder='Fecha Evolución...'
                       value="<?= $inputFechaEvolucion ?>" >
            </fieldset>
            <fieldset>
                <span class="error"><?= $txtEvolucion_error ?></span><br>
                <textarea id="txtEvolucion" value="<?= $txtEvolucion ?>" name="txtEvolucion"  tabindex="2" cols="90" rows="7"><?= $txtEvolucion ?></textarea><br><br>
            </fieldset>
            <fieldset>
                <button type="Ingresar" value="Submit">Ingresar</button>
                </button><br><br>
            </fieldset>
        </form>
    </body>
</html>
Ricardo
  • 1,308
  • 1
  • 10
  • 21
  • 2
    PHP language constructs are not case sensitive. https://stackoverflow.com/questions/33273941/php-case-sensitivity – Don't Panic Apr 06 '18 at 21:26
  • 2
    It's always best to use the canonical capitalization, `isset` in this case, but it's not strictly necessary. – tadman Apr 06 '18 at 21:33
  • I didn't know that, thanks guys. – Ricardo Apr 06 '18 at 22:01
  • Thank you so much for your answer Ricardo, it was very helpful for me, and it is working just fine. I have just voted your answer. Also thank you very much to Don't Panic and Tadman, I will be using isset from now on :) – felipe Apr 07 '18 at 03:22