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