Question

PartA: Create the database. Name the database doctorWho. Then create a page that allows Doctor Who’s...

PartA:

Create the database. Name the database doctorWho. Then create a page that allows Doctor Who’s assistant to add a new patient record. You will need to give the assistant rights to this database. The assistant’s username is 'helper' and the password is 'feelBetter'. For this to work, you will need to create several pages so be sure to include all of them when submitting your work. Name the main page addPatient.php.

PartB:

Add at least five records to the patients table in the doctorWho database you created in PartA. Now create a page that will display three or more fields from each of these records. The display should consist of, at a minimum, the patient’s first and last names and a unique identifier. Name the page getPatient.php and be sure to include the necessary accompanying files when you submit your work.

Homework Answers

Answer #1

Create database in phpMyadmin doctorWho

syntax: create database databasename;

create database doctorWho;

then use database

use doctorWho;

database doctorWho

Now create two tables

1) assistant table is stored login details of assistant

syntax: create table table_name (
    col1 datatype,
col2 datatype,
....
);

create table assistant(

id int auto_increment,

username varchar(100);

password varchar(100),

primary key(id)

);

insert data in assistant table

syntax: insert into table_name (col1, col2, col3) values(val1, val2, val3);

insert into assistant values(1,'helper','feelBetter');

assistant table

2) patient table is stored patient details to submit add patient form

  syntax: create table table_name (
    col1 datatype,
col2 datatype,
....
);

  create table patient(

id int auto_increment,

firstname varchar(100),

lastname varchar(100),

mobileno varchar(20),

primary key(id)

);

patient table insert data to submit add patient form

patient table

First create auth.php show assistant login form

<!DOCTYPE html>
<html>
<head>
   <title>Login</title>
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
   <div class="container-fluid">
       <div style="margin-left: 30%;margin-top: 15%;">
       <form action="auth_rights.php" method="post"><!-- to click on submit button action tag goto auth_rights.php -->
           <div class="col-md-6 text-center">
               <h4>Assistant Login</h4>
               <table class="table">
                   <tr>
                       <td><label>Username: </label></td>
                       <td><input class="form-control" type="text" name="uname"></td><!-- enter username -->
                   </tr>
                   <tr>
                       <td><label>Password: </label></td>
                       <td><input class="form-control" type="password" name="pass"></td><!-- enter password -->
                   </tr>
               </table>
               <div class="text-right">
                   <!-- submit button -->
                   <input class="btn btn-primary" type="submit" name="submit" value="Submit">
               </div>
           </div>
       </form>
       </div>
   </div>
</body>
</html>

Assistant Login

click on submit button goes to file auth_rights.php

auth_rights.php

<?php
   //database connction parameter
   $hostname="localhost";
   $username="root";
   $password="root";
   $database="doctorWho";

   $db=mysqli_connect($hostname,$username,$password,$database);//call mysqli_connect method for connection to database
   if(!$db){
die('Connect Error==>'.mysqli_connect_error());
   }

   if(isset($_POST['submit'])) //check user click on submit button
   {
       $uname = $_POST['uname']; //get value
       $pass = $_POST['pass']; //get value
       $sql_login = 'select * from assistant where username = "'.trim($uname).'" and password = "'.trim($pass).'";';//sql query for user is rights or not
       $result = mysqli_query($db,$sql_login);
       $count = mysqli_num_rows($result);//het count of rows in sql query

       if($count == 1)
       {
           header('location:addPatient.php');//go to addPatient.php when user login successfully
       }
       else
       {
           header('location:auth.php?login=Login Failed! Please Try Again."');//go to same page auth.php when user enter worh username and password
       }
   }
?>

after login sucessfully goto page addPatient.php show add patient form

addPatient.php

<!DOCTYPE html>
<html>
<head>
   <title>Add Patient</title>
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
   <div class="container-fluid">
       <div style="margin-left: 5%;margin-top: 2%;">
       <form class="form-inline" action="save_data.php" method="post"><!-- to click on add patient button action tag call save_data.php -->
           <div class="col-md-4">
               <h4>Add Patient</h4>
               <hr>
               <div class="form-group">
                   <label>First Name:</label>
                   <input class="form-control ml-3" type="text" name="fname"><!-- enter first name -->
               </div>
               <div class="form-group mt-3">
                   <label>Last Name:</label>
                   <input class="form-control ml-3" type="text" name="lname"><!-- enter last name -->
               </div>
               <div class="form-group mt-3">
                   <label>Mobile No:</label>
                   <input class="form-control ml-3" type="text" name="mono"><!-- enter mobile no -->
               </div>
               <div class="text-right mt-3">
                   <input class="btn btn-primary mr-3" type="submit" name="submit" value="Save Patient"><!-- button used for save patient details -->
                   <a href="getPatient.php" class="btn btn-info mr-3">Get Patient</a><!-- button used for get datato alla patients -->
               </div>
           </div>
       </form>
       </div>
   </div>
</body>
</html>

there are two buttons on add patient form

1) Save Patient button used to save patient details in database call save_data.php

2) Get Patient button used to get patient details in database call getPatient.php

save_data.php

<?php
//database connction parameter
   $hostname="localhost";
   $username="root";
   $password="root";
   $database="doctorWho";

$db=mysqli_connect($hostname,$username,$password,$database);//call mysqli_connect method for connection to database
if(!$db){
die('Connect Error==>'.mysqli_connect_error());
}
   if(isset($_POST['submit'])) //check user click on submit button
   {
       $fname = $_POST['fname'];//get value
       $lname = $_POST['lname'];//get value
       $mobileno = $_POST['mono'];//get value
       $sql_insert = 'insert into patient values("Null","'.$fname.'","'.$lname.'","'.$mobileno.'");';//sql query for insert data in database
       mysqli_query($db,$sql_insert);
       header('location:addPatient.php?save=Patient save sucessfully."');//call to same php addPatient.php user enter data successfully
   }

?>

save data sucessfully show the message in URL

getPatient.php

<?php
//database connction parameter
   $hostname="localhost";
   $username="root";
   $password="root";
   $database="doctorWho";

$db=mysqli_connect($hostname,$username,$password,$database);//call mysqli_connect method for connection to database
if(!$db){
die('Connect Error==>'.mysqli_connect_error());
}
   //create html table using echo in php to shoew all patient data
       echo "<table border='1px' cellspacing='0'>";
       echo "<tr><th>Unique Id</th><th>First Name</th><th>Last Name</th><th>Mobile No</th></tr>";
       $sql_select = 'select * from patient;';//sql query for get data in database
       $result= mysqli_query($db,$sql_select);
       while($row = mysqli_fetch_assoc($result)){
           //bind the patient data in UI table
           echo "<tr><td>".$row['id']."</td><td>".$row['firstname']."</td><td>".$row['lastname']."</td><td>".$row['mobileno']."</td></tr>";
       }
      
       echo "</table>";
?>

Show tables click on Get Patient button

==Please Upvote==

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Create an application that will give valuable advice to future students from someone (you!) who is...
Create an application that will give valuable advice to future students from someone (you!) who is close to graduation. However, only end-users who have their credentials validated against the database (which uses encrypted passwords) are allowed entry. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- advice_ddl.sql CREATE DATABASE advice; USE advice; CREATE TABLE users ( id int primary key auto_increment, username varchar(255), password varchar(255) ); -- insert a row into the users table: -- username = foo -- password = bar INSERT INTO users (username, password) VALUES...
As an enterprise system developer, you need to develop the registration page of the employee management...
As an enterprise system developer, you need to develop the registration page of the employee management system. The administrator of the system registers a new employee using the GUI developed in JSP. The required table ‘Employee’ is provided in mysql database with columns as employee id, name, address, city, state and zip code as shown in figure. Write a GUI snippet/JSP code with GUI components to take the user’s input. Separately, write the servlet code to insert the input records...
A. Create a PowerShell script named “restore.ps1” within the “Requirements2” folder. For the first line, create...
A. Create a PowerShell script named “restore.ps1” within the “Requirements2” folder. For the first line, create a comment and include your first and last name along with your student ID. Note: The remainder of this task shall be completed within the same script file, “restore.ps1.” B. Write a single script within the “restore.ps1” file that performs all of the following functions without user interaction: 1. Create an Active Directory organizational unit (OU) named “finance.” 2. Import the financePersonnel.csv file (found...
Need this done using PHP code and not javascript Create a PHP form with a textarea...
Need this done using PHP code and not javascript Create a PHP form with a textarea field input and a submit button. The textarea field should be able to accept up to 250 characters. When the user clicks the Submit button, read the text in the textarea and display the following results on a web age. At the bottom of the page include a link back to the form. Number of characters: Number of words: (hint: explode the string into...
Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code...
Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code to initialize the CustomerAccountsDB database table and add a set of customer accounts is provided. Finish the code in these 3 methods in CustomerAccountDB.java to update or query the database: -purchase(double amountOfPurchase) -payment(double amountOfPayment) -getCustomerName() Hint: For getCustomerName(), look at the getAccountBalance() method to see an example of querying data from the database. For the purchase() and payment() methods, look at the addCustomerAccount() method...
In c++ create a class to maintain a GradeBook. The class should allow information on up...
In c++ create a class to maintain a GradeBook. The class should allow information on up to 3 students to be stored. The information for each student should be encapsulated in a Student class and should include the student's last name and up to 5 grades for the student. Note that less than 5 grades may sometimes be stored. Your GradeBook class should at least support operations to add a student record to the end of the book (i.e., the...
My assignment is listed below. I already have the code complete, but I cannot figure out...
My assignment is listed below. I already have the code complete, but I cannot figure out how to complete this portion: You must create a makefile to compile and build your program. I can't figure out if I need to create a makefile, and if I do, what commands do I use for that? Create a  ContactInfo class that contains the following member variables: name age phoneNumber The ContactInfo class should have a default constructor that sets name = "", phoneNumber...
SQL DATABASE Task 4 [1.5 marks] Create Index (0.5 marks) Currently, the database only contains a...
SQL DATABASE Task 4 [1.5 marks] Create Index (0.5 marks) Currently, the database only contains a small number of records. However, the data contained within it is expected to grow significantly in the future. Creating indexes on commonly searched columns is a way performance issues can be minimized. Write a command to create an index on student_name column of the student table. Create view – 1 mark Write a command to create a view to list the student ID and...
Create a flowgorithm program to calculate the Area of Circle first then do the Circumference of...
Create a flowgorithm program to calculate the Area of Circle first then do the Circumference of Circle. The user will have the ability to convert Area OR the Circumference. That means we need to add a decision structure to the program. Furthermore, they need to be able to do it as many times as they want. That means we need to add a main loop structure to the program. The user will also have the choice of whether to run...
In the previous assessment, you used a static set of named variables to store the data...
In the previous assessment, you used a static set of named variables to store the data that was entered in a form to be output in a message. For this assessment, you will use the invitation.html file that you modified in the previous assessment to create a more effective process for entering information and creating invitations for volunteers. Rather than having to enter each volunteer and create an invitation one at a time, you will create a script that will...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT