Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'header.php';
- ?>
- <?php
- require_once("conn.php");
- ?>
- <div>
- <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
- StudentUsername: <input type="text" name="StudentUsername" /><br />
- New Student Password: <input type="password" name="StudentPassword" /><br/>
- Teacher Username: <input type="text" name="username" /><br />
- Teacher Password: <input type="password" name="TeacherPassword" /><br />
- <input type="submit" name="submit" value="Login" />
- </form>
- </div>
- <?php
- require_once("conn.php");
- $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
- # check connection
- if ($mysqli->connect_errno) {
- echo "<p>MySQL error no {$mysqli->connect_errno} : {$mysqli->connect_error}</p>";
- exit();
- }
- $TeacherUsername = $_POST['username'];
- $TeacherPassword = $_POST['TeacherPassword'];
- $StudentUsername = $_POST['StudentUsername'];
- $StudentPassword = $_POST['StudentPassword'];
- $sql = "SELECT * FROM `teacher` WHERE `Username` = '$TeacherUsername' AND `Password` = '$TeacherPassword' LIMIT 1";
- $result = $mysqli ->query($sql);
- if ($result->num_rows > 0 ) {
- $sql = "SELECT * FROM `student` WHERE `Username` = '$StudentUsername' LIMIT 1";
- $result = $mysqli ->query($sql);
- if ($result->num_rows > 0){
- echo '<script language="javascript">';
- echo 'alert("Student Found")';
- echo '</script>';
- $sql = "UPDATE `student` SET `Password` = '$StudentPassword' WHERE `student`.`Username` = '$StudentUsername'";
- echo $sql;
- $Changed = $mysqli ->query($sql);
- if($Changed) {
- echo '<script language="javascript">';
- echo 'alert("Password Changed")';
- echo '</script>';
- }
- else{
- echo 'password not changed';
- echo '<script language="javascript">';
- echo 'alert("Password not changed")';
- echo '</script>';}
- }
- else{
- echo '<script language="javascript">';
- echo 'alert("Student Not found")';
- echo '</script>';
- }
- }else{
- echo '<script language="javascript">';
- echo 'alert("Teacher Login Incorrect")';
- echo '</script>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement