1

I want to have a pop-up message when the user has successfully submitted a registration form. But being a newbie in PHP, I'm having a hard time with some validations. Need help :( Here's my code.

my buttons here <div class="row">
<div class="col-lg-12" style="text-align: center;">
<input class="btn btn-success" type="submit" value="<?php echo __('Register'); ?>"/>
<input class="btn btn-warning" type="reset" value="<?php echo __('Reset');?>"/>
<input class="btn btn-danger" type="button" value="<?php echo __('Cancel'); ?>" onclick="javascript:
    window.location.href='index.php';"/>
</div>

enter code <div class="modal fade success-popup" id="success" tabindex="-1" role="dialog" aria-labelledby="modal-label" style="transition: .3s ease all;"><div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">x</span></button>
    <h4 class="modal-title" id="modal-label">Thank You!</h4>
  </div>
  <div class="modal-body text-center">
    <i class="fa fa-check" aria-hidden="true" style="border-radius: 50%; font-size: 35px;"></i>
    <p class="lead">Registration form successfully submitted.</p>
    <a href="index.php" class="btn btn-default" style="text-decoration: none;">Go To Home</a>
  </div>
</div>

The modal is what I want to show after the code is validated and the user submitted the form successfully.

Gerard
  • 15,418
  • 5
  • 30
  • 52
nesi
  • 39
  • 2
  • 4
  • 1
    Welcome to Stack Overflow! Can you elaborate on how your code "doesn't work"? What were you expecting, and what actually happened? If you got an exception/error, post the line it occurred on and the exception/error details. Please [edit] these details in or we may not be able to help. – Blue Jun 20 '17 at 02:29
  • http://getbootstrap.com/javascript/#modals – Jason Bassett Jun 20 '17 at 04:18

2 Answers2

0
There are various methods to show the popup after registration. You can set it on the session or you can return '1' for the successful registration in your php file.
//example 1
if(insert_query){
return '1';
}

//example 2
if(insert_query){
 session_start();
 $_SESSION['registration_success']='1';
}
PHP Geek
  • 3,949
  • 1
  • 16
  • 32
0

I tell you a standard approach which works everywhere not just your current code so you can master such issues.

In you server side function you should return a flag i.e a number or text for success and error

// success
if($success)
    return 1
else
    return 0

then in you ajax request check what the server response.

You asked about validation but i didn't really get that. Do you mean form validation or something ? lets do some basics:

<?php

if( $_POST['your_input'] == 'your value' )
    return 1
else
    return 0

Where $_POST['your_input'] is the data sent from client and 'your value' is the value to test against.

Your question is somehow vague. I hope it helps and feel free to comment here if you steel need help :)