Question

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

You need to implement a web application that is split in three parts, namely, Webpage, PHP and MySQL. Each of them will be used accordingly to solve a simple problem described below. Remember to implement the logic in the most secure way of your knowledge.

PHP

  • Implement a PHP function that reads in input a string from the user and store it in a table (e.g., in a field called "Content Name").
  • The function should be able to read the content of the file and store it in a table (e.g., in a field called "File Content").
  • The web application should be able to implement a logic to log in and sign up users.
    • Each user will have exclusive access to her/his uploaded material.
    • When a user logs in, all her/his private content will be displayed on the web page.
      • If no user has logged in yet, no information from the database are printed on the webpage.

Webpage

  • The user must be able to upload a text file (and nothing more!).
  • The user must be able to input a string, using a text box.
  • The webpage allows users to input their credentials for both logging in and signing up.
  • After a user logs in, the webpage prints in output her/his personal material from the database, that is, the content of each file with the specified name.
    • If there is no material yet, nothing is showed for that specific user.

MySQL

  • You need to create a database that contains at least two tables. One to store the information in input to the webpage, the other to store the users credentials.
    • The "credentials table" should contain at least these fields: email, username and password.

SUBMISSION

  • You need to submit your web application in a .php file, no other formats is allowed.
  • You don't need to submit your 'login.php' file.
  • No details about the database need to be submitted.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

index.php

<!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->
<head>

</head>
<body>
<section class="container">
    <div class="login">
      <h1>Login Portal</h1>
      <form method="post" action="login.php" name="frm" onSubmit="return f1();">

        <p><input type="email" name="email" value="" placeholder="Enail"></p>

        <p><input type="password" name="pwd" value="" placeholder="Password"></p>

        <p class="submit"><input type="submit"   value="Login"></p>
      </form>
        <p class="submi"><a href="admin_signup.php" > <input type="button"   value="Signup"></a></p>
    </div>


</section>


</body>
</html>

login.php

<?php
session_start();
$con=mysqli_connect("localhost","root","","storage");
if(!$con)
{
die("connection failed" .mysqli_connect_error());
}

$e=$_POST["email"];
$p=$_POST["pwd"];

$sql="select * from `account` where `email`='$e' and `password`='$p'";

$res=mysqli_query($con,$sql);
if(mysqli_num_rows($res)>0)
{
$_SESSION["email"]=$e;
include 'profile.php';
}
else {
echo "no such username";
include 'admin.php';
}

mysqli_close($con);
?>

admin_signup.php

<!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->
<head>

</head>
<body>
<section class="container">
    <div class="login">
      <h1>Signup Portal</h1>
      <form method="post" action="signup.php" name="frm" onSubmit="return f1();">
         <p><input type="email" name="email" value="" placeholder="Email id"></p>
        <p><input type="text" name="uname" value="" placeholder="Admin name"></p>
        <p><input type="password" name="pwd" value="" placeholder="Password"></p>

        <p class="submit"><input type="submit"   value="Signup"></p>
      </form>
        <p class="submi"><a href="admin.php" > <input type="button"   value="Login"></a></p>
    </div>


</section>


</body>
</html>

signup.php

<?php
session_start();
$con=mysqli_connect("localhost","root","","storage");
if(!$con)
{
die("connection failed" .mysqli_connect_error());
}

$u=$_POST["uname"];
$e=$_POST["email"];
$p=$_POST["pwd"];

$sql="INSERT INTO `account`(`email`, `username`, `password`) VALUES ('$e','$u','$p')";
mysqli_query($con,$sql);
mysqli_close($con);
include 'admin.php';


?>

upload file (profile.php)

<!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->
<head>

</head>
<body>
<section class="container">
    <div class="login">
      <h1>Login Portal</h1>
      <form method="post" action="content.php" name="frm" onSubmit="return f1();" enctype="multipart/form-data" >

        <p><input type="test" name="docname" value="" placeholder="docname"></p>

        <p><input type="file" name="filename" value="" placeholder="file path"></p>

        <p class="submit"><input type="submit"   value="upload"></p>
      </form>
      <p > <a href="view.php">to view your content , click here</a></p>
    </div>


</section>


</body>
</html>

content.php

<?php
session_start();
$con=mysqli_connect("localhost","root","","storage");
if(!$con)
{
die("connection failed" .mysqli_connect_error());
}

$handle = $_FILES['filename']['tmp_name'];
echo $handle;
$d=$_POST["docname"];
$e=$_SESSION["email"];
$c=file_get_contents($handle);

$sql="INSERT INTO `info`(`email`, `docname`, `content`) VALUES ('$e','$d','$c')";
mysqli_query($con,$sql);
mysqli_close($con);
include 'admin.php';


?>


to view content , view.php

<?php
session_start();
$con=mysqli_connect("localhost","root","","storage");
if(!$con)
{
die("connection failed" .mysqli_connect_error());
}

$e=$_SESSION["email"];


$sql="select * from `info` where `email`='$e' ";

$res=mysqli_query($con,$sql);

if(mysqli_num_rows($res)>0)
{
while($show=mysqli_fetch_assoc($res))
{
echo $show["docname"]."\n".$show["content"];
}
}
else {
echo "no content till now";

}

mysqli_close($con);
?>

Add a comment
Know the answer?
Add Answer to:
You need to implement a web application that is split in three parts, namely, Webpage, PHP and My...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Implement a PHP function that reads in input a string from the user and store it in a table (e.g....

    Implement a PHP function that reads in input a string from the user and store it in a table (e.g., in a field called "Content Name"). The function should be able to read the content of the file and store it in a table (e.g., in a field called "File Content"). The web application should be able to implement a logic to log in and sign up users. Each user will have exclusive access to her/his uploaded material. When a...

  • Helpp: Make an application Protocol Application log for text messages In this task, an application protocol for sending...

    Helpp: Make an application Protocol Application log for text messages In this task, an application protocol for sending and retrieving text messages is to be developed. A client (eg app on a smartphone) communicates with an application on a web server running a database of user data (username and password) and messages (user name of the sender, user name of the recipient, message text). The client should be able to perform the following actions: Register a new user Log in...

  • PHP Programming In this project, you will create a Web page that allows visitors to your...

    PHP Programming In this project, you will create a Web page that allows visitors to your site to sign a guest book that is saved to a database. Create a new document in your text editor and type the <!DOCTYPE> declaration, <html> element, document head, and <body> element. Use the strict DTD and “Guest Book” as the content of the <title> element. Add the following text and elements to the document body: <h2>Enter your name to sign our guest book</h2>...

  • Hi guys! I need some help with this Web Design mini project. Any help will be appreciated a rated...

    Hi guys! I need some help with this Web Design mini project. Any help will be appreciated a rated. Thanks in advance! Here is the project: (It must be implemented using JSP and MySQL) not PHP I need help with the code implementation! Mini Facebook A. Description You are asked to implement a social network B. Requirements You are to implement a computer system with the following capabilities 1. User accounts including: sign up, login, and logout. 2. Each user...

  • i need help with this homework webpage and code too: The webpage must include: Global Structure...

    i need help with this homework webpage and code too: The webpage must include: Global Structure Tags Text Tags Images   Your first page must be named index.html Include a table within your site, challenge yourself to add a header in the table, and choose interesting border and/or cell formatting. Include a hyperlink within your site. Include an image in your site. Include a form in your site to demonstrate understanding of a variety of form components (the form does not...

  • In this assignment you will combine HTML, PHP, and SQL in order to create a web...

    In this assignment you will combine HTML, PHP, and SQL in order to create a web form that allows a manager to add films to the sakila database. You will also create a method to allow the manager to view a list of all films along with their related information, and a list of actors in the movies. Task 1 Create an initial HTML page titled manager.html with 2 buttons. The first button will be labeled “View Films”, and the...

  • For this course project, you will use various database management and programming techniques to design and...

    For this course project, you will use various database management and programming techniques to design and develop an online sales and distribution system for a fictitious organization. There are two phases—you will complete the first phase this week and the second phase in W5 Assignment 2. Rationale The focus of the project is to develop your database programming skills. This project will help you get a fair idea of the sales and distribution system in any organization that has a...

  • Project Description In this project, you will design and implement a database for keeping track of...

    Project Description In this project, you will design and implement a database for keeping track of information for an online “SOCIAL NETWORK” system (e.g. a simplified version of Facebook!). You will first design an EER schema diagram for this database application. Then, you will map the EER schema into a relational database schema and implement it on ORACLE or MySQL or some other relational DBMS. Finally, you will load some data into your database (via user Interface) and create some...

  • Problem statement For this program, you are to implement a simple machine-learning algorithm that uses a...

    Problem statement For this program, you are to implement a simple machine-learning algorithm that uses a rule-based classifier to predict whether or not a particular patient has diabetes. In order to do so, you will need to first train your program, using a provided data set, to recognize a disease. Once a program is capable of doing it, you will run it on new data sets and predict the existence or absence of a disease. While solving this problem, you...

  • For milestone #1, we will start the CARIT site with three static HTML pages and a...

    For milestone #1, we will start the CARIT site with three static HTML pages and a CSS file. Create a dedicated folder for this project. This folder should contain all related files in this project. The future milestones are cumulative and built directly on top of your prior work. Function/content requirements: A home page named “index.html”, which include these contents at least: Description of the center. You may reference the example sites. Latest news: use list tags; make up some...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT