Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Untitled Document</title>
  6. </head>
  7.  
  8. <body>
  9.  
  10. <?php
  11.  
  12. include('login.php');
  13.  
  14.  
  15.  
  16.  
  17. if ( !empty($_POST) and ( empty($_POST['num_aluno']) or empty($_POST['nome_aluno'])
  18. or empty($_POST['disciplina']) or empty($_POST['modulo']) or empty($_POST['data_realizacao']) or empty($_POST['nota']) ) )
  19. {
  20. header("Location: registar_utilizador.php");
  21. exit;}
  22.  
  23.  
  24. $Server_name="localhost";
  25. $Username="root";
  26. $Password="";
  27. $database="gestao_notas";
  28. $Ligacao=new mysqli ($Server_name, $Username, $Password, $database);
  29. if ($Ligacao -> connect_error)
  30. die('Ligação Falhada'.$Ligacao -> connect_error);
  31. else
  32. Echo("Ligação bem sucedida!");
  33. $sql = "SELECT * FROM gestao_notas";
  34. $result = mysqli_query($Ligacao, $sql);
  35.  
  36.  
  37.  
  38. // variáveis que irão guardar os dados que foram preenchidos no formulário
  39. $num_aluno = $_POST['num_aluno'];
  40. $nome_aluno = $_POST['nome_aluno'];
  41. $disciplina = $_POST['disciplina'];
  42. $modulo = $_POST['modulo'];
  43. $data_realizacao = $_POST['data_realizacao'];
  44. $nota = $_POST['nota'];
  45.  
  46. // comando SQL que irá inserir os dados
  47. $sql = "INSERT INTO gestao_notas (num_aluno, nome_aluno, disciplina, modulo, data_realizacao, nota) VALUES
  48. ('".$num_aluno."','".$nome_aluno."','".$disciplina."','".$modulo."','".$data_realizacao."','".$nota."')";
  49. // executa o comando SQL
  50. if (!mysqli_query($Ligacao, $sql))
  51. {
  52. // erro no registo
  53. header('Location: registar_utilizador.php');
  54. exit();
  55. }
  56. else
  57. {
  58. // mensagem de registo incluido
  59. echo("O Registo foi realizado com sucesso!");
  60. exit();
  61. }
  62.  
  63.  
  64.  
  65.  
  66. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement