This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| session_start(); | |
| if(!isset($_SESSION['user_id'])) { | |
| header("location: logn.html"); | |
| exit; | |
| } | |
| echo "Welcome to your dashboard"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>Login system</title> | |
| </head> | |
| <body> | |
| <form action="login.php" method="POST"> | |
| <input type="emaiil" name="email" placeholder="email" required> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $conn = new mysqli("localhost", "root", "", "user_system"); | |
| $username = $_POST['username']; | |
| $email = $_POST['email']; | |
| $password = password_hash($_POST['password'], PASSWORD_DEFAULT); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Updating data | |
| $newName = "Alice smith "; | |
| $idToUpdate = 3; | |
| $sql = "UPDATE users_ SET name = '$newName' WHERE id=$idToUpdate"; | |
| if ($conn->query($sql)) { | |
| echo "Record Updated"; | |
| } else{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Create | |
| $conn= new mysqli('localhost', "root", "", "myapp"); | |
| $name = "Alice"; | |
| $email = "alice@example.com"; | |
| $age = 25; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $host = 'localhost'; | |
| $user = 'root'; | |
| $password = ""; | |
| $dbname = "myapp"; | |
| //create connection | |
| $conn = new mysqli($host,$user,$password,$dbname); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>File Upload</title> | |
| </head> | |
| <body> | |
| <?php | |
| if(isset($_FILES['myFile'])) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // WRITE to file | |
| $handle = fopen("example.txt", "w"); | |
| fwrite($handle, "Hello, this is a test \n"); | |
| fwrite($handle, "We are writing to a file in PHP"); | |
| fclose($handle); | |
| // READ from file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>User Input</title> | |
| </head> | |
| <body> | |
| <?php | |
| // Define the function first |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>Form Validation</title> | |
| </head> | |
| <body> | |
| <?php | |
| $name = $email = $age = ""; |