Skip to content

Instantly share code, notes, and snippets.

@Zerk123
Created May 11, 2017 20:14
Show Gist options
  • Save Zerk123/3133042403d96ba2cb1c0b894b920d39 to your computer and use it in GitHub Desktop.
Save Zerk123/3133042403d96ba2cb1c0b894b920d39 to your computer and use it in GitHub Desktop.
QuickShare Beta version of Social networking website
<?php
$db=mysqli_connect("localhost","root","","members");
$query="select * from chat ORDER BY id DESC";
$run=mysqli_query($db,$query);
while($row=mysqli_fetch_array($run)) :
?>
<div id="chat_data">
<span style="color:green";><?php echo $row['name']; ?></span> :
<span style="color:brown";><?php echo $row['msg']; ?></span>
<span style="float:right";><?php echo $row['date']; ?></span>
</div>
<?php endwhile; ?>
<?php
// This is a sample code in case you wish to check the username from a mysql db table
if(isSet($_POST['username'])) {
$username = $_POST['username'];
$dbHost = 'localhost'; // usually localhost
$dbUsername = 'root';
$dbPassword = '';
$dbDatabase = 'members';
$db = mysqli_connect($dbHost, $dbUsername, $dbPassword,$dbDatabase )
or die ("Unable to connect to Database Server.");
$sql_check = mysql_query("select id from members where name='".$username."'")
or die(mysql_error());
if(mysqli_num_rows($sql_check)) {
echo '<font color="red">The nickname <strong>'.$username.'</strong>'.
' is already in use.</font>';
} else {
echo 'OK';
}
}
?>
<?php
$db=mysqli_connect("localhost","root","","members");
function formatDate($date)
{
//return date('g:i a',strtotime($date));
}
?>
<?php
session_start();
$link=mysqli_connect("localhost","root","","members");
if(isset($_POST['submit'])){
$username=$_SESSION['currentuser'];
$query="delete from users where name='$username'";
if(mysqli_query($link,$query)){
header("Location:logout.php");
}
}
?>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
<style>
@import url('https://fonts.googleapis.com/css?family=Asar|Playfair+Display');
body{
background-color:black;
}
.navbar {
margin-bottom: 0;
border-radius: 0;
font-family: 'Playfair Display', serif;
}
.navbar{
height: 40px;
background-color:lightblue;
border: lightblue;
}
.form-group{
margin:0 auto;
width:400;
}
.btn{
margin:0 auto;
width:400;
margin-left:-40;
}
.division{
margin-top:150;
}
.question{
margin-top:200;
margin-left:-25;
text-align:center;
}
.question01{
margin-top:80;
margin-left:-25;
text-align:center;
}
</style>
</head>
<body>
<div class="container">
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#"><b>QuickShare</b></a>
</div>
<ul class="nav navbar-nav">
<li><a href="home.php">Home</a></li>
<li class="active"><a href="deavtivate.php">Settings</a></li>
</ul>
/</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="logout.php"><span class="glyphicon glyphicon-log-in"></span> Logout</a></li>
</ul>
</div>
</nav>
<div class="question01">
<form action="index.php" method="POST">
<label for="submit">Do you want some sought of technical support? We are available 24/7 One click away</label></br>
<input class="btn btn-primary" type="submit" id="submit" value="Tech Support" name="submit">
</form>
</div>
<div class="question">
<form action="deactivate.php" method="POST">
<label for="submit">Do you really want to delete your account ?</label></br>
<input class="btn btn-danger" type="submit" id="submit" value="Deactivate" name="submit">
</form>
</div>
</div>
</body>
</html>
<?php
session_start();
$a=mysqli_connect("localhost","root","","members");
if(isset($_POST['update'])){
$username=$_POST['username'];
$password=$_POST['password'];
$query1="select id from users where name='$username'";
$result=mysqli_query($a,$query1);
$display=mysqli_fetch_assoc($result);
$edit_record=display['id'];
$query="select * from users where id='$edit_record'";
$run=mysqli_query($a,$query);
while ($row=mysqli_fetch_array($run))
{
$edit_id=$row['id'];
$username= $row['name'];
$password= $row['password'];
}
$query2="update users set password='$password' where id='$edit_id'";
if(mysqli_query($a,$query2))
{
}
}
?>
<html>
<head>
<title>User's data</title>
</head>
<body>
<form action="Edit.php>" method="POST">
<h1> updating records</h1>
<input type="text" name="username" id="username" value="Enter Username...">
<input type="password" name="password" id="password" value="New Password"required>
<input type="submit" id="update" name="update" value="updatenow">
</form>
</body>
</html>
<?php
session_start();
$server="localhost";
$user="root";
$pass="";
$Db="members";
$link=mysqli_connect($server,$user,$pass,$Db);
if(isset($_POST['submit'])){
$name=$_POST["username"];
$message=$_POST["textarea01"];
$query="insert into feedback(username,feedback) values('$name','$message');";
if($result=mysqli_query($link,$query)){
header("Location:home.php");
}
}
?>
<html>
<head>
<title>Feedback</title>
<title>QuickShare</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
<script>
</script>
<style>
body{
background-color: gray;
background-image: url("background.png");
}
#myProgress {
width: 100%;
background-color: grey;
}
#myBar {
width: 1%;
height: 30px;
background-color:black;
}
.navbar{
background-color: lightblue;
border: lightblue;
font-family: 'Playfair Display', serif;
}
</style>
</head>
<body>
<div>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#"><b>QuickShare</b></a>
</div>
<ul class="nav navbar-nav">
<li><a href="home.php">Home</a></li>
<li class="active"><a href="feeback.php">FeedBack</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Logout</a></li>
</ul>
</div>
</nav> </div>
<div class="wrap">
<form method="POST">
<h2>Feedback</h2>
<input type="text" name="username" placeholder="Your username..."/>
<textarea name="textarea01" id="textarea01" placeholder="Enter the Feedback..."></textarea>
<button id="submit" name="submit" class="btn-login">Submit</button>
</div>
</form>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Home</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="HMstyle.css">
<script>
$(document).ready(function(){
$("#search").keyup(function(){
var query=$(this).val();
if(query!=' '){
$.ajax({
url:"search.php",
method:"POST",
data:{query:query},
success:function(data){
$('#searchtryList').fadeIn();
$('#searchtryList').html(data);
}
});
}
});
$(document).on('click','li',function(){
$('#search').val($(this).text());
$('#searchtryList').fadeOut(function(){
});
});
});
</script>
<style>
body{
background-color:black;
}
.navbar{
width:-30;
}
ul{
background-color:lightblue;
cursor:pointer;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm3">
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#"><b>QuickShare</b></a>
</div></div>
<div class="col-sm-3">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#"><b><?php
session_start();
if(isset($_SESSION['currentuser'])){
echo $_SESSION['currentuser'];
}
else{
header("Location:login.php");
}
?></b></a></li>
</div>
<col-sm-2>
</ul>
<form class="navbar-form navbar-left">
<div class="form-group">
<input type="text" class="form-control" id="search" placeholder="Search QuickShare">
<div id="searchtryList"></div>
</div>
</div>
</div>
<div>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">More
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="update.php">Update Profile</a></li>
<li><a href="feeback.php">feedback</a></li>
<li><a href="deactivate.php">setting</a></li>
</ul>
<li><a href="logout.php"><span class="glyphicon glyphicon-log-in"></span>Log out</a></li>
</ul>
<div>
</div>
</form>
</div></div>
</nav>
<div class="jumbotron">
<div class="container text-center">
<h1><?php
$server="localhost";
$user="root";
$pass="";
$Db="members";
if(isset($_SESSION['currentuser'])){
echo $_SESSION['currentuser'];
}
?>
</h1>
<p>
<?php
$server="localhost";
$user="root";
$pass="";
$Db="members";
$link=mysqli_connect($server,$user,$pass,$Db);
$id=$_SESSION['id'];
if($id>0){
$result=mysqli_query($link,"select bio from users where id='$id'");
if($result===false){
die("Database Error");
}
if(mysqli_num_rows($result)==0){
die("No such data exsist");
}
$display=mysqli_fetch_assoc($result);
echo $display['bio'];
}
?></p>
</div>
</div>
<div class="container-fluid bg-3 text-center">
<div class="row">
<div class="col-sm-3">
<p>Some text..</p>
<img src="WhatsApp Image 2017-03-13 at 11.24.14 AM.jpeg" class="img-responsive" style="width:100%" alt="Image">
</div>
<div class="col-sm-3">
<p>Some text..</p>
<img src="WhatsApp Image 2017-03-13 at 11.25.32 AM.jpeg" class="img-responsive" style="width:100%" alt="Image">
</div>
<div class="col-sm-3">
<p>Some text..</p>
<img src="WhatsApp Image 2017-03-13 at 11.26.04 AM.jpeg" class="img-responsive" style="width:100%" alt="Image">
</div>
<div class="col-sm-3">
<p>Some text..</p>
<img src="WhatsApp Image 2017-03-13 at 11.29.33 AM.jpeg" class="img-responsive" style="width:100%" alt="Image">
</div>
</div>
</div><br>
<div class="container-fluid bg-3 text-center">
<div class="row">
<div class="col-sm-3">
<p>Some text..</p>
<img src="WhatsApp Image 2017-03-13 at 11.32.40 AM.jpeg" class="img-responsive" style="width:100%" alt="Image">
</div>
<div class="col-sm-3">
<p>Some text..</p>
<img src="WhatsApp Image 2017-03-13 at 11.33.01 AM.jpeg" class="img-responsive" style="width:100%" alt="Image">
</div>
<div class="col-sm-3">
<p>Some text..</p>
<img src="WhatsApp Image 2017-03-13 at 11.33.21 AM.jpeg" class="img-responsive" style="width:100%" alt="Image">
</div>
<div class="col-sm-3">
<p>Some text..</p>
<img src="WhatsApp Image 2017-03-13 at 11.33.25 AM.jpeg" class="img-responsive" style="width:100%" alt="Image">
</div>
</div>
</div><br><br>
<div class="container-fluid bg-2 text-center">
<form action="home.php">
<footer class="container-fluid text-center">
<p>Footer Text</p>
</footer>
</body>
</html>
<!DOCTYPE html>
<?php
session_start();
include 'db.php'; ?>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<title>chat system </title>
<link rel="stylesheet" href="style.css" media="all"/>
<script>
function ajax()
{
var req=new XMLHttpRequest();
req.onreadystatechange=function()
{
if(req.readyState ==4 && req.status==200)
{
document.getElementById('chat').innerHTML =req.responseText;
}
}
req.open('GET','chat.php',true);
req.send();
}
setInterval(function(){ajax()},1000);
</script>
<style>
@import url('https://fonts.googleapis.com/css?family=Asar|Playfair+Display');
body{
background-color:black;
}
.navbar {
margin-bottom: 0;
border-radius: 0;
font-family: 'Playfair Display', serif;
}
.navbar{
height: 40px;
background-color:lightblue;
border: lightblue;
}
</style>
</head>
<body onload="ajax();">
<div class="container">
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#"><b>QuickShare</b></a>
</div>
<ul class="nav navbar-nav">
<li><a href="home.php">Home</a></li>
<li class="active"><a href="#">Tech Support</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<ul class="nav navbar-nav">
<ul class="nav navbar-nav ">
<li><a href="logout.php"><span class="glyphicon glyphicon-log-in"></span> Logout</a></li>
</ul>
</div>
</nav>
<div id="container">
<div id="chat_box">
<div id="chat"></div>
</div>
<form action="index.php" method="POST">
<div class="form-group">
<label for="name">Username</label>
<input type="text" class="form-control" name="name" id="name" aria-describedby="name" value="<?php echo $_SESSION['currentuser'] ?>"readonly>
</div>
<div class="form-group">
<label for="msg">Message</label>
<input type="text" class="form-control" name="msg" id="msg" aria-describedby="msg" placeholder="Enter Message">
</div>
<input type="submit" class="btn btn-primary" id="submit" name="submit" value="send it"/>
</form>
<?php
$db=mysqli_connect("localhost","root","","members");
if(isset($_POST['submit']))
{
$name=$_POST['name'];
$msg=$_POST['msg'];
$insert="insert into chat (name,msg) values ('$name','$msg')";
$run=mysqli_query($db,$insert);
if($run)
{
}
}
?>
</div>
</div>
</body>
</html>
<?php
session_start();
$server="localhost";
$user="root";
$pass="";
$Db="members";
$link=mysqli_connect($server,$user,$pass,$Db);
if(isset($_POST['idcatcher'])){
}
if(isset($_POST['submit'])){
$name=$_POST['username'];
$password=$_POST['password'];
$passwordmd5=md5($password);
$jsqla=mysqli_query($link,"select id from users where name='".$name."' and password='".$passwordmd5."'");
$jfeta=mysqli_fetch_assoc($jsqla);
$id=$jfeta['id'];
echo $_SESSION['id']=$id;
$check_database_query=mysqli_query($link,"select * from users where name='".$name."' AND password='".$passwordmd5."'");
$check_no_of_row=mysqli_num_rows($check_database_query);
if(isset($_POST['chk'])){
$chk="checked";
}
else{
$chk="unchecked";
}
if($check_no_of_row==1){
if($chk==checked){
setcookie("username",$username,time() +(86400 * 10) );
}
$row=mysql_fetch_array[$check_database_query];
$username=$row['username'];
$_SESSION['currentuser']=$name;
header("Location:home.php");
}
else{
header("Location:login.php");
}
}
?>
<html>
<head>
<title>QuickShare</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
<script>
function move() {
var elem = document.getElementById("myBar");
var width = 1;
var id = setInterval(frame, 10);
function frame() {
if (width >= 100) {
clearInterval(id);
} else {
width++;
elem.style.width = width + '%';
}
}
}
$(function() {
var body = $('body');
var backgrounds = ['url("explore.png")', 'url("Blackbird.png")','url("people.png")','url("life.png")'];
var current = 0;
function nextBackground() {
body.css(
'background',
backgrounds[current = ++current % backgrounds.length]
);
setTimeout(nextBackground, 5000);
}
setTimeout(nextBackground, 5000);
body.css('background', backgrounds[0]);
});
</script>
<style>
body{
background-color: gray;
}
#myProgress {
width: 100%;
background-color: grey;
}
#myBar {
width: 1%;
height: 30px;
background-color:black;
}
.navbar{
background-color:lightblue;
border: lightblue;
}
</style>
</head>
<body>
<div>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#"><b>QuickShare</b></a>
</div>
<ul class="nav navbar-nav navbar-right">
<li><a href="Signup.php"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
</ul>
</div>
</nav>
</div>
<div class="wrap">
<form method="POST" action="login.php">
<h2>Login Form</h2>
<input type="text" id="username" name="username" placeholder="Your username..."/>
<input type="password" id="password" name="password" placeholder="Your password..."/>
<button class="btn-login" name="submit" id="submit" onclick="move()">Login</button>
</br>
<label for="chk">Remember me</label>
<input type="checkbox" name="chk" class="chk" value="Remember me" style="width: 15px; height: 15px"></br>
<a href="update01.php"> Forgot Password?</a>
</div>
</br></br></br></br>
</form>
</body>
</html>
<?php
session_start();
session_destroy();
setcookie("username","",time() - (86400 * 10));
unset($_SESSION['username']);
header("Location:login.php");
?>
<?php
$connect=mysqli_connect("localhost","root","","members");
if(isset($_POST["query"])){
$output='';
$query="select * from users where name LIKE '%".$_POST["query"]."%'";
$result=mysqli_query($connect,$query);
$output='<ul class="list-unstyled">';
if(mysqli_num_rows($result)>0){
while($row=mysqli_fetch_array($result)){
$output.='<li>'.$row["name"].'</li>';
}
}
else{
$output.='<li>name Not Found</li>';
}
$output.='</ul>';
echo $output;
}
?>
<?php
//session_start();
$server="localhost";
$user="root";
$pass="";
$table="members";
$link=mysqli_connect($server,$user,$pass,$table);
if(isset($_POST['submit'])){
$name=$_POST['name'];
$email=$_POST['email'];
$password=$_POST['password'];
$newpassword=md5($password);
$status=$_POST['status'];
$bio=$_POST['bio'];
$country=$_POST['country'];
// $_SESSION['bio']=$bio;
$query="insert into users(name,email,password,status,country,bio) values('$name','$email','$newpassword','$status','$country','$bio')";
if($result=mysqli_query($link,$query)){
// $_SESSION['bio'];
header("Location:login.php");
}
}
?>
<html>
<head>
<title>Sign Up</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style>
@import url('https://fonts.googleapis.com/css?family=Asar|Playfair+Display');
body{
background-image: url("explore.png");
font-family: 'Playfair Display', serif;
}
#outer{
height: 600px;
width: 1000px;
}
#form{
height: 430px;
width: 220px;
opacity: 0.8;
background-color: black;
font-family: 'Playfair Display', serif;
margin-left: 1000px;
margin-top: 100px;
}
.a{
height: 40px;
width: 180px;
border-radius: 5px;
margin-top: 20px;
margin-left: 20px;
}
.b{
height: 40px;
width: 180px;
border-radius: 5px;
margin-top: 20px;
margin-left: 20px;
background-color: lightblue;
}
.navbar{
background-color: lightblue;
border: lightblue;
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#"><b>QuickShare</b></a>
</div>
<ul class="nav navbar-nav navbar-right">
<li><a href="login.php"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>
</div>
</nav>
<div id="outer">
<div id="form">
<form action="Signup.php" method="POST">
<input class="a" type="text" name="name" placeholder="Enter your Name"/>
<input class="a" type="email" name="email" placeholder="Enter your Email"/>
<input class="a" type="password" name="password" placeholder="Enter your Password"/>
<input class="a" type="text" name="status" placeholder="Enter your Status"/>
<input class="a" type="text" name="country" placeholder="Enter your Country "/>
<input class="a" type="text" name="bio" placeholder="Enter your Short Bio"/>
<input class="b" type="submit" id="submit" name="submit" value="Submit"/>
</form>
</div>
</div>
</body>
</html>
@import url('https://fonts.googleapis.com/css?family=Asar|Playfair+Display');
body{
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
background-color: #349Bdb;
}
.wrap h2{
text-align: center;
margin-bottom: 30px;
font-family: 'Asar', serif;
}
.wrap{
width: 440px;
overflow: hidden;
margin: auto;
margin-top: 180px;
padding: 20px;
background:#fff;
border:1px solid silver;
border-radius: 5px;
font-family: 'Asar', serif;
}
.navbar-brand{
font-family: 'Playfair Display', serif;
}
.wrap input{
width: 400px;
height: 35px;
margin-bottom: 10px;
border-radius: 3px;
border: 1px solid silver;
padding: 5px;
}
.wrap textarea{
width: 400px;
height: 90px;
margin-bottom: 10px;
border-radius: 3px;
border: 1px solid silver;
padding: 5px;
}
.wrap .btn-login{
padding:5px;
font-size: 18px;
width: 401px;
height: 40px;
background-color: lightblue;
color: white;
border-radius: 3px;
border:0;
}
.enemyRating{
margin: 0px;
padding: 0px;
}
#r1{
margin: 0px;
padding: 0px;
padding-right: 2px;
margin-left: auto;
margin-right: auto;
width: 28px;
}
#r1:hover{
cursor: default;
}
.ratings {
bottom: 0px;
width: 4px;
background: #ddd;
vertical-align: bottom;
display: inline-block;
padding: 0px;
margin: 0px;
position: relative;
margin-right: -4px;
border: 1px solid #fff;
}
.ratings:hover{
cursor: pointer;
}
.level_1{
height:5px;
opacity: 0.4;
filter: alpha(opacity=40);
}
.level_2{
height:7px;
opacity: 0.55;
filter: alpha(opacity=55);
}
.level_3{
height:9px;
opacity: 0.7;
filter: alpha(opacity=70);
}
.level_4{
height:11px;
opacity: 0.85;
filter: alpha(opacity=85);
}
.level_5{
height:13px;
opacity: 1;
filter: alpha(opacity=100);
}
.innactive{
background: #ddd;
}
*
{
padding:0;
margin:0;
border:0;
}
body
{
background-color:silver;
}
#container
{
width:40%;
background:white;
margin:0 auto;
padding:20px;
}
#chat_box
{
width:90%;
height:400px;
}
#chat_data
{
font-weight:bold;
border-bottom:1px solid silver;
}
input[type='text']
{
width:100%;
height:40px;
border:1px solid gray;
border-radius:5px;
}
input[type='submit']
{
width:100%;
height:40px;
border:1px solid gray;
border-radius:5px;
}
input[type='submit']:hover
{
background:black;
color:white;
}
textarea
{
width:100%;
height:40px;
border:1px solid gray;
border-radius:5px;
}
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
@import url('https://fonts.googleapis.com/css?family=Asar|Playfair+Display');
body{
background-color:black;
}
.navbar {
margin-bottom: 0;
border-radius: 0;
font-family: 'Playfair Display', serif;
}
.navbar{
height: 40px;
background-color:lightblue;
border: lightblue;
}
.form-group{
margin:0 auto;
width:400;
}
.btn{
margin:0 auto;
width:400;
margin-left:370;
}
.division{
margin-top:150;
}
</style>
</head>
<body> <div class="container">
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#"><b>QuickShare</b></a>
</div>
<ul class="nav navbar-nav">
<li><a href="home.php">Home</a></li>
<li class="active"><a href="#">Update Profile</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<ul class="nav navbar-nav">
<ul class="nav navbar-nav ">
<li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Logout</a></li>
</ul>
</div>
</nav>
<form action='update.php' method="post">
<div class="division">
<div class="form-group">
<label for="UpdateUsername">Update Username</label>
<input type="text" class="form-control" name="username" id="username" aria-describedby="NewUsername" placeholder="Enter Email">
<small id="NewUsername" class="form-text text-muted">Please,Enter the new username.</small>
</div>
<div class="form-group">
<label for="bio">Update Bio</label>
<input type="text" class="form-control" name="bio" id="bio" aria-describedby="NewBio" placeholder="Enter New Bio">
<small id="NewUsername" class="form-text text-muted">Please,Enter the new Bio.</small>
</div>
<button type="submit" name="update_val" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</body>
</html>
<?php
session_start();
$link=mysqli_connect('localhost','root','',"members");
if(isset($_POST['update_val'])){
$newusername=$_POST['username'];
$username=$_SESSION['currentuser'];
$bio=$_POST['bio'];
$query1="select id from users where name='$username'";
$result=mysqli_query($link,$query1);
$display=mysqli_fetch_assoc($result);
$id=$display['id'];
$query="update users set bio='$bio' where id='$id'";
if(mysqli_query($link,$query)){
$query2="update users set name='$newusername'";
if(mysqli_query($link,$query2)){
$_SESSION['currentuser']=$newusername;
header("location:home.php");
}
}
}
?>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
<style>
@import url('https://fonts.googleapis.com/css?family=Asar|Playfair+Display');
body{
background-color:black;
}
.navbar {
margin-bottom: 0;
border-radius: 0;
font-family: 'Playfair Display', serif;
}
.navbar{
height: 40px;
background-color:lightblue;
border: lightblue;
}
.form-group{
margin:0 auto;
width:400;
}
.btn{
margin:0 auto;
width:400;
margin-left:483;
}
.division{
margin-top:150;
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#"><b>QuickShare</b></a>
</div>
<ul class="nav navbar-nav navbar-right">
<ul class="nav navbar-nav">
<ul class="nav navbar-nav ">
<li><a href="login.php"><span class="glyphicon glyphicon-log-in"></span> Log in</a></li>
</ul>
</div>
</nav>
<form action='update01.php' method="post">
<div class="division">
<div class="form-group">
<label for="UpdateUsername">Username</label>
<input type="text" class="form-control" name="username" id="username" aria-describedby="NewUsername" placeholder="Enter Username">
<small id="NewUsername" class="form-text text-muted">Please,Enter the username.</small>
</div>
<div class="form-group">
<label for="UpdateUsername">New Password</label>
<input type="text" class="form-control" name="password" id="password" password aria-describedby="NewUsername" placeholder="Enter Password">
<small id="NewUsername" class="form-text text-muted">Please,Enter the Password.</small>
</div>
</div>
<input type="submit" class="btn btn-primary" name="update_val" value="update now">
</form>
</body>
</html>
<?php
$link=mysqli_connect('localhost','root','',"members");
if(isset($_POST['update_val']))
{
$username=$_POST['username'];
$password=$_POST['password'];
$newpassword=md5($password);
$query1="select id from users where name='$username'";
$result=mysqli_query($link,$query1);
$display=mysqli_fetch_assoc($result);
$id=$display['id'];
$query = "update users set password='$newpassword' where id='$id'";
if(mysqli_query($link,$query))
{
header("location: login.php");
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment