Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

352
Vistas
How show a confirmation message at php form submit which contains a dynamic message text?

I want to show a confirmation message at form submit with a confirmation message. Confirmation message itself needs to do some php calls in order to do some validations and then show a message with ok and cancel buttons. Upon pressing ok button, it should continue with submit flow and remain in the form otherwise.

I have taken following approach but it doesn't work. Even though it goes into else block it doesn't show the message. Seems like the second echo line is the problem. Can you give me a clue on how to accomplish this task?

PHP code:

<?php 
    if (!empty($_POST)){
        // read $_POST['item'] values and do the validation and construct validation message.
        // Because validation message is a dynamic one which is based on user inputs. 
        // Some server calls are also needs to make within this validation phase.
        
        if(empty($validation_msg)) {
            saveData();
        }
        else {
            echo '<script type="text/javascript"> if (confirm("' . $validation_msg . '")) { ';
            echo saveData(); 
            echo ' } </script>'; 
        }
    }
    
    function saveData(){
        // Save function goes here.
    }
?>

HTML code:

<div class="form-group">
    <button type="submit" class="btn btn-primary" id="submit_button" disabled><?= _('Save') ?></button>
</div>
about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda