Table for specific user - php

This is a concept question. Right now I have a registration/login and a profile page system built using php and mysql, but I have one question.
I want a user to be able to make their own specific todos. So when they login they can see their todo and create their todo for them selves. Only their login can access their todo. But I don't understand how to do that in php/mysql.
Here is my login page:
<?php
session_start();
require_once('PhpConsole.phar');
require_once('connection.php');
ob_start();
require('index.php');
$data = ob_get_clean();
ob_end_clean();
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://rawgit.com/marcoceppi/bootstrap-glyphicons/master/css/bootstrap.icon-large.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="lib/sweetalert.css">
<script src="lib/sweetalert-dev.js"></script>
</head>
<body>
<div id="page">
<form method = "post" role = "form" id = "form">
<h1 style = "position:relative; left:60px; font-family: Impact;">Login </h1>
<div class="col-xs-2">
<div class="inner-addon left-addon">
<i class="glyphicon glyphicon-envelope"></i>
<input type="text" class="form-control" id = "email" name = "loginemail" placeholder="Email" />
</div>
</div>
<br>
<div class="col-xs-2">
<div class="inner-addon left-addon">
<img src = "http://i.imgur.com/GqkLI3z.png" id = "imgLock"/>
<input type="text" class="form-control" name = "loginpassword" placeholder="Password" id = "password" />
</div>
</div>
<br>
<br>
<div id = "buttons">
<div class="col-xs-2">
<div class="inner-addon left-addon">
<i class="glyphicon glyphicon-ok-sign" ></i>
<input type = "submit" class="btn btn-info" name = "loginsubmit" id = "submit"/>
</div>
<div>
</div>
</form>
</div>
<?php
if(isset($_POST["loginsubmit"])){
$loginEmail = $_POST["loginemail"];
$loginPassword = $_POST["loginpassword"];
if ($query = mysqli_query($connection, "SELECT * FROM `authe` WHERE Email = '".$loginEmail."' AND Password = '".$loginPassword."' ")) {
$rows = mysqli_num_rows($query);
if($rows>0){
echo "<script> swal('Good job!', 'Sucessfully Authenticated', 'success')</script>";
$_SESSION['email'] = $loginEmail;
$_SESSION['password'] = $loginPassword;
if(true){
// header("Location: http://localhost:8012/phpForm/Profile.php");
if ($queryTwo = mysqli_query($connection, "SELECT Username FROM `authe` WHERE Email = '".$loginEmail."'")) {
$rowsTwo = mysqli_num_rows($queryTwo);
if($rowsTwo>0){
printf($rowsTwo);
while($roww = mysqli_fetch_array($queryTwo))
{
$_SESSION["username"] = $roww['Username'];
}
}
}
echo "<script> window.location.href = 'http://localhost:8012/phpForm/Profile.php' </script>";
}
}
else {
echo "<script>sweetAlert('Oops...', 'Authentication Failed', 'error');</script>";
}
}
}
?>
</body>
</html>
<!-- <br>
<input type = "text" class="form-control" name = "loginemail" style = "width = 20px;" id = "input" placeholder = "Enter Email" required/>
<i class="glyphicon glyphicon-user form-control-feedback"></i>
<br> -->
And my profile page:
<?php
session_start();
require_once('PhpConsole.phar');
require_once('connection.php');
ob_start();
require('index.php');
$data = ob_get_clean();
ob_end_clean();
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://rawgit.com/marcoceppi/bootstrap-glyphicons/master/css/bootstrap.icon-large.css">
<link rel="stylesheet" href="main.css">
<script src="https://code.angularjs.org/1.4.9/angular.js"></script>
<link href='https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:700' rel='stylesheet' type='text/css'>
<script src = "page.js"></script>
<link rel="stylesheet" href="lib/sweetalert.css">
<script src="lib/sweetalert-dev.js"></script>
<style>
#toDoButton {
position: relative;
color: rgba(255,255,255,1);
text-decoration: none;
background-color: rgba(219,87,5,1);
font-family: 'Yanone Kaffeesatz';
font-weight: 700;
right:550px;
bottom:70px;
font-size: 3em;
display: block;
padding: 4px;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
-webkit-box-shadow: 0px 9px 0px rgba(219,31,5,1), 0px 9px 25px rgba(0,0,0,.7);
-moz-box-shadow: 0px 9px 0px rgba(219,31,5,1), 0px 9px 25px rgba(0,0,0,.7);
box-shadow: 0px 9px 0px rgba(219,31,5,1), 0px 9px 25px rgba(0,0,0,.7);
margin: 100px auto;
width: 160px;
text-align: center;
-webkit-transition: all .1s ease;
-moz-transition: all .1s ease;
-ms-transition: all .1s ease;
-o-transition: all .1s ease;
transition: all .1s ease;
}
#toDoButton:active {
-webkit-box-shadow: 0px 3px 0px rgba(219,31,5,1), 0px 3px 6px rgba(0,0,0,.9);
-moz-box-shadow: 0px 3px 0px rgba(219,31,5,1), 0px 3px 6px rgba(0,0,0,.9);
box-shadow: 0px 3px 0px rgba(219,31,5,1), 0px 3px 6px rgba(0,0,0,.9);
}
</style>
</head>
<body>
<div id="page" ng-app = "pageApp" ng-controller="pageController">
<h1>Welcome <?php echo $_SESSION['username']; ?></h1>
<h5>Here is one cool feauture. Type in the box :)</h5>
<div class = "coolFeauture" id = "CoolFeauture1">
<input type = "text" ng-model = "CoolFeauture"/>
<div ng-bind = "CoolFeauture"></div>
</div>
<div class = "todoMain">
<h4>Click on the button for a TODO App! Check it out!</h4>
Todo
</div>
</div>
<?php
?>
</body>
</html>
<!-- <br>
<input type = "text" class="form-control" name = "loginemail" style = "width = 20px;" id = "input" placeholder = "Enter Email" required/>
<i class="glyphicon glyphicon-user form-control-feedback"></i>
<br> -->

Since it is a concept question, and you mentioned that the login / register system is already done, what you need to do is:
Log them in saving a unique $_SESSION['id'], or an expirable unique key.
Additionally you may save cookies to identify their account
In the todo.php page:
Make sure that they are logged in by checking $_SESSION['id'] (if it has been set, else redirect somewhere or pop up a message).
Query their current stored TODOs by something like SELECT * FROM todo WHERE user='id'
Display a <textarea> or similar to store new TODO (which you can do by a POST to the same page).
If the page gets a POST request:
Store new TODOs by INSERT INTO todo('id', 'sanitized $_POST["text"]')
Also, always make sure to sanitize variables before doing any of these queries.

Related

How to store the image ID and image of a set of shuffling images in array

I'm a newbie and still learning how to code. So, any help is much appreciated. This is what I have in an
image of what's done so far.
How do I save the selected radio button's image ID and the image itself to my database in PHPMyAdmin? I tried but couldn't figure it out. I would also want to repeat this process three times since the user must select three pictures(1 per submit). Users also should not be allowed to choose the same picture again. Perhaps if a picture is selected, it won't be displayed again in the second and third rounds. Below is my code.
include_once 'database.php';
// Create Level 2 password
if (isset($_POST['submit'])) {
header("LOCATION: registration_l3.php");
try {
$stmt = $conn->prepare("INSERT INTO tbl_pass_level_2(fld_user_id, fld_image_id, fld_image) VALUES(:uid, :iid, :image)");
$stmt->bindParam(':uid', $uid, PDO::PARAM_STR);
$stmt->bindParam(':iid', $iid, PDO::PARAM_STR);
$stmt->bindParam(':image', $image, PDO::PARAM_STR);
$uid = $_POST['uid'];
$iid = $_POST['iid'];
$image = $_POST['image'];
$stmt->execute();
}
catch(PDOException $e)
{
echo "Error: " . $e->getMessage();
}
}
// Auto increment for User ID
$num = $conn->query("SELECT MAX(fld_user_id) AS uid FROM tbl_pass_level_2")->fetch()['uid'];
if ($num){
$num = ltrim($num, 'U')+1;
$num = 'U'.str_pad($num,2,"0",STR_PAD_LEFT);
}
else{
$num = 'U'.str_pad(1,2,"0",STR_PAD_LEFT);
}
$pic = array('1.png','2.png','3.png','4.png','5.png','6.png','7.png','8.png','9.png','10.png','11.png','12.png','13.png','14.png','15.png','16.png','17.png','18.png','19.png','20.png');
shuffle($pic);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Register-Password Level 2</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
body {
background: linear-gradient(to bottom, #ff6699 0%, #ffcc99 100%)fixed;
font: 18px Tahoma, sans-serif;
color: black;
text-align: center;
}
p {font-size: 16px;}
.margin {margin-bottom: 35px;}
.container-fluid {
padding-top: 50px;
padding-bottom: 50px;
}
div {
margin-bottom: 20px;
}
label {
display: inline-block;
width: 100px;
text-align: center;
}
input[type=submit] {
background-color: #ff0066;
border: 2px solid #000000 ;
color: black;
text-decoration: none;
cursor: pointer;
display: inline-block;
width: 120px;
text-align:center;
}
.center {
display: flex;
flex-flow: row wrap;
position: relative;
width: auto;
margin-left: auto;
margin-right: auto;
}
li {
flex: 1 1 16%;
height: auto;
margin: 20px;
margin-right: 40px;
padding: 20px 0;
width: auto;
border: 2px solid #000000 ;
}
.buttonHolder{ text-align: center;}
#footer {
position: relative;
padding: 10px 10px 0px 10px;
bottom: 0;
width: 100%;
/* Height of the footer*/
height: 40px;
}
</style>
</head>
<body>
<div class="container-fluid text-center">
<h2 class="margin"> <b>3 LEVEL PASSWORD AUTHENTICATION <br>SECURITY SYSTEM<b></h2>
<h3 class="margin"><b>LEVEL 2 PASSWORD REGISTRATION </b></h3>
<h4 class="margin">CHOOSE 3 OUT OF 10 DISPLAYED IMAGES </h4>
<label>User ID :</label>
<input name="uid" type="text" id="userid" placeholder="User ID" value="<?php echo $num; ?>"readonly>
<?php
if (isset($_SESSION['error'])) {
echo "<p class='text-danger text-center'>{$_SESSION['error']}</p>";
unset($_SESSION['error']);
}
?>
<form method="post">
<ul>
<div class="center">
<?php
for($i=0;$i<10;$i++)
echo "<li style = \"display:inline-block;\"><input type = \"radio\" name = \"iid\"><img src = \"$pic[$i]\" name=\"image\" width=\"50%\" height=\"150\" class=\"center\" ></li>";
?>
</div>
</ul>
<h4 class="margin text-center"> 1 OUT OF 3 </h4>
<div class="buttonHolder">
<input type="hidden" name="matricnum" value="a174559">
<?php { ?>
<input type="submit" name="submit" value="Submit" align="text-center">
<?php } ?>
</div>
</form>
<!-- Footer -->
<footer class="footer text-center" id=footer>
<p>Copyright � S.SASHNEETA 2022</p>
</footer>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</body>
</html>

PHP Gives no error and does not fill items into database

I am trying to get secq (secret question) and seca (secret answer) into the database.
I get no errors when I go through the registration progress, and when I echo the variables it goes through POST fine.
If you see the image above everything is fine except for the fact that secq and seca are not going into database.
How can I fix it?
Code:
<?php
// Include config file
require_once "config.php";
// Define variables and initialize with empty values
$username = $password = $confirm_password = $secq = $seca = "";
$username_err = $password_err = $confirm_password_err = "";
// Processing form data when form is submitted
if($_SERVER["REQUEST_METHOD"] == "POST"){
// Validate username
if(empty(trim($_POST["username"]))){
$username_err = "Please enter a username.";
} else{
// Prepare a select statement
$sql = "SELECT id FROM users WHERE username = ?";
if($stmt = mysqli_prepare($link, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "s", $param_username);
// Set parameters
$param_username = trim($_POST["username"]);
$param_seca = trim($_POST["seca"]);
$param_secq = trim($_POST["secq"]);
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
/* store result */
mysqli_stmt_store_result($stmt);
if(mysqli_stmt_num_rows($stmt) == 1){
$username_err = "This username is already taken.";
} else{
$username = trim($_POST["username"]);
}
} else{
echo "Oops! Something went wrong. Please try again later.";
}
}
// Close statement
mysqli_stmt_close($stmt);
}
// Validate password
if(empty(trim($_POST["password"]))){
$password_err = "Please enter a password.";
} elseif(strlen(trim($_POST["password"])) < 6){
$password_err = "Password must have atleast 6 characters.";
} else{
$password = trim($_POST["password"]);
}
// Validate confirm password
if(empty(trim($_POST["confirm_password"]))){
$confirm_password_err = "Please confirm password.";
} else{
$confirm_password = trim($_POST["confirm_password"]);
if(empty($password_err) && ($password != $confirm_password)){
$confirm_password_err = "Password did not match.";
}
}
// Check input errors before inserting in database
if(empty($username_err) && empty($password_err) && empty($confirm_password_err)){
// Prepare an insert statement
$sql = "INSERT INTO users (username, password, secq, seca) VALUES (?, ?, ?, ?)";
if($stmt = mysqli_prepare($link, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "ssss", $param_username,$param_password,$param_secq,$param_seca);
// Set parameters
$param_username = $username;
$param_password = password_hash($password, PASSWORD_DEFAULT); // Creates a password hash
$param_secq = $secq;
$param_seca = $seca;
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
// Redirect to login page
header("location: login.php");
} else{
echo "Something went wrong. Please try again later.";
}
}
// Close statement
mysqli_stmt_close($stmt);
}
// Close connection
mysqli_close($link);
}
?>
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8>
<meta name=viewport content="width=device-width, initial-scale=1" />
<meta property=og:url content="https://treasurebits.net/" />
<meta property=og:type content=website />
<meta property=og:title content=TreasureBits />
<meta property=og:description content="Welcome to TreasureBits.net! This website offers various cryptocurrency faucets and strategies to its users to earn free cryptocurrencies. The users can vary from beginners to pros and will help you maximize your micro earnings!" />
<meta property=og:image content="https://treasurebits.net/images/treasure.png" />
<meta name=description content="Welcome to TreasureBits.net! This website offers various cryptocurrency faucets and strategies to its users to earn free cryptocurrencies. The users can vary from beginners to pros and will help you maximize your micro earnings!">
<script src="/cdn-cgi/apps/head/C3ZYTVLv_F3wN8HVuyz6VVxx6mU.js"></script><link rel="shortcut icon" href="https://treasurebits.net/images/bitcoinlogo.png" />
<title>TreasureBits</title>
<script type="2215151d9caf119f7aa679d7-text/javascript">(function (a, b, c) {Object.defineProperty(a, b, {value: c});})(window, 'absda', function () {var _0xf75e=['span','setAttribute','height: inherit; position: relative;','color: white; cursor: pointer; font-size: 50px; font-weight: bold; position: absolute; right: 30px; top: 20px;','innerHTML','ADBLOCK DETECTED<br/>Unfortunately AdBlock might cause a bad affect on displaying content of this website. Please, deactivate it.','✖','click','parentNode','removeChild','addEventListener','createElement','div',' ','className','style','position','absolute','left','-99999px','body','appendChild','offsetHeight'];(function(_0x1b51b2,_0x292bdf){var _0x266de7=function(_0x4a062c){while(--_0x4a062c){_0x1b51b2['push'](_0x1b51b2['shift']());}};_0x266de7(++_0x292bdf);}(_0xf75e,0xc2));var _0x4e13=function(_0x31e2a4,_0x4eccd5){_0x31e2a4=_0x31e2a4-0x0;var _0x2f1ef2=_0xf75e[_0x31e2a4];return _0x2f1ef2;};window[_0x4e13('0x0')]('DOMContentLoaded',function(){var _0x1b0f57=document[_0x4e13('0x1')](_0x4e13('0x2'));_0x1b0f57['innerHTML']=_0x4e13('0x3'),_0x1b0f57[_0x4e13('0x4')]='adsBox',_0x1b0f57[_0x4e13('0x5')][_0x4e13('0x6')]=_0x4e13('0x7'),_0x1b0f57[_0x4e13('0x5')][_0x4e13('0x8')]=_0x4e13('0x9'),document[_0x4e13('0xa')][_0x4e13('0xb')](_0x1b0f57),setTimeout(function(){if(0x0===_0x1b0f57[_0x4e13('0xc')]){var _0x2adb51=document[_0x4e13('0x1')](_0x4e13('0x2')),_0x5d5bc3=document[_0x4e13('0x1')](_0x4e13('0x2')),_0x554d62=document[_0x4e13('0x1')](_0x4e13('0xd')),_0x24dd7d=document[_0x4e13('0x1')]('p');_0x2adb51[_0x4e13('0xe')](_0x4e13('0x5'),'background-color: black; height: 100%; left: 0; opacity: .7; top: 0; position: fixed; width: 100%; z-index: 2147483650;'),_0x5d5bc3[_0x4e13('0xe')](_0x4e13('0x5'),_0x4e13('0xf')),_0x554d62[_0x4e13('0xe')](_0x4e13('0x5'),_0x4e13('0x10')),_0x24dd7d[_0x4e13('0xe')](_0x4e13('0x5'),'color: white; font-size: 35px; font-weight: bold; left: 0; line-height: 1.5; margin-left: 25px; margin-right: 25px; text-align: center; top: 150px; position: absolute; right: 0;'),_0x24dd7d[_0x4e13('0x11')]=_0x4e13('0x12'),_0x554d62[_0x4e13('0x11')]=_0x4e13('0x13'),_0x5d5bc3['appendChild'](_0x24dd7d),_0x5d5bc3[_0x4e13('0xb')](_0x554d62),_0x554d62[_0x4e13('0x0')](_0x4e13('0x14'),function(){_0x2adb51[_0x4e13('0x15')][_0x4e13('0x16')](_0x2adb51);}),_0x2adb51[_0x4e13('0xb')](_0x5d5bc3),document[_0x4e13('0xa')][_0x4e13('0xb')](_0x2adb51);}},0xc8);});});</script><script type="2215151d9caf119f7aa679d7-text/javascript" onerror="absda()" src='//4bb6jls06l.com/78/80/3a/78803a0cc569feed08a77531ad75b00b.js'></script>
<meta name="maValidation" content="cf9394b6bba261d9134e60717a751c5b" />
</head>
<body width="width: 50%;">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<style>
.w3-sidebar a, .dropdown-btn {
padding: 14px 10px 14px 10px;
text-decoration: none;
font-size: 14px;
color: #818181;
display: block;
border: none;
background: none;
width:100%;
text-align: left;
cursor: pointer;
outline: none;
}
.w3-sidebar a:hover, .dropdown-btn:hover {
color: #f1f1f1;
border: none;
}
.active {
background-color: #A9A9A9;
color: white;
border: none;
}
.dropdown-container {
display: none;
border: none;
background-color: #262626;
padding-left: 50px;
}
.fa-caret-down {
float: right;
padding-right: 1px;
border: none;
}
hr {
display: block;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: 10px;
margin-right: 10px;
border-style: inset;
border-width: 1px;
color: #262626;
}
figure {
display: inline-block;
border: none;
}
figure1 {
display: inline-block;
border: none;
}
.icon-bar a {
float: left;
display: inline;
text-align: center;
padding: 0px 15px;
font-size: 26px;
text-decoration: none;
color: #818181;
border: none;
background: none;
cursor: pointer;
}
.icon-bar a:hover {
color: #f1f1f1;
}
::-webkit-scrollbar {
width: 10px;
}
::-webkit-scrollbar-track {
box-shadow: inset 0 0 5px grey;
border-radius: 10px;
}
::-webkit-scrollbar-thumb {
background: #696969;
border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
background: #696969;
}
#keyframes shake {
0% { transform: translate(1px, 1px) rotate(0deg); }
10% { transform: translate(-1px, -2px) rotate(-1deg); }
20% { transform: translate(-3px, 0px) rotate(1deg); }
30% { transform: translate(3px, 2px) rotate(0deg); }
40% { transform: translate(1px, -1px) rotate(1deg); }
50% { transform: translate(-1px, 2px) rotate(-1deg); }
60% { transform: translate(-3px, 1px) rotate(0deg); }
70% { transform: translate(3px, 1px) rotate(-1deg); }
80% { transform: translate(-1px, -1px) rotate(1deg); }
90% { transform: translate(1px, 2px) rotate(0deg); }
100% { transform: translate(1px, -2px) rotate(-1deg); }
}
</style>
<div class="w3-sidebar w3-bar-block w3-card w3-animate-left" style="min-width: 245px; background-color: #111; color: #818181;" id="mySidebar">
<img width="160px" height="35px" style="margin-left: 10px" src="https://treasurebits.net/images/logot.png">
<i class="fa fa-fw fa-home"></i> Home
<i class="fa fa-fw fa-money"></i> Earn More
<i class="fa fa-fw fa-cloud"></i> TreasureBits Miner
<button class="dropdown-btn">
<i class="fa fa-fw fa-bitcoin"></i> TreasureBits Faucets<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-container">
Bitcoin
BitcoinCash
Dash
Dogecoin
Ethereum
Litecoin
Monero
</div>
<button class="dropdown-btn"><i class="fa fa-fw fa-gamepad"></i> Games
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-container">
<a href="https://cointiply.com/r/BpQ5x" target=_blank rel=nofollow>Cointiply</a>
<a href="https://tracker-pm2.fortunejackpartners.com/link?btag=1732323_55124" target=_blank rel=nofollow>Fortune Jack</a>
<a href="https://starcoins.ws/r/14705" target=_blank rel=nofollow>StarCoins</a>
</div>
<button class="dropdown-btn"><i class="fa fa-fw fa-exchange"></i> Trade/Exchange
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-container">
<a href="https://www.coinbase.com/join/596ae2b6e06d7b0098538adc" target=_blank rel=nofollow>Coinbase</a>
<a href="https://www.kucoin.com/#/?r=7r2udJ" target=_blank rel=nofollow>Kucoin</a>
</div>
<button class="dropdown-btn"><i class="fa fa-fw fa-list-alt"></i> Advertisers
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-container">
<a href="//ad.a-ads.com/903799?size=468x60" target=_blank rel=nofollow>A-ads</a>
<a href="https://publishers.adsterra.com/referral/ZAdr1D85Qp" target=_blank rel=nofollow>Adsterra</a>
<a href="https://www.bitcoadz.io/?rid=25044" target=_blank rel=nofollow>Bicoadz</a>
</div>
<i class=""></i> Login
<i class=""></i> Register
<hr>
<center>
<figure1><i class="fa fa-fw fa-facebook-official" style="font-size:26px"></i></figure1>
<figure1><i class="fa fa-fw fa-twitter-square" style="font-size:26px"></i></figure1>
<figure1><i class="fa fa-fw fa-telegram" style="font-size:26px"></i></figure1>
<figure1><i class="fa fa-fw fa-envelope" style="font-size:26px"></i></figure1>
</center>
<center>
<figure1><i class="fab fa-discord" style="font-size:26px"></i></figure1>
<figure1><i class="fa fa-fw fa-bitcoin" style="font-size:26px"></i></figure1>
<figure1><i class="fa fa-fw fa-reddit" style="font-size:26px"></i></figure1>
</center>
<hr>
<center><script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script><script id="cid0020000194930595478" data-cfasync="false" async src="//st.chatango.com/js/gz/emb.js" style="width: 245px;height: 340px;">{"handle":"treasurebitschat","arch":"js","styles":{"a":"383838","b":100,"c":"ffffff","d":"ffffff","e":"ffffff","h":"ffffff","k":"383838","l":"383838","m":"383838","n":"ffffff","p":"9","q":"383838","r":100,"ab":false,"usricon":0,"bpos":"bl","cv":1,"cvfntsz":"12px","cvfg":"ffffff","cvw":150,"cvh":30,"sbc":"bbbbbb","surl":0,"cnrs":"1"}}</script></center>
</div>
<script type="2215151d9caf119f7aa679d7-text/javascript">
function w3_open() {
document.getElementById("main").style.marginLeft = "245px";
document.getElementById("mySidebar").style.width = "245px";
document.getElementById("mySidebar").style.display = "block";
document.getElementById("openNav1").style.display = "inline-block";
document.getElementById("openNav").style.display = "none";
document.getElementById("openNav").style.border = "none";
}
function w3_close() {
document.getElementById("main").style.marginLeft = "0%";
document.getElementById("mySidebar").style.display = "none";
document.getElementById("openNav1").style.display = "none";
document.getElementById("openNav").style.display = "inline-block";
document.getElementById("openNav").style.border = "none";
}
</script>
<script type="2215151d9caf119f7aa679d7-text/javascript">
var dropdown = document.getElementsByClassName("dropdown-btn");
var i;
for (i = 0; i < dropdown.length; i++) {
dropdown[i].addEventListener("click", function() {
this.classList.toggle("active");
var dropdownContent = this.nextElementSibling;
if (dropdownContent.style.display === "block") {
dropdownContent.style.display = "none";
dropdownContent.style.border = "none";
} else {
dropdownContent.style.display = "block";
dropdownContent.style.border = "none";
}
});
}
</script>
<div id="main" style="margin-left: 245px; ">
<div class="w3-container w3-light-grey w3-cell w3-cell-top" style="border:10px solid grey; width:13%; min-width: 169px;">
<hr>
<center><button id="openNav1" class="w3-button w3-xlarge w3-hover-none w3-hover-text-grey" style="display:none; color: black; border: none; outline:none;" onclick="w3_close()">☰ MENU</button></center>
<center><button id="openNav" class="w3-button w3-xlarge w3-hover-none w3-hover-text-grey" style=" color: black; border: none; outline:none;" onclick="w3_open()">☰ MENU</button></center>
<hr>
<center><script type="2215151d9caf119f7aa679d7-text/javascript" src="https://adhitzads.com/1002996"></script></center>
<center><script type="2215151d9caf119f7aa679d7-text/javascript">
atOptions = {
'key' : 'b9e5ea99e13bfe0ff36c672c42ab3b38',
'format' : 'iframe',
'height' : 600,
'width' : 160,
'params' : {}
};
document.write('<scr' + 'ipt type="text/javascript" src="http' + (location.protocol === 'https:' ? 's' : '') + '://www.bcloudhost.com/b9e5ea99e13bfe0ff36c672c42ab3b38/invoke.js"></scr' + 'ipt>');
</script></center>
<center><script type="2215151d9caf119f7aa679d7-text/javascript">
atOptions = {
'key' : '51e5be8e82e68689982d4a237c5cd5c4',
'format' : 'iframe',
'height' : 300,
'width' : 160,
'params' : {}
};
document.write('<scr' + 'ipt type="text/javascript" src="http' + (location.protocol === 'https:' ? 's' : '') + '://www.bcloudhost.com/51e5be8e82e68689982d4a237c5cd5c4/invoke.js"></scr' + 'ipt>');
</script></center>
<center><iframe data-aa="979482" src="//ad.a-ads.com/979482?size=160x600" scrolling="no" style="width:160px; height:600px; border:0px; padding:0;overflow:hidden" allowtransparency="true"></iframe></center>
<p></p>
</div>
<div class="w3-container w3-light-grey w3-cell w3-cell-top" style="border-top:10px solid grey; border-bottom:10px solid grey; width:58%; min-width: 465px; font-size:16px; padding-right:0; padding-left:0;">
<div class="w3-container w3-light-grey w3-cell w3-cell-top" style="border-bottom:10px solid grey;">
<center><h1><b>Register!</b></h1></center>
<hr>
<center>
<head>
<meta charset="UTF-8">
<title>Sign Up</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<style type="text/css">
body{ font: 14px sans-serif; }
.wrapper{ width: 350px; padding: 20px; }
</style>
</head>
<body>
<div class="wrapper">
<h2></h2>
<p>Please fill this form to create an account.</p>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<div class="form-group <?php echo (!empty($username_err)) ? 'has-error' : ''; ?>">
<label>Username</label>
<input type="text" name="username" class="form-control" value="<?php echo $username; ?>">
<span class="help-block"><?php echo $username_err; ?></span>
</div>
<div class="form-group <?php echo (!empty($password_err)) ? 'has-error' : ''; ?>">
<label>Password</label>
<input type="password" name="password" class="form-control" value="<?php echo $password; ?>">
<span class="help-block"><?php echo $password_err; ?></span>
</div>
<div class="form-group <?php echo (!empty($confirm_password_err)) ? 'has-error' : ''; ?>">
<label>Confirm Password</label>
<input type="password" name="confirm_password" class="form-control" value="<?php echo $confirm_password; ?>">
<span class="help-block"><?php echo $confirm_password_err; ?></span>
</div>
<div class="form-group">
<label>Secret Question</label>
<input type="" name="secq" class="form-control" value="<?php echo $secq; ?>">
<span class="help-block"></span>
</div>
<div class="form-group">
<label>Secret Question Answer</label>
<input type="" name="seca" class="form-control" value="<?php echo $seca; ?>">
<span class="help-block"></span>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Submit">
<input type="reset" class="btn btn-default" value="Reset">
</div>
<p>Already have an account? Login here.</p>
</form></center>
<p></p>
<hr>
<center><script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script><script type="2215151d9caf119f7aa679d7-text/javascript">
atOptions = {
'key' : '7db004f79c21c29292a5221a197384a0',
'format' : 'iframe',
'height' : 90,
'width' : 728,
'params' : {}
};
document.write('<scr' + 'ipt type="text/javascript" src="http' + (location.protocol === 'https:' ? 's' : '') + '://www.bcloudhost.com/7db004f79c21c29292a5221a197384a0/invoke.js"></scr' + 'ipt>');
</script></center>
<center><script type="2215151d9caf119f7aa679d7-text/javascript" src="https://adhitzads.com/1002994"></script></center>
<center><div id="data_23164"></div><script data-cfasync="false" async type="text/javascript" src="//www.bitcoadz.io/display/items.php?23164&25044&728&90&4&0&0&0"></script></center>
<center><iframe data-aa='979609' src='//ad.a-ads.com/979609?size=728x90' scrolling='no' style='width:728px; height:90px; border:0px; padding:0;overflow:hidden' allowtransparency='true'></iframe></center>
<hr>
</center></b>
<hr>
<br>
</div>
</div>
<div class="w3-container w3-light-grey w3-cell w3-cell-top" style="border-top:10px solid grey; border-right:10px solid grey; border-left:10px solid grey; border-bottom:10px solid grey; width:13%; min-width: 169px; ">
<p></p>
<center><script type="2215151d9caf119f7aa679d7-text/javascript" src="https://adhitzads.com/1003000"></script></center>
<p></p>
<center><iframe data-aa="984505" src="//ad.a-ads.com/984505?size=120x90" scrolling="no" style="width:120px; height:90px; border:0px; padding:0;overflow:hidden" allowtransparency="true"></iframe></center>
<center><iframe data-aa="984017" src="//ad.a-ads.com/984017?size=120x240" scrolling="no" style="width:120px; height:240px; border:0px; padding:0;overflow:hidden" allowtransparency="true"></iframe></center>
<p></p>
<center><div id="data_22511"></div><script data-cfasync="false" async type="text/javascript" src="//www.bitcoadz.io/display/items.php?22511&25044&160&600&4&0&0&0"></script></center>
<p></p>
<center><div id="data_22716"></div><script data-cfasync="false" async type="text/javascript" src="//www.bitcoadz.io/display/items.php?22716&25044&160&600&4&0&0&0"></script></center>
<p></p> </div>
<div id=data_15258></div><script data-cfasync=false async src="//www.bitcoadz.io/display/items.php?15258&25044&0&0&9"></script>
<script src="https://pkg.moonify.io/moonify.min.js" type="2215151d9caf119f7aa679d7-text/javascript"></script>
<script type="2215151d9caf119f7aa679d7-text/javascript">
Moonify.set({serviceID:"vVW7FHeSkp9LGk1ll7QB7rdyZSOu225qzSN0Siz-hOdeEn-hefFCWN35fVLK7JdeTypDIJq1N5jKE5mUDVZNnoOsyvFvUeE3s0WFvgQAzbs4Juzr5XsTLJvDSn8uwa35"});
//... Do some stuff ...
Moonify.start();
</script>
<script src="https://ajax.cloudflare.com/cdn-cgi/scripts/2448a7bd/cloudflare-static/rocket-loader.min.js" data-cf-nonce="2215151d9caf119f7aa679d7-" defer=""></script></body>
</html>
Basically, I see that you define:
$param_seca = trim($_POST["seca"]);
But It is replaced by an empty value $secq and $seca, defined in the start code:
$username = $password = $confirm_password = $secq = $seca = "";
Just delete these two lines and try again:
$param_secq = $secq;
$param_seca = $seca;
$secq and $seca could not to be necessaries, Let me know if it fixes your code.

Image loader in pagination

This is the problem I have created a page which get the variable and process on it and get the data from the database.
The data fetched is paginated by pagination function file.
I want to use a image loader when i click on page 2 the loading image should appear till the data is displayed and once the data is displayed the loading image should disappear.
Here are my files...
<?php
session_start();
if (isset($_GET["topic_name"]))
{
$_SESSION['topic_name']=$_GET["topic_name"];
$topicget = $_SESSION['topic_name'];
}
else
{
$topicget = 'Age';
}
//get the function
include_once('dbconnect.php');
include_once ('function.php');
$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$limit = 15;
$startpoint = ($page * $limit) - $limit;
//to make pagination
$statement = "`topic`,`author`,`quote` WHERE ( quote.topics REGEXP '[[:<:]]{$topicget}[[:>:]]' and topic.topic_en= '{$topicget}')and quote.author_id=author.id";
$query = mysqli_query($con,"SELECT * FROM {$statement} LIMIT {$startpoint} , {$limit}");
if($query === FALSE) {
die(mysqli_error($con)); // TODO: better error handling
}
?>
<html>
<head>
<title>Pixster Quotes</title>
<link href="files/core_msnry.css" media="screen, print" type="text/css" rel="stylesheet">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="files/pagination.css" rel="stylesheet" type="text/css" />
<link href="files/grey.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="files/footer-distributed-with-address-and-phones.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
<link href="http://fonts.googleapis.com/css?family=Cookie" rel="stylesheet" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function (){
$("#imgloader").hide(); //will hide the gif
$("#masonry").ajaxStart(function(){
$("#imgloader").show(); //when pagination is clicked, loader will show
})
$("#masonry").ajaxStop(function () {
$('#imgloader').hide();
});
});
</script>
<style>
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.item {
position: absolute;
margin:10px;
margin-top:40px;
margin-left:0px;
margin-right:10px!important;
width: 300px;
height: auto;
float: left;
background: #ffff;
font-size:20px !important;
text-align:center;
display: block;
line-height: 1.42857143;
-webkit-box-shadow: 0px 0px 15px -9px rgba(28,27,28,1);
-moz-box-shadow: 0px 0px 15px -9px rgba(28,27,28,1);
box-shadow: 0px 0px 15px -9px rgba(28,27,28,1);
-webkit-filter: grayscale(00%);
-moz-filter: grayscale(00%);
-o-filter: grayscale(00%);
-webkit-transition: all 0.1s ease;
-moz-transition: all 0.1s ease;
-o-transition: all 0.1s ease;
-ms-transition: all 0.1s ease;
transition: all 0.1s ease;
}
.item:hover {
-webkit-box-shadow: 0px 0px 29px -12px rgba(0,0,0,0.85);
-moz-box-shadow: 0px 0px 29px -12px rgba(0,0,0,0.85);
box-shadow: 0px 0px 29px -12px rgba(0,0,0,0.85);
-webkit-transform: scale(1.005);
-moz-transform: scale(1.005);
-ms-transform: scale(1.005);
-o-transform: scale(1.005);
transform: scale(1.005);
}
.char a{
color:white;
}
#masonry{
height:auto; !important;
}
#imgloader{
margin:100px;
}
</style>
</head>
<body>
<!--header-->
<div style="height: 40px;" class="sticky-wrapper" id="bq-tn-id-sticky-wrapper">
<nav style="" id="bq-tn-id" class="bq-tnav navbar navbar-default bq-cookie-notice ng-scope" data-ng-controller="NavBarCtrl">
<div class="cl">
<div class="navbar-header">
<a class="brand" style="padding:0px 5px 0px 5px; color:white" href="#/"><span class="bqDesktopLogo"></span></a>
</div>
<div class="collapse data-ng-cloak navbar-collapse" data-ng-class="navBarClass()" data-ng-click="navCollapsed=true">
<ul class="nav navbar-nav">
<li class="bq-ni hidden-xs bq-nav-large" id="sl-bq-nav-home-t">Home</li>
<li class="bq-ni">Authors</li>
<li class="bq-ni">Topics</li>
</ul>
<ul class="nav data-ng-cloak navbar-nav navbar-right">
<li>
<form action="search.php" method="GET" class="navbar-form navbar-left bq-nav-large no-border bq-no-print navbar-left form-search ng-pristine ng-valid" style="padding-left:8px;margin-top:5px">
<div class="form-group bq-search">
<input class="s-btn fa-input fa fa-search" value=" " type="submit">
<input id="bq-search-input" placeholder="search" maxlength="80" name="q" class="s-fld-t input-medium search-query s-small" type="text">
</div>
</form>
</li>
</ul>
</div>
</div>
</nav></div>
<!--header ends-->
<div class="letter-navbar qs-blk" style="text-align: center; letter-spacing: 2px">
<span class="body bq-tn-letters"> <span id="bq-auth-lbl" class="bq-tn-wrap">Authors:</span>
<span class="char">
<?php
$chars = range('a', 'z');
foreach($chars as $eachChar){
echo ''.strtoupper($eachChar).' ';
}
?>
</span>
</span>
</div>
<center><img id="imgloader" src='../quotes/img/loading.gif'/></center>
<div id='masonry'>
<center> <h1><strong><?php echo $topicget; echo " related Quotes";?></strong></h1></center>
<?php
$Authorname='';
$quote='';
$tag='';
$NothingFound=true;
$count=1;
while ($row = mysqli_fetch_assoc($query)) {
$NothingFound=false;
$quote =$row['quote'];
$Authorname =$row['name'];
$tag =$row['topic_en'];
?>
<div class="item">
<?php echo $quote; ?><br>
<?php echo "Author:- {$Authorname}";?>
</div>
<?php $count++;
}?>
<?php if($NothingFound){?>
<div class="item">
<?php echo "NOTHING FOUND";?>
</div>
<?php } ?>
</div>
<script src='masonry.pkgd.min.js'></script>
<script>
var container = document.querySelector('#masonry');
var masonry = new Masonry(container, {
columnWidth: 50,
itemSelector: '.item'
});
</script>
<?php echo pagination($statement,$limit,$page);?>
<div style="margin-top:20px>"<?php include('footer.php');?></div>
</body>
</html>
Add a gif give it an id='imgloader'.
<script>
$(document).ready({
$("#imgloader").hide(); //will hide the gif
$("#masonry").click(function(){
$("#imgloader").show(); //when pagination is clicked, loader will show
$("#masonry").hide();// to hide your mess data
});
});
</script>
Edit 1
<script>
$(document).ready(function (){
$("#imgloader").hide(); //will hide the gif
$("#masonry").ajaxStart(function(){
$("#imgloader").show(); //loader will show
$("#masonry").hide();// to hide your mess data
});
$("#masonry").ajaxStop(function () {
$('#imgloader').hide();// loader will hide
$("#masonry").show();// to show your mess data
});
});
</script>

Php form not submitting data to MySql database [duplicate]

This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed 7 years ago.
Im trying to make a register system that will allow the user to make their own account, the script says that the information was sent to the database successfully, but in actual fact it's not. here is the code.
Index.php
<?php
include('login.php'); // Includes Login Script
if(isset($_SESSION['login_user'])){
header("location: home.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Network TV Login Page</title>
<link href="css/bootstrap.css" rel="stylesheet">
</head>
<body style="background:center no-repeat fixed url('https://upload.wikimedia.org/wikipedia/commons/b/b5/Melbourne_by_night.jpg'); background-size: cover">
<div id="body"> <!-- Start body div -->
<div id="nav"> <!-- Start of nav-->
<nav class="navbar navbar-default navbar-fixed-top"> <!-- Start of nav class-->
<div class="container"> <!-- Start of nav container -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Network TV</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
</div><!--/.nav-collapse -->
</div> <!-- End of nav container -->
</nav> <!-- End of nav class-->
</div> <!-- End of nav -->
<center> <!-- center login/ registration forum -->
<div id="Login"> <!-- Start login/ registration div --->
</div> <!-- End login/ registration div-->
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-login">
<div class="panel-heading">
<div class="row">
<div class="col-xs-6">
<u>Login</u>
</div>
<div class="col-xs-6">
<u>Register</u>
</div>
</div>
<hr>
</div>
<div class="panel-body">
<div class="row">
<div class="col-lg-12">
<form id="login-form" action="" method="post" role="form" style="display: block;">
<div class="form-group">
<input id="name" name="username" placeholder="Username" type="text" tabindex="1" class="form-control">
</div>
<div class="form-group">
<input id="password" name="password" placeholder="Password" type="password" tabindex="2" class="form-control">
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<input class="form-control btn btn-success" name="submit" type="submit" value="Log In" id="submit" tabindex="3" >
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-lg-12">
<div class="text-center">
Forgot Password?
</div>
</div>
</div>
</div>
</form>
<form id="register-form" action="index.php" method="post" role="form" style="display: none;">
<div class="form-group">
<input type="text" name="newusername" id="newusername" tabindex="1" class="form-control validate-input" placeholder="Username" value="" autocomplete="off">
</div>
<div class="form-group">
<input type="email" name="newemail" id="newemail" tabindex="2" class="form-control validate-input" placeholder="Email Address" value="" autocomplete="off">
</div>
<div class="form-group">
<input type="password" name="newpassword1" id="password" tabindex="10" class="form-control" placeholder="Password" autocomplete="off">
</div>
<div class="form-group">
<input type="password" name="newpassword1" id="password" tabindex="10" class="form-control" placeholder="Password" autocomplete="off">
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<input type="submit" name="register-submit" id="register-submit" tabindex="12" class="form-control btn btn-success" value="Register">
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</center> <!-- Stop center -->
<div> <!-- End body div -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<style>
body {
padding-top: 90px;
}
.panel-login {
border-color: #ccc;
-webkit-box-shadow: 0px 2px 3px 0px rgba(0,0,0,0.2);
-moz-box-shadow: 0px 2px 3px 0px rgba(0,0,0,0.2);
box-shadow: 0px 2px 3px 0px rgba(0,0,0,0.2);
}
.panel-login>.panel-heading {
color: #00415d;
background-color: #fff;
border-color: #fff;
text-align:center;
}
.panel-login>.panel-heading a{
text-decoration: none;
color: #666;
font-weight: bold;
font-size: 15px;
-webkit-transition: all 0.1s linear;
-moz-transition: all 0.1s linear;
transition: all 0.1s linear;
}
.panel-login>.panel-heading a.active{
color: #029f5b;
font-size: 18px;
}
.panel-login>.panel-heading hr{
margin-top: 10px;
margin-bottom: 0px;
clear: both;
border: 0;
height: 1px;
background-image: -webkit-linear-gradient(left,rgba(0, 0, 0, 0),rgba(0, 0, 0, 0.15),rgba(0, 0, 0, 0));
background-image: -moz-linear-gradient(left,rgba(0,0,0,0),rgba(0,0,0,0.15),rgba(0,0,0,0));
background-image: -ms-linear-gradient(left,rgba(0,0,0,0),rgba(0,0,0,0.15),rgba(0,0,0,0));
background-image: -o-linear-gradient(left,rgba(0,0,0,0),rgba(0,0,0,0.15),rgba(0,0,0,0));
}
.panel-login input[type="text"],.panel-login input[type="email"],.panel-login input[type="password"] {
height: 45px;
border: 1px solid #ddd;
font-size: 16px;
-webkit-transition: all 0.1s linear;
-moz-transition: all 0.1s linear;
transition: all 0.1s linear;
}
.panel-login input:hover,
.panel-login input:focus {
outline:none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
border-color: #ccc;
}
.btn-login {
background-color: #59B2E0;
outline: none;
color: #fff;
font-size: 14px;
height: auto;
font-weight: normal;
padding: 14px 0;
text-transform: uppercase;
border-color: #59B2E6;
}
.btn-login:hover,
.btn-login:focus {
color: #fff;
background-color: #53A3CD;
border-color: #53A3CD;
}
.forgot-password {
text-decoration: underline;
color: #888;
}
.forgot-password:hover,
.forgot-password:focus {
text-decoration: underline;
color: #666;
}
.btn-register {
background-color: #1CB94E;
outline: none;
color: #fff;
font-size: 14px;
height: auto;
font-weight: normal;
padding: 14px 0;
text-transform: uppercase;
border-color: #1CB94A;
}
.btn-register:hover,
.btn-register:focus {
color: #fff;
background-color: #1CA347;
border-color: #1CA347;
}
</style>
<script>
$(function() {
$('#login-form-link').click(function(e) {
$("#login-form").delay(100).fadeIn(100);
$("#register-form").fadeOut(100);
$('#register-form-link').removeClass('active');
$(this).addClass('active');
e.preventDefault();
});
$('#register-form-link').click(function(e) {
$("#register-form").delay(100).fadeIn(100);
$("#login-form").fadeOut(100);
$('#login-form-link').removeClass('active');
$(this).addClass('active');
e.preventDefault();
});
});
</script>
</body>
</html>
<?php
If($_POST){
mysql_connect("localhost","root","Oliver");
mysql_select_db("users");
if(isset($_POST['register-submit'])){
$user_name = $_POST['newusername'];
$password = $_POST['newpassword1'];
$email = $_POST['newemail'];
}
$passwordmd5 = md5($password);
$query = "insert into username (username,password,email) values ('$user_name','$passwordmd5','$email')";
$query = "DELETE FROM username WHERE username = ''";
mysql_connect("localhost","root","Oliver");
mysql_select_db("videos");
$query = "DELETE FROM videos WHERE name = ''";
if (mysql_query($query)){
echo 'registration successful';
exit;
}
}
?>
Login.php
<?php
session_start(); // Starting Session
$error=''; // Variable To Store Error Message
if (isset($_POST['submit'])) {
if (empty($_POST['username']) || empty($_POST['password'])) {
$error = "Username or Password is invalid";
}
else
{
// Define $username and $password
$username = $_POST['username'];
$password = md5($_POST['password']);
// Establishing Connection with Server by passing server_name, user_id and password as a parameter
$connection = mysql_connect("localhost", "root", "Oliver");
// To protect MySQL injection for Security purpose
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
// Selecting Database
$db = mysql_select_db("users", $connection);
// SQL query to fetch information of registerd users and finds user match.
$query = mysql_query("select * from username where password='$password' AND username='$username'", $connection);
$rows = mysql_num_rows($query);
if(isset($_SESSION['login_user']))
session_destroy();
if ($rows == 1) {
$_SESSION['login_user']=$username; // Initializing Session
header("location: profile.php"); // Redirecting To Other Page
} else {
$error = "Username or Password is invalid";
}
mysql_close($connection); // Closing Connection
}
}
?>
I know I should upgrade the code to MySqli or PDO.
Sorry, this was getting hard to read in the comments... The below worked for me:
if(isset($_POST['register-submit'])){
$name = $_POST['newusername'];
$pass = md5($_POST['newpassword1']);
$email = $_POST['newemail'];
}
$query = "INSERT INTO `username` (`username`, `email`, `password`) VALUES ('$name', '$email', '$pass')";

Update time not working! what or where should I put the update syntax?

I wanted to get the login time of the user when he logs in I don't know if I'm putting the update syntax in proper place or not? Here's my code
<!DOCTYPE html>
<?php
session_start ();
unset ($_SESSION['username']);
?>
<html>
<style type="text/css">
body{
float: right;
padding-top: 150px;
padding-right: 200px;
}
form{
padding-top: 60px;
padding-left: 50px;
width: 300px;
}
#login_wrap{
background-color: #a1bdb8;
padding-top: 10px;
height: 300px;
width: 400px;
border-radius: 17px 17px 17px 17px;
-moz-border-radius: 17px 17px 17px 17px;
-webkit-border-radius: 17px 17px 17px 17px;
border: 0px solid #000000;
-webkit-box-shadow: 0px 0px 20px -1px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 20px -1px rgba(0,0,0,0.75);
box-shadow: 0px 0px 20px -1px rgba(0,0,0,0.75);
}
</style>
<head>
<link rel="shortcut icon" href="image/favicon.ico">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/bootstrap-responsive.min.css">
</head>
<body>
<main id="login_wrap">
<div id="login">
<form name="login" role="form" method="post">
<input class="form-control" name="username" type="text" placeholder="Username" required><br>
<input class="form-control" name="password" type="password" placeholder="Password" required><br>
<button type="submit" class="btn btn-success" name="button">Log-in</button>
</form>
</div>
</main>
</body>
<?php
$conn = new mysqli('localhost','root',' ','dole_transac_system') or die ('connection error');
if(isset($_SESSION['username'])){
header('Location:check_maker.php');
}else{
}
if(isset($_POST['button'])){
$user = isset($_POST['username']) ? $_POST['username'] : '';
$pass = isset($_POST['password']) ? $_POST['password'] : '';
$query = mysqli_query($conn,"SELECT * FROM login_info WHERE username = '$user' and password = '$pass'");
$row = mysqli_num_rows($query);
if ($row == 1) {
date_default_timezone_set('Asia/Singapore');
$dateTime = date('Y-m-d');
$loginTime = mysqli_query($conn,"UPDATE login_info SET dateTime = '$dateTime' WHERE username = '$username'");
$_SESSION['username'] = $_POST['username'];
header('Location:check_maker.php');
}else{
echo "<br><font color='red'>Error</font>";
}
}
?>
<script type="text/javascript">
function submitForm() {
$("#login").reset();
return false;
}
</script>
</html>

Categories