1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
mario62 [17]
3 years ago
13

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.
Computers and Technology
1 answer:
Anastasy [175]3 years ago
6 0

Answer:

Check the explanation

Explanation:

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);

?>

You might be interested in
FOLLOW INSTRUCTIONS BELOW , WRITTEN IN JAVA LANGUAGE PLEASE AND THANK YOU !
boyakko [2]
It’s a lot of reading sorry can’t help you but try your best too
7 0
3 years ago
The __________ algorithm takes the ciphertext and the secret key and produces the original plaintext
Bad White [126]
The answer is decryption
8 0
3 years ago
Que Inventos Importantes se Crearon durante la edad de agua y viento
ss7ja [257]

Answer:

Sep 24, 2016 · Que inventos importantes se crearon durante la edad del agua y el viento Recibe ahora mismo las respuestas que necesitas!

Explanation:

3 0
3 years ago
Write steps to Delete data from ‘Datagridview’
julsineya [31]

Explanation:

private void btnDelete_Click(object sender, EventArgs e)

{

if (this.dataGridView1.SelectedRows.Count > 0)

{

dataGridView1.Rows.RemoveAt(this.dataGridView1.SelectedRows[0].Index);

}

}

8 0
3 years ago
Create pseudocode that could be used as a blueprint for a program that would do the following: An employer wants you to create a
mestny [16]

Answer:

START LOOP FOR EACH EMPLOYEE:

   INPUT employee’s name, hourly rate of pay, number of hours worked, overtime pay rate, payroll deductions, tax rate

   SET gross pay = (hourly rate of pay x *weekly hours) + (overtime pay rate x (number of hours worked - *weekly hours))

   PRINT gross pay

   SET net pay = gross pay - (payroll deductions + (gross pay * tax rate/100 ))

   PRINT net pay

END LOOP

* weekly hours (how many hours an employee needs to work to earn overtime pay rate) is not given in the question

Explanation:

Create a loop that iterates for each employee

Inside the loop, ask for name, hourly rate, number of hours worked, overtime pay rate, payroll deductions, tax rate. Calculate the gross pay and print it. Calculate the net pay and print it

8 0
3 years ago
Other questions:
  • Create a stored procedure named prc_inv_amounts to update the INV_SUBTOTAL, INV_TAX, and INV_TOTAL. The procedure takes the invo
    8·1 answer
  • A corporation needs an operating system that allows the various teams in its office to network and collaborate on projects. Whic
    14·1 answer
  • Which network could NOT carry commercial traffic?
    5·1 answer
  • It is better to know the main components of all computer programming languages
    9·1 answer
  • What is the biggest disadvantage of copying a worksheet into another workbook?
    13·1 answer
  • If a storm is 7.5 kilometers away, how much time is expected between observations of lightning and thunder? Round your answer to
    10·1 answer
  • The syntax for accessing a class (struct) member using the operator -&gt; is ____.
    15·2 answers
  • Describe your ideas for a keyboarding game that would help someone improve their skills.
    6·1 answer
  • Which device allows you to convert sounds into digital format to be used on the computer​
    8·1 answer
  • A computer game allows a player to repeat a level until they run out of lives. Which two of the following loops would work corre
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!