甜蜜警报到$ _POST

时间:2017-02-23 14:07:28

标签: mysql forms post crud sweetalert

我想使用php / mysql更新数据,但是想成为PHP的新程序员。

我想知道我怎么做:

1-使用带有Sweet Alert的申请表,以便在我点击“编辑”时在我的CRUD中,而不是被重定向到处理,只需一个简单步骤即可替换它?

2-当我点击PHP的$_POST超全局中的按钮时,发送来自此完成表单的数据,以便我能够测试数据并更新我的数据库。

是的,有人能帮帮我吗?以下是crud.php的代码:

<?php

session_start(); // on a besoin des variables de session
include_once("inc/inc_header.php");    
include_once("inc/inc_nav.php");
include_once('connection.php');
include_once('oldconnection.php');
//include_once('../dist/libs/grocery-crud-1.5.8.1/application/libraries/Grocery_CRUD.php');
//include_once('../dist/libs/grocery-crud-1.5.8.1/application/libraries/image_moo.php');
?>

<?php
if(isset($_GET['oneDeleted']) && $_GET['oneDeleted'] == true && isset($_GET['stopUser']))
{ 
?>
<h2>
    <?php 
        extract($_GET); 
        echo $stopUser." a bien ete supprime. ";  
    ?>
</h2>
<?php 
}
?>

<?php
// on recupere les donnees d'obis.
$cruder = $con->prepare("SELECT * FROM user");
$cruder->execute();

$abonnes = $cruder->fetchAll(); // on met ses donnees personnelles dans $mesInfos, elles  serviront en placeholder.
foreach($abonnes as $abonne)
{

    $keepId = $abonne['user_id'];

?>

<?php /*if(isset($_GET['oneDeleted'] && $_GET['oneDeleted'] == true) && isset($_GET['stopuser']))
{ ?>
<h2>
    <?php 
        extract($_GET); 
        echo $stopUser." a bien ete supprime.";  
    ?>
</h2>
<?php }*/ ?>

<br />
<table class="table table-hover table-inverse">
  <thead>
    <tr>
      <th>user_id</th>
      <th>Nom</th>
      <th>Prenom</th>
      <th>Email</th>
      <th>Telephone</th>
      <th>Statut</th>      
      <th>Nombre de reservations</th>
      <th>Derniere visite</th>
      <th>Derniere reservation</th>
      <th>Action</th>

    </tr>
  </thead>
  <tbody>
    <tr>

      <td><?php echo $abonne['user_id']; ?></td>  
      <td><?php echo $abonne['nom']; ?></td>      
      <td><?php echo $abonne['prenom']; ?></td>      
      <td><?php echo $abonne['email']; ?></td>      
      <td><?php echo $abonne['tel']; ?></td>      
      <td>
          <?php 
            $status = $abonne['rights'];           
            if($status == 1)
            {
                echo "Admin";   
            }else
            {
                echo "Visiteur";            
            }            
          ?>
      </td>    
      <td><?php echo $abonne['last_visit']; ?></td>      
      <td><?php echo $abonne['nb_reservation']; ?></td>      
      <td><?php echo $abonne['event_id']; ?></td>      

      <td>


        <a>
            <button type="button" class="btn btn-outline-warning" data-toggle="modal" data-target="#editUserModal">
                Editer
            </button>
        </a>

        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
                </button>
              </div>
              <div class="modal-body">
                ...
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary">Save changes</button>
              </div>
            </div>
          </div>
        </div>


        <button type="button" class="btn btn-outline-danger  btn-outline-warning"
        onclick="swal({
              title: 'AVERTISSEMENT!',
              text: 'CET UTILISATEUR SERA DEFINITIVEMENT SUPPRIME !',
              type: 'warning',
              showCancelButton: true,
              cancelButtonText: 'ANNULER',
              confirmButtonColor: '#DD6B55',
              confirmButtonText: 'OUI, je le supprime.',
              closeOnConfirm: false
            },
            function(){

              timer: 5000;

            document.location.href='deleteUser.php?user_id=<?php echo $keepId; ?>';
            });

            "   
        >
            Supprimer
        </button>




      </td>      
    </tr>    
  </tbody>
</table>
<?php

}


include_once("inc/inc_footer.php");

?>

0 个答案:

没有答案