Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <script src="js/funcao.js"></script>
- </head>
- <body>
- <div data-role="page" id="paginal">
- <div data-role="header">
- <h1>Registros</h1>
- </div>
- <div data-role="main" class="ui-content">
- <label>Nome</label>
- <input id="nome" type="text" name="nome" /> <br>
- <label>Sobrenome</label>
- <input id="sobrenome" type="text" name="sobrenome" /> <br>
- <button id="inclusao">Incluir</button>
- <HR>
- <a href="#paginal2" class="ui-btn ui-btn-corner-all">Visualizar Cadastros</a>
- </HR>
- </div>
- </div>
- <div data role="page" id="paginal2">
- <div data-role="header">
- <a href="#paginal1" data-rel="back" class="ui-btn-left ui-btn ui-btn-icon-notext ui-corner-all ui-icon-back">Voltar</a>
- <h1>Listar Usuario</h1>
- </div>
- <div data-role="main" class="ui-content">
- <p id="listarusuario"></p>
- </div>
- </div>
- </body>
- </html>
- <?php
- //$serve = mysql_connect('localhost', 'root', '');
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "registro";
- // Create connection
- $serve = new mysqli($servername, $username, $password, $dbname);
- if (!$serve) {
- echo 'erro';
- }
- //$db = mysql_select_db('registro', $serve);
- if($GET['acao'] == 'inclusao') {
- $nome = $_GET['nome'];
- $sobrenome = $_GET['sobrenome'];
- $SQL = "insert INTO usuario (nome,sobrenome) VALUES ('$nome', '$sobrenome') ";
- $re = mysqli_query($SQL, $serve);
- }
- if ($_GET['acao'] == 'listarusuario') {
- $SQL = "SELECT * FROM usuario";
- $re = mysqli_num_rows($re);
- if($num > 0) {
- while($Linha = mysqli_fetch_object($re)) {
- echo "<b>Nome:</b> {$Linha->nome} <b><br></b> <b>Sobrenome:</b> {$Linha->sobrenome} </br><hr>";
- }
- }
- else {
- echo 'no registered users';
- }
- }
- ?>
- $(document).ready(function) {
- var $server;
- $server = 'http://localhost:81/xampp/porto/www/';
- $('#inclusao').on('click', function() {
- $nome = $('#nome').val();
- $sobrenome = $('#sobrenome').val();
- $.ajax({
- type: "get",
- url: $server-"/connecta.php",
- data: "nome="+$nome+"&sobrenome="+$sobrenome+"&acao=inclusao",
- sucess: function(data) {
- intel.xdk.notification.alert('usuario cadastr:','aviso!','OK');
- Lista();
- }
- });
- });
- function Lista() {
- $.ajax({
- type: "get",
- dataType: 'html',
- url: $server+"/conecta.php",
- data: "acao=listarusuario",
- sucess: function(data) {
- $('#listarusuario').html(data);
- }
- });
- }
- Lista();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement