Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // session_start();
- include("nagl.php");
- include("functions.php");
- include("database_var.php");
- //variables for database connecting configuration
- // $servername = "mysql.agh.edu.pl";
- // $username = "malis";
- // $password = "p1u1kr8dvw6kWXmE";
- // $database = "malis";
- //generating object conn
- $conn= new mysqli($servername, $username, $password, $database);
- //sprawdzenie połączenia
- if($conn->connect_error){
- die("Fatal error - connection lost: " . $conn->connect_error. "<br>" );
- }
- echo "Connected to database <br>";
- $zapytanie = "SELECT * FROM my_database";
- echo "<br>" . $zapytanie . "<br>";
- $result = $conn->query($zapytanie);
- echo "Number of found records:" . $result->num_rows . "<br>";
- echo"ID | NAME | EMAIL | MD5 PASSWORD | STATUS <br/>" ;
- if($result->num_rows > 0){
- //printing results from every row
- while($row=$result->fetch_assoc()){
- echo $row["id"]. " | " . $row["my_name"] . " | " .
- $row["email"] . " | " .$row["decrypted_password"] . " | " .
- $row["encrypted_password"] . " | " . $row["status"] . "<br>";
- }
- } else {
- echo "Returned no records<br>";
- }
- if(!empty($_GET['menu'])){
- $wybor = $_GET['menu'];
- echo "You're using GET<br>";
- }
- if(isset($_SESSION)){
- session_destroy();
- // $_SESSION=array();
- }
- echo "<br>";
- echo "<br>";
- if(!isset($wybor)) $wybor = 0;
- echo "Switch case: = $wybor <br>";
- switch($wybor){
- case 1:
- addsql($conn,$_GET['newName'], $_GET['newEmail'], $_GET['newDecrypted_password'], $_GET['newStatus']);
- myencrypt($conn,$_GET['newDecrypted_password']);
- break;
- case 2:
- deletesql($conn, $_GET['id']);
- break;
- }
- //$wybor=0;
- $conn->close();
- ?>
- <H3>Menu</H3>
- <H4>Choose one of the options below:</H4>
- <form action="main.php" method="get">
- <label><input type="radio" name="menu" value="1">Add new record<label><br>
- Name<input type="text" name="newName"><label><br>
- Email<input type="text" name="newEmail"><label><br>
- Password<input type="text" name="newDecrypted_password"><label><br>
- Status<input type="text" name="newStatus"><label><br>
- <label><input type="radio" name="menu" value="2">Remove from database<label><br>
- ID to remove<input type="number" name="id"><label><br>
- <input type="submit" value="Done">
- </form>
- <form action="lab.php" method="POST">
- <input type="submit" value="LOG IN">
- </form>
- <?php
- include("stopka.php");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement