Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------index.php-----------
- <?php
- // Name:
- // Aim:
- // Date:
- // En.No:
- // PC No:
- ?>
- <!DOCTYPE html>
- <html>
- <body>
- <h2>Login</h2>
- <form method="post" action="backend.php">
- <label>Username:</label>
- <input type="text" name="username" required><br><br>
- <label>Password:</label>
- <input type="password" name="password" required><br><br>
- <input type="submit" value="Login">
- </form>
- </body>
- </html>
- ---------------backend.php--------------
- <?php
- $uname = $_POST["username"];
- setcookie("uname", $uname);
- $pass = $_POST["password"];
- if (!preg_match('/^[a-zA-Z]+$/', $uname)) {
- echo "Invalid username. Username should contain only characters.";
- }else{
- $true = 1;
- }
- $length = strlen($pass);
- if ($length < 8 || $length > 15) {
- echo "Password should be between 8 and 15 characters.";
- }else{
- $true = $true + 1;
- }
- echo $true;
- if($true == 2){
- echo "Login successful. Welcome, $uname!";
- echo "Click <a href='welcome.php' >Here </a>to go welcome Page";
- header("Location: welcome.php");
- }
- ?>
- ----------------------------welcome.php-----------------
- <!DOCTYPE html>
- <html>
- <head>
- <title>Welcome to College</title>
- </head>
- <body>
- <h2>Welcome to College</h2>
- <p>Welcome <?php echo $_COOKIE["uname"]; ?>!</p>
- <p>Choose an option:</p>
- <ul>
- <li><a href="complain_details.php">Complain Details (soon..)</a></li>
- <li><a href="class_details.php">Class Details</a></li>
- <li><a href="student_profile.php">Student Profile (soon..)</a></li>
- </ul>
- </body>
- </html>
- -----------class_details.php------------
- <a href="add_class_details.php">Add Class Details</a><br>
- <a href="welcome.php">Home</a>
- <h2>All Class Name</h2><br>
- <?php
- $server = "127.0.0.1";
- $user = "root";
- $pass = "";
- $dbname = "e-complain";
- $con = new mysqli($server,$user,$pass,$dbname);
- if (!$con) {
- echo "DB Connection Fail check port number or server";
- }else{
- $sql = "select * from class_details";
- $result = $con->query($sql);
- while ($class = mysqli_fetch_array($result)) {
- echo $class[1]."<br>";
- }
- }
- ?>
- -----------add_class_details.php
- <body>
- <form action="" method="post">
- <lable>Enter Class Name:- </lable>
- <input type="text" name="cName" /><br>
- <input type="submit">
- </form>
- </body>
- <?php
- if (isset($_POST['cName'])) {
- $cname = $_POST['cName'];
- $server = "127.0.0.1";
- $user = "root";
- $pass = "";
- $dbname = "e-complain";
- $con = new mysqli($server, $user, $pass, $dbname);
- if (!$con) {
- echo "DB Connection Fail check port number or server";
- } else {
- $sql = "INSERT INTO class_details(ClassName) VALUES ('$cname')";
- $result = $con->query($sql);
- if ($result) {
- header('Location: class_details.php');
- }else{
- echo "Error:- Something Want Wrong Value can't insert";
- }
- }
- }
- ?>
- ------------next soon.----------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement