Google
Edit File: merchant.php
<?php include 'session.php'; error_reporting(0); include 'reader.php'; //$dbl = new ConDB(); $sessionQuery = "select username from admin_pass"; //$sessionResult = mysql_query($accQry, $db1->conn); if(!$sessionResult = $db1->db->query($sessionQuery)){ die('There was an error running the query [' . $db1->db->error . ']'); } $row = $sessionResult->fetch_assoc(); //$row = mysql_fetch_assoc($sessionResult); //if ($row['session'] == $_SESSION["keys"]) { //} else { //$row = $sessionResult->fetch_assoc(); /* if ($row['username'] == $_SESSION["keys"]) { } else { // header("Location: login.php"); } */ if (isset($_POST["merchant_edit"])) { $merchant_id = $_POST["merchant_name"]; $merchant_email = $_POST["email_name"]; $merchant_password =$_POST["password_name"]; $merchant_brand_name =$_POST["brand_name"]; $event_id1 = $_POST['event_name1']; $phone = $_POST['phone']; $uploaddir = './uploads/'; $filename = basename($_FILES['upload']['name']); $raw = $uploaddir . $filename; if (move_uploaded_file($_FILES['upload']['tmp_name'], $raw)) { // $url = "http://localhost/pinaccle".$raw; $url = "http://".$_SERVER['HTTP_HOST']."/admin/pinaccle/".$raw; } $accQry = "update merchant set merchant_email='$merchant_email',merchant_password='$merchant_password',merchant_brand_name='$merchant_brand_name',event_id ='$event_id1',phone='$phone', modified_dt=NOW() where merchant_id ='$merchant_id'"; // $result1 = mysql_query($accQry, $db1->conn) ; if(!$result = $db1->db->query($accQry)){ die('There was an error running the query [' . $dbl->db->error . ']'); } // if(mysql_insert_id() > 0){ // $txt = "Merchant Created Successfully"; // echo "<script type=\"text/javascript\">alert('".$txt."');</script>"; $txt = "Merchant Updated Successfully"; echo "<script type=\"text/javascript\">alert('".$txt."');</script>"; } if (isset($_POST["merchant_add"])) { $merchant_id1 = $_POST["merchant_name1"]; $merchant_email1 = $_POST["email_name1"]; $merchant_password1 =$_POST["password_name1"]; $merchant_brand_name1 =$_POST["brand_name1"]; $event_name_new = $_POST['event_name']; $phone = $_POST['phone']; $uploaddir = 'uploads/'; $filename = basename($_FILES['pic']['name']); $raw = $uploaddir . $filename; if (move_uploaded_file($_FILES['pic']['tmp_name'], $raw)) { $url = "http://".$_SERVER['HTTP_HOST']."/admin/pinaccle/".$raw; } $accQry1 = "insert into merchant(merchant_email,merchant_password,merchant_brand_name,phone,created_dt,modified_dt,state,event_id) values('$merchant_email1','$merchant_password1','$merchant_brand_name1','$phone',NOW(),NOW(),1,$event_name_new)"; // $result1 = mysql_query($accQry1, $db1->conn) ; if(!$result1 = $db1->db->query($accQry1)){ die('There was an error running the query [' . $dbl->db->error . ']'); } $txt = "Merchant Added Successfully"; echo "<script type=\"text/javascript\">alert('".$txt."');</script>"; // echo "<script>alert('Password Changed')</script>"; // header('location:merchant.php'); // echo 'window.location= "index.php"'; // echo ("<SCRIPT LANGUAGE='JavaScript'> // window.location.href='http://merchant.php'; // </SCRIPT>"); } ?> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Merchant</title> <link type="text/css" href="css/bootstrap.min.css" rel="stylesheet"> <link type="text/css" href="css/bootstrap-responsive.min.css" rel="stylesheet"> <link type="text/css" href="css/theme.css" rel="stylesheet"> <link type="text/css" href="images/icons/css/font-awesome.css" rel="stylesheet"> <link type="text/css" href='https://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600' rel='stylesheet'> <link type="text/css" href="css/admin_menu_edit.css" rel="stylesheet"> <link type="text/css" href="css/switch.css" rel="stylesheet"> <style type="text/css"> #merchant_id{ color:#fff; }a:focus,a:hover{ color:black; text-decoration:none; } .dropdown-menu>li{ float:none; } </style> <style> .close { color: #000000; opacity: 1; } </style> </head> <body> <div class="navbar navbar-fixed-top"> <div class="navbar-inner"> <div class="container" style="min-height: 50px;"> <a class="brand" href="merchant.php"> Pinnacle </a> <ul style="list-style-type: none;text-decoration:none;color:black;float:right;padding-top:10px;"> <li class="dropdown" style="padding-top:10px;"> <a class="dropdown-toggle" role="button" data-toggle="dropdown" href="#" style="color:black;"> <b><?php echo $login_session; ?></b><span class="caret"></span></a> <ul id="g-account-menu" class="dropdown-menu" role="menu"> <li><a href="logout.php">Logout</a></li> </ul> </li> </ul> <a class="brand" href="change_password.php" style ="float:right;font-size:13px" > Change Password </a> </div> </div><!-- /navbar-inner --> </div><!-- /navbar --> <div class="wrapper"> <div class="container"> <div class="row"> <div> <?php include ('menu.php'); ?> </div> </div><br /> <div class="row"> <div> <div class="content"> <div class="module"> <div class="module-head"> <h3>Merchants</h3> <a href="javascript:void(0);" data-toggle="modal" data-target="#myModal" class="newbuttontyle">Add New</a> </div> <div class="module"> <div class="module-head"> </div> <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <br> <div class=" col-sm-10 col-sm-offset-2" align="center"> <h4 id="myModalLabel">Add Merchant Details</h4></div> </div> <div class="form-group col-sm-10 col-sm-offset-2" align="center"> <form action="" method ="post" enctype="multipart/form-data"> <br> <div class="form-group" id ="form1" > <label class="control-label" for="name">Merchant Email:</label> <input type="email" class="form-control" id="email" placeholder="Email" name="email_name1" required> </div> <div class="form-group" id ="form2"> <label class="control-label" for="email">Password:</label> <input type="password" class="form-control" id="password" placeholder="Password" name="password_name1" required> </div> <div class="form-group" id ="form2"> <label class="control-label" for="phone">Phone:</label> <input type="tel" name="phone" pattern="[0-9]{10}" class="form-control" id="phone" placeholder="Phone" name="phone" required > </div> <div class="form-group" id ="form2"> <label class="control-label" for="email">Brand Name:</label> <input type="text" class="form-control" id="brand" placeholder="Brand Name" name="brand_name1"> </div> <div class="form-group" id ="form2"> <label class="control-label" for="email">Event Id:</label> <input type="text" class="form-control" id="event_id" placeholder="Event Id" name="event_name" required > </div> <br> <button type="submit" name="merchant_add" class="btn btn-default col-sm-12" style="width:40%;">Add New Merchant</button> <br><br><br><br><br><br> </form> </div> </div> <div id="myModal1" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <br> <div class=" col-sm-10 col-sm-offset-2" align="center"> <h4 id="myModalLabel">Edit Merchant Details</h4></div> </div> <div class="form-group col-sm-10 col-sm-offset-2" align="center"> <form action="" method ="post" enctype="multipart/form-data"> <div class="form-group" id ="form1"> <label class="control-label" for="name"></label> <input type="text" class="form-control" id="merchant_id_id" placeholder="Email" name="merchant_name" > </div> <div class="form-group" id ="form1"> <label class="control-label" for="name">Merchant Email:</label> <input type="text" class="form-control" id="email_id" placeholder="Email" name="email_name" required > </div> <div class="form-group" id ="form2"> <label class="control-label" for="email">Password:</label> <input type="text" class="form-control" id="password_id" placeholder="Password" name="password_name" required > </div> <div class="form-group" id ="form2"> <label class="control-label" for="email">Phone:</label> <input type="tel" name="phone" pattern="[0-9]{10}" class="form-control" id="e_phone" placeholder="Phone" required > </div> <div class="form-group" id ="form2"> <label class="control-label" for="email">Brand Name:</label> <input type="text" class="form-control" id="brand_id" placeholder="Brand Name" name="brand_name"> </div> <div class="form-group" id ="form2"> <label class="control-label" for="email">Event Id:</label> <input type="text" class="form-control" id="e_event_id" placeholder="Event Id" name="event_name1"> </div> <br> <button type="submit" name="merchant_edit" class="btn btn-default col-sm-12" style="width:40%;">Update Merchant Details</button> <br><br><br><br><br><br> </form> </div> </div> <div class="module-body table"> <table cellpadding="0" cellspacing="0" border="0" class="datatable-1 table table-bordered table-striped display" width="100%"> <thead> <tr> <th>Sl No:</th> <th>Merchant Id</th> <th>Merchant Email </th> <th>Phone</th> <th>Password</th> <th>Merchant Brand Name</th> <th>State</th> <th>Created Date</th> <th>Modified Date </th> <th>Event_Id</th> <th>Edit</th> </tr> </thead> <tbody> <?php $accQry2 = "select * from merchant"; // $result1 = mysql_query($accQry, $db1->conn) ; if(!$result2 = $db1->db->query($accQry2)){ die('There was an error running the query [' . $db->db->error . ']'); } $i = 1; while ($row = $result2->fetch_assoc()) { ?> <tr id="doc_rows" > <td class="center"><?Php echo $i ?></td> <td class="center"><?Php if($row['merchant_id'] != NULL){echo $row['merchant_id'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['merchant_email'] != NULL){echo $row['merchant_email'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['phone'] != 0){echo $row['phone'];}else{echo "0000000000";} ?></td> <td class="center"><?Php if($row['merchant_password'] != NULL){echo $row['merchant_password'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['merchant_brand_name'] != NULL){echo $row['merchant_brand_name'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['state'] != NULL){echo $row['state'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['created_dt'] != NULL){echo $row['created_dt'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['modified_dt'] != NULL){echo $row['modified_dt'];}else{echo "-";} ?></td> <td class="center"><?Php if($row['event_id'] != NULL){echo $row['event_id'];}else{echo "-";} ?></td> <td class="center"><button id="button_id" style="color:white;background-color:#b0ca95;" onclick="myFunction(<?Php echo "'".$row['merchant_id']."','".$row['merchant_email']."','".$row['merchant_password']."','".$row['merchant_brand_name']."','".$row['phone']."','".$row['event_id']."' " ?>)">Edit Merchant</button></td> </tr> <?php $i++; } ?> </tbody> </table> </div> </div><!--/.module--> <br /> </div><!--/.content--> </div><!--/.span9--> </div> </div><!--/.container--> </div><!--/.wrapper--> <script src="scripts/jquery-1.9.1.min.js"></script> <script src="scripts/jquery-ui-1.10.1.custom.min.js"></script> <script src="js/bootstrap.min.js"></script> <script src="scripts/datatables/jquery.dataTables.js"></script> <script> $(document).ready(function() { $('.datatable-1').dataTable(); $('.dataTables_paginate').addClass("btn-group datatable-pagination"); $('.dataTables_paginate > a').wrapInner('<span />'); $('.dataTables_paginate > a:first-child').append('<i class="icon-chevron-left shaded"></i>'); $('.dataTables_paginate > a:last-child').append('<i class="icon-chevron-right shaded"></i>'); } ); $('#myModal').on('show', function() { var tit = $('.confirm-delete').data('title'); $('#myModal .modal-body p').html("Desea eliminar al usuario " + '<b>' + tit +'</b>' + ' ?'); var id = $(this).data('id'), removeBtn = $(this).find('.danger'); }) $('.confirm-delete').on('click', function(e) { e.preventDefault(); var id = $(this).data('id'); $('#myModal').data('id', id).modal('show'); }); function myFunction(merchant_id,merchant_email,password,merchant_brand,phone,event_id) { document.getElementById("merchant_id_id").value=merchant_id; document.getElementById("email_id").value=merchant_email; document.getElementById("password_id").value=password; document.getElementById("brand_id").value=merchant_brand; document.getElementById("e_event_id").value=event_id; document.getElementById("e_phone").value=phone; $('#myModal1').modal('show'); document.getElementById("merchant_id_id").style.display="none"; // document.getElementById("form2").style.display="none"; } </script> </body> </html>