Question

In: Computer Science

You need to implement a web application that is split in three parts, namely, Webpage, PHP...

You need to implement a web application that is split in three parts, namely, Webpage, PHP and Database. Each of them will be employed synergically to solve the simple problem described below. Your implementation should be able to resist all the most common security threats.

Webpage: This is the main page of your application. It would contain two sections, ADD and SEARCH: ADD section contains:

-A text box to input an Advisor name

-A text box to input a Student name

-A text box to input the Student ID code

-A text box to input the class code

-A button to allow the user to add the above specified data in the Database

SEARCH section contains: A search box (with corresponding button) that allows the user to query the database for Advisors name

PHP:

-Implement one or more PHP functions that read the inputs from the ADD section of the Webpage and prepare the corresponding query to add the record in the Database.

-Implement one or more PHP functions that read the input from the SEARCH section and prepare the corresponding query for the Database.

-Implement a function that, when a search is made in the SEARCH section, it shows in input the result of the query

Database: You need to create a database that contains at least a table to store the information in input to the webpage.

Solutions

Expert Solution

Database /* Male database "hello", and set user,password in php file*/

CREATE TABLE `data` (
`id` int(11) NOT NULL,
`aname` varchar(50) DEFAULT NULL,
`sname` varchar(50) DEFAULT NULL,
`cno` varchar(50) DEFAULT NULL,
`ccode` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `data`
--
ALTER TABLE `data`
ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `data`
--
ALTER TABLE `data`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
COMMIT;

/* Now copy the below php file */

<?php
$servername = "localhost";
$username = "root";
$password = "";
$db="hello";
$conn = new mysqli($servername, $username, $password,$db);

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo '<form class="form" method="POST">
           <input type="text" name="aname" placeholder="Advisor Name" required>
           <input type="text" placeholder="Student Name" name="sname" required>
           <input type="text" placeholder="Student Id code" name="cno" required>
           <input type="text" placeholder="Class code" name="ccode" required>
          
           <button type="submit" id="login-button" name="submit" value="submit">Add</button>
       </form>
       <br><br>
<form class="form" method="POST">
           <input type="text" name="search" placeholder="Search by Student name" required>
           <button type="submit" id="login-button" name="submit1" value="Search">Add</button>
       </form>';
if(isset($_POST['submit'])){
   $aname=mysqli_real_escape_string($conn,$_POST['aname']);
   $sname=mysqli_real_escape_string($conn,$_POST['sname']);
   $cno=mysqli_real_escape_string($conn,$_POST['cno']);
   $ccode=mysqli_real_escape_string($conn,$_POST['ccode']);
$o="INSERT INTO data(id,aname,sname,cno,ccode)values('','".$aname."','".$sname."','".$cno."','".$ccode."')";
$q=mysqli_query($conn,$o);
}
if(isset($_POST['submit1'])){
   $sname=mysqli_real_escape_string($conn,$_POST['search']);
   $r="SELECT * FROM data WHERE sname='".$sname."'";
   $q=mysqli_query($conn,$r);
   if(mysqli_num_rows($q)>0)
   {

       echo '<table border="1"><tr><th>Advisor Name</th><th>Student Name</th><th>Student ID</th><th>Class Code</th></tr>';
       while($t=mysqli_fetch_assoc($q)){
           echo '<tr><td>'.$t['aname'].'</td><td>'.$t['sname'].'</td><td>'.$t['cno'].'</td><td>'.$t['ccode'].'</td></tr>';
          
       }
       echo '</table>';
   }
   }
?>
  


Related Solutions

Using the combination of HTML and PHP, implement a web page where the users can upload...
Using the combination of HTML and PHP, implement a web page where the users can upload a text file, exclusively in .txt format, which contains a string of 1000 numbers, such as: 71636269561882670428252483600823257530420752963450 85861560789112949495459501737958331952853208805511 65727333001053367881220235421809751254540594752243 52584907711670556013604839586446706324415722155397 53697817977846174064955149290862569321978468622482 83972241375657056057490261407972968652414535100474 82166370484403199890008895243450658541227588666881 96983520312774506326239578318016984801869478851843 12540698747158523863050715693290963295227443043557 66896648950445244523161731856403098711121722383113 05886116467109405077541002256983155200055935729725 16427171479924442928230863465674813919123162824586 17866458359124566529476545682848912883142607690042 24219022671055626321111109370544217506941658960408 07198403850962455444362981230987879927244284909188 84580156166097919133875499200524063689912560717606 62229893423380308135336276614282806444486645238749 73167176531330624919225119674426574742355349194934 30358907296290491560440772390713810515859307960866 70172427121883998797908792274921901699720888093776 Your code should contain a PHP function that, accepting the string of 1000 numbers in input, is able to: 1) Find the 5 adjacent numbers that multiplied together...
Using a combination of HTML/PHP, implement a web page where the users can upload a text...
Using a combination of HTML/PHP, implement a web page where the users can upload a text file, exclusively in .txt format, which contains a string of 400 numbers, such as: 71636269561882670428 85861560789112949495 65727333001053367881 52584907711670556013 53697817977846174064 83972241375657056057 82166370484403199890 96983520312774506326 12540698747158523863 66896648950445244523 05886116467109405077 16427171479924442928 17866458359124566529 24219022671055626321 07198403850962455444 84580156166097919133 62229893423380308135 73167176531330624919 30358907296290491560 70172427121883998797 Your code should contain a PHP function that, accepting the string of 400 numbers in input, is able to find the greatest product of four adjacent numbers in all the...
DNS Query and Web Page Access Time: Suppose you click on a hyperlink on a webpage...
DNS Query and Web Page Access Time: Suppose you click on a hyperlink on a webpage you are currently viewing -- this causes a new web page to be loaded and displayed. Suppose the IP address for the host in the new URL is not cached in your local DNS server (AKA local name server), so your Client (browser) makes a DNS query to obtain the IP address before the page can be requested from the web server. To resolve...
Implement an exam application in which a user can give exam. Question will be of three...
Implement an exam application in which a user can give exam. Question will be of three types. MCQ, true false and fill in the blank. Develop a GUI in java using swings.
You are working for an organisation that is using a very old web-based application that was...
You are working for an organisation that is using a very old web-based application that was developed in-house and is only used by members of the organisation. The leader of the web development team has indicated that the application needs to be urgently redeveloped as it is dependent upon outdated frameworks that have recently been found to be vulnerable to SQL injection attacks, however the organisation is currently short on funding. One of the security team has suggested using a...
Java - Design and implement an application that creates a histogram that allows you to visually...
Java - Design and implement an application that creates a histogram that allows you to visually inspect the frequency distribution of a set of values. The program should read in an arbitrary number of integers that are in the range 1 to 100 inclusive; then produce a chart similar to the one below that indicates how many input values fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk for each value entered. Sample...
When you put a Servlet in a Web Application on the Tomcat/Glassfish server, how do you...
When you put a Servlet in a Web Application on the Tomcat/Glassfish server, how do you go about running this Servlet? a. From the Browser’s URL(give path):
QUESTION 2 You are developing an online quiz web application and you have been asked to...
QUESTION 2 You are developing an online quiz web application and you have been asked to design a JSON file for creating a TestBank. You need to design the JSON file for storing some multiple choice questions/answers. Here is an example of sample data which you need to convert it into JSON Q) 5 + 7 * 2 = ? a) 14 b) 12 c) 24 d) 19 ANS: d Answer the following questions: 1) How do you design the...
8.3) Design and implement an application that creates a histogram that allows you to visually inspect...
8.3) Design and implement an application that creates a histogram that allows you to visually inspect the frequency distribution of a set of values. The program should read in an arbitrary number of integers that are in the range 1 to 100 inclusive; then produce a chart similar to the one below that indicates how many input values fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk for each value entered. 1 -...
java 8.3: Histogram Design and implement an application that creates a histogram that allows you to...
java 8.3: Histogram Design and implement an application that creates a histogram that allows you to visually inspect the frequency distribution of a set of values. The program should read in an arbitrary number of integers that are in the range 1 to 100 inclusive; then produce a chart similar to the one below that indicates how many input values fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk for each value entered....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT