Jump to content

carlitosfigue

New Members
  • Posts

    3
  • Joined

  • Last visited

carlitosfigue's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I am having troubles trying to add View/Edit/Del options to my web system modules. I am not the creator of the web system so it's complicated for me, also, I am a newbie on this. I want to be able to view/edit/del from admin panel every product or client stored in my db. Here's the Clients module code: client.html <div ng-include="'views/menu.html'"> </div> <button type="button" class="btn btn-primary" ng-model = 'newProduct' ng-click = 'newProductButton()'>{{buttonName}}</button> <hr> <div class="table-responsive" ng-show ='!newProduct'> <table class="table table-striped table-hover"> <tr> <td>Nº</td> <td>Cédula</td> <td>Nombre</td> <td>Apellido</td> <td>Dirección</td> <td>Email</td> <td>Télefono</td> </tr> <tr ng-repeat= 'client in clients track by $index'> <td>{{$index + 1}}</td> <td>{{client.codigo}}</td> <td>{{client.nombre}}</td> <td>{{client.apellido}}</td> <td>{{client.direccion}}</td> <td>{{client.email}}</td> <td>{{client.telefono}}</td> </tr> </table> </div> <div ng-show = 'newProduct'> <form role="form" ng-submit ="updateClient (id,name,lastName,address,phoneNumber,email)"> <label>Cédula</label> <div class="form-group"> <input class="form-control" placeholder="Cédula" ng-model='id' id="id"> </div> <label>Nombre</label> <div class="form-group"> <input class="form-control" placeholder="Nombre" ng-model='name' id="sname"> </div> <label>Apellido</label> <div class="form-group"> <input class="form-control" placeholder="Apellido" ng-model='lastName' id="lastName"> </div> <label>Dirección</label> <div class="form-group"> <input class="form-control" placeholder="Dirección" ng-model='address' id="address"> </div> <label>Teléfono</label> <div class="form-group"> <input type='tel' class="form-control" placeholder="Teléfono" ng-model='phoneNumber' id="phoneNumber"> </div> <label>Email</label> <div class="form-group"> <input type='email'class="form-control" placeholder="Email" ng-model='email' id="email"> </div> <div class="alert alert-success" id='alertSuccess' style="display:none">Ingresado Satisfactoriamente...</div> <div class="alert alert-danger" id='alertDanger' style="display:none">Ese cliente ya fue agregado</div> <button type="submit" class="btn btn-primary">Agregar Cliente</button> </form> </div> client.js 'use strict'; /** * @ngdoc function * @name belkitaerpApp.controller:ClientCtrl * @description * # ClientCtrl * Controller of the belkitaerpApp */ angular.module('belkitaerpApp') .controller('ClientCtrl', function ($scope,$http) { $scope.newProduct = false; if($scope.newProduct){ $scope.buttonName = 'Ver Tabla'; } else{ $scope.buttonName = 'Ingresar Cliente'; } $http.get('../serverSide/clients.php').success(function(clients){ console.log(clients); $scope.clients = clients.Clients; }) $scope.newProductButton = function(){ $scope.newProduct = !$scope.newProduct; if($scope.newProduct){ $scope.buttonName = 'Ver Tabla'; } else{ $scope.buttonName = 'Ingresar Cliente'; } } $scope.updateClient = function(id,name,lastName,address,phoneNumber,email){ $http.post('../serverSide/updateClient.php',{id:id,name:name,lastName:lastName,address:address,phoneNumber:phoneNumber,email:email}).success(function(data){ console.log(data); $('#alertSuccess').show("slow"); setTimeout(function() { $('#alertSuccess').hide('slow'); }, 3000); }).error(function(data){ console.log(data); $('<div id="alertDanger"></div>').show("slow"); setTimeout(function() { $('<div id="alertDanger"></div>').hide('slow'); }, 3000); }) } }); client.php <?php require_once 'database.php'; $db = new Database(); $clients = $db->queryAll('SELECT clie_id as id,clie_cod as codigo, clie_ape as apellido, clie_nom as nombre, clie_dir as direccion, clie_ema as email, clie_tel as telefono FROM cliente','Clients'); echo json_encode($clients); ?> I have found a php code on the web and I was wondering if it was possible to merge it with my existing one. I tested the code with my db and it's working but I do not know how to merge it with my existing code. Here's the code: <?php if (isset($_POST['submit'])) { include 'db.php'; $clie_cod=$_POST['clie_cod'] ; $clie_ape= $_POST['clie_ape'] ; $clie_nom=$_POST['clie_nom'] ; $clie_dir=$_POST['clie_dir'] ; mysql_query("INSERT INTO `cliente`(Código,Apellido,Nombre,Dirección) VALUES ('$clie_cod','$clie_ape','$clie_nom','$clie_dir')"); } ?> </form> <table border="1"> <?php include("db.php"); $result=mysql_query("SELECT * FROM cliente"); while($test = mysql_fetch_array($result)) { $id = $test['clie_id']; echo "<tr align='center'>"; echo"<td><font color='black'>" .$test['clie_id']."</font></td>"; echo"<td><font color='black'>" .$test['clie_cod']."</font></td>"; echo"<td><font color='black'>". $test['clie_ape']. "</font></td>"; echo"<td><font color='black'>". $test['clie_nom']. "</font></td>"; echo"<td><font color='black'>". $test['clie_dir']. "</font></td>"; echo"<td> <a href ='view.php?clie_id=$id'>Edit</a>"; echo"<td> <a href ='del.php?clie_id=$id'><center>Delete</center></a>"; echo "</tr>"; } mysql_close($conn); ?> </table> </body> </html> Any help would be highly appreciated. Thank you very much.
  2. Hello DavidAm, turns out I had and old version of Xampp. Updated it and got it to work, a php problem I think. Thank you very much.
  3. Hello guys, first post here. I have a web system which contains a login form programmed in 3 different languages HTML, PHP and JS. The problem is that it's not working, you can access without entering any data, you just press enter and it will work, I don't know why it is not validating any credentials. I was thinking about some query problems but I don't know. I am a newbie on this. I have read a lot but haven't found an answer. A friend helped me build the system but left that uncompleted and he's nowhere to be found. I was wondering if you could help me out with this. <form role="form" ng-submit="login(user,password)"> <div class="form-group"> <input type="user" class="form-control" ng-model='user' placeholder="Usuario"> </div> <div class="form-group"> <input type="password" class="form-control" ng-model='password' placeholder="Contraseña"> </div> <div class="alert alert-warning" id='alert' style="display:none">Revise la informacion...</div> <div class="alert alert-danger" style="display:none" id='alertErr'>Error Usuario o Contraseña Erronea intentelo de nuevo</div> <button type="submit" class="btn btn-primary">Ingresar</button> </form> <?php require_once 'database.php'; $db = new Database(); $body = json_decode(file_get_contents('php://input')); $user =$db->query("SELECT * FROM usuario WHERE usua_login = '".$body->user."' AND usua_pass = '".$body->password."'"); if($user == false){ http_response_code(404); } else{ http_response_code(200); echo json_encode($user); } ?> 'use strict'; /** * @ngdoc function * @name belkitaerpApp.controller:MainCtrl * @description * # MainCtrl * Controller of the belkitaerpApp */ angular.module('belkitaerpApp') .controller('MainCtrl', function ($scope,$http,$location) { $scope.login = function(user,password){ console.log('Login...'); if(user =='' || password ==''){ $('#alert').show("slow"); setTimeout(function() { $('#alert').hide('slow'); }, 3000); } else{ $http.post('../serverSide/login.php',{user:user,password:password}).success(function(data){ console.log('OK!'); $location.path('/products'); }).error(function(data){ $('#alertErr').show("slow"); setTimeout(function() { $('#alertErr').hide('slow'); }, 3000); }); } } });
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.