PHP Gives no error and does not fill items into database - php

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.

Related

How do I define 'id'

Before anyone judges my coding, just know that I'm still learning the basics.
I'm facing an issue within my page which states as such:
Warning: Undefined array key "id" in C:\xampp\htdocs\Project\POLIMAS
Treatment Center\POLIMAS Treatment Center\ma\write-report.php on line
11
a screenshot of the error
I want to know how to solve this issue, now to make my question more understandable I will include the coding, I know it's most likely not secure, I need to finish my project by tomorrow, so I just want to solve this issue.
I have two pages, one which will direct towards this form, and another, that displays this form.
For the page that will direct the users towards the form, the coding is as follows:
<?php
require('database.php');
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Appointments</title>
<link rel="stylesheet" href="../css/dashboard.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<style>
<!--.btn{
background-color: red;
border: none;
color: white;
padding: 2px 2px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 40px;
margin: 4px 2px;
cursor: pointer;
border-radius: 20px;
}-->
#appointment {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#appointment td, #appointment th {
border: 1px solid #7e7f81;
padding: 8px;
}
#appointment tr:nth-child(even){background-color: #8399bb;}
#appointment tr:hover {background-color: #7e7f81;}
#appointment th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #69649b;
color: white;
}
</style>
<body>
<div class="wrapper">
<div class="header">
<img src="../images/POLIMAS Treatment Center.png" width="50%" height="100%" alt=""/></div>
<div class="sidebar">
<nav>
<ul>
<?php
$count=1;
$sel_query="Select * from ma";
$naem = mysqli_query($link,$sel_query);
while($row = mysqli_fetch_assoc($naem)){
?>
<li><a href="home-ma.php" class="logo">
<img src="../images/grid-img6.png" alt="logo">
<span class="nav-item"><?php echo $row["maName"]; ?></span>
</a></li>
<?php }?>
<li><a href="ma-appoiment.php">
<i class="fa fa-history"></i>
<span class="nav-iteam">View Appoiment</span>
</a></li>
<li><a href="ma-report.php">
<i class="fa fa-edit"></i>
<span class="nav-iteam">Report</span>
</a></li>
<li><a href="../index.html" class="logout">
<i class="fa fa-sign-out"></i>
<span class="nav-iteam">Logout</span>
</a></li>
</ul>
</nav>
</div>
<div class="content">
<center>
<!-- TABLE TOP ROW HEADINGS-->
<h1>Student Appointment</h1>
<table id="appointment" style="width:100%">
<tr>
<th>Appointment ID</th>
<th>Matrics Number</th>
<th>Appointment Status</th>
<th>Report</th>
<th>Delete</th>
</tr>
<?php
$count=1;
$sel_query="Select * from appointment";
$result = mysqli_query($link,$sel_query);
while($row = mysqli_fetch_assoc($result)){
?>
<tr>
<td align="center">
<?php echo $row["appID"]; ?></td>
<td align="center">
<?php echo $row["matricsNo"]; ?></td>
<td align="center"><?php if($row['appDecline']=="1")
echo "Approved";
else if($row['appDecline']=="2")
echo "Dissaproved";
else
echo "Pending"
?>
</td>
<td align="center"><i class="fa fa-book"></i>Write Report</td>
<td align="center"><a href="delete.php?id=<?php echo $row['appID']?>"
onclick="return confirm('Are you sure to delete this record?')"><i class="fa fa-trash"></i> Remove</a></td>
</tr><?php } ?>
</table>
</center>
</div>
<div class="footer">Content for class "footer" Goes Here</div>
</div>
</body>
</html>
The error states that my 'id' was not defined, however in line 130, I am pretty sure I already stated it </td>
For the page which display the form, the coding is as follows:
<?php
ini_set('display_errors', 1);
ini_set('log_errors',1);
error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
require ('../database.php');
if($link){
$sql = mysqli_query($link, "SELECT *
FROM appointment
WHERE appID = '" . $_REQUEST['id'] . "'");
$row = mysqli_fetch_array($sql);
}
else{
die("Error: Could not CONNECT." . mysqli_error($link));
}
if(isset($_POST['update'])){
$update = mysqli_query($link, "UPDATE appointment
SET studMeds = '" . $_REQUEST['studMeds'] ."',
maNotes = '" . $_REQUEST['maNotes'] . "'
WHERE appID = '" . $_REQUEST['id'] . "'");
header("Location: write-report.php");
}
mysqli_close($link);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Report</title>
<link rel="stylesheet" href="../css/dashboard.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<style type="text/css">
.form-style-5{
max-width: 500px;
padding: 10px 20px;
background: #f4f7f8;
margin: 10px auto;
padding: 20px;
background: #f4f7f8;
border-radius: 8px;
font-family: Georgia, "Times New Roman", Times, serif;
}
.form-style-5 fieldset{
border: none;
}
.form-style-5 legend {
font-size: 1.4em;
margin-bottom: 10px;
}
.form-style-5 label {
display: block;
margin-bottom: 8px;
}
.form-style-5 input[type="text"],
.form-style-5 input[type="date"],
.form-style-5 input[type="datetime"],
.form-style-5 input[type="email"],
.form-style-5 input[type="number"],
.form-style-5 input[type="search"],
.form-style-5 input[type="time"],
.form-style-5 input[type="url"],
.form-style-5 textarea,
.form-style-5 select {
font-family: Georgia, "Times New Roman", Times, serif;
background: rgba(255,255,255,.1);
border: none;
border-radius: 4px;
font-size: 15px;
margin: 0;
outline: 0;
padding: 10px;
width: 100%;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
background-color: #e8eeef;
color:#8a97a0;
-webkit-box-shadow: 0 1px 0 rgba(0,0,0,0.03) inset;
box-shadow: 0 1px 0 rgba(0,0,0,0.03) inset;
margin-bottom: 30px;
}
.form-style-5 input[type="text"]:focus,
.form-style-5 input[type="date"]:focus,
.form-style-5 input[type="datetime"]:focus,
.form-style-5 input[type="email"]:focus,
.form-style-5 input[type="number"]:focus,
.form-style-5 input[type="search"]:focus,
.form-style-5 input[type="time"]:focus,
.form-style-5 input[type="url"]:focus,
.form-style-5 textarea:focus,
.form-style-5 select:focus{
background: #d2d9dd;
}
.form-style-5 select{
-webkit-appearance: menulist-button;
height:35px;
}
.form-style-5 .number {
background: #353185;
color: #fff;
height: 30px;
width: 30px;
display: inline-block;
font-size: 0.8em;
margin-right: 4px;
line-height: 30px;
text-align: center;
text-shadow: 0 1px 0 rgba(255,255,255,0.2);
border-radius: 15px 15px 15px 0px;
}
.form-style-5 input[type="submit"],
.form-style-5 input[type="button"]
{
position: relative;
display: block;
padding: 19px 39px 18px 39px;
color: #FFF;
margin: 0 auto;
background: #353185;
font-size: 18px;
text-align: center;
font-style: normal;
width: 100%;
border: 1px solid #16a085;
border-width: 1px 1px 3px;
margin-bottom: 10px;
}
.form-style-5 input[type="submit"]:hover,
.form-style-5 input[type="button"]:hover
{
background: #2a2769;
}
</style>
<div class="wrapper">
<div class="header">
<img src="../images/POLIMAS Treatment Center.png" width="50%" height="100%" alt=""/></div>
<div class="sidebar">
<nav>
<ul>
<li><a href="home-ma.php" class="logo">
<img src="../images/grid-img6.png" alt="logo">
<span class="nav-item">Medical Assistant</span>
</a></li>
<li><a href="ma-appoiment.php">
<i class="fa fa-history"></i>
<span class="nav-iteam">View Appoiment</span>
</a></li>
<li><a href="ma-report.php">
<i class="fa fa-edit"></i>
<span class="nav-iteam">Report</span>
</a></li>
<li><a href="../index.html" class="logout">
<i class="fa fa-sign-out"></i>
<span class="nav-iteam">Logout</span>
</a></li>
</ul>
</nav>
</div>
<div class="form-style-5">
<form action="" method="POST">
<fieldset>
<legend>Student Appointment Report</legend>
<input type="hidden" name="new" value="1" />
<input type="text" name="appID" size="6" value="<?php echo $row['appID'];?>" disabled>
<input type="text" name="matricsNo" size="6" value="<?php echo $row['matricsNo'];?>" disabled>
<input type="text" name="appTime" size="6" value="<?php echo $row['appTime'];?>" disabled>
<input type="text" name="appStatus" size="6" value="<?php echo $row['appStatus'];?>" disabled>
<input type="text" name="studMeds" size="6" placeholder="Medication Used">
</fieldset>
<input type="submit" name="update" value="Complete Report" />
</form>
</div>
<div class="footer">Content for class "footer" Goes Here</div>
</div>
</body>
</html>
The error which lies on the 11th line is this:
$sql = mysqli_query($link, "SELECT *
FROM appointment
WHERE appID = '" . $_REQUEST['id'] . "'");
Why is my 'id' key undefined? I thought that I declared it on the previous page with </td>. My other pages face no error such as this one, and they're identical as well. Please, help me solve this issue, I'm pretty sure I made the question very clear.

How do I get rid of this extra section below the footer - Bootstrap

Underneath my footer on the webpage I'm working on, there seems to be an extra section (almost another div which is the blue area) which appears beneath it. Any guidance on how to get rid of it and which code even included it?
1st Section of code is from the signup.php page:
<body>
<main>
<div class="wrapper-main">
<section class="section-default">
<h1 class="h1-signup-title">Signup</h1>
<?php
// Here we create an error message if the user made an error trying to sign up.
if (isset($_GET["error"])) {
if ($_GET["error"] == "emptyfields") {
echo '<p class="signuperror">Fill in all fields!</p>';
}
else if ($_GET["error"] == "invaliduidmail") {
echo '<p class="signuperror">Invalid username and email!</p>';
}
else if ($_GET["error"] == "invaliduid") {
echo '<p class="signuperror">Invalid username!</p>';
}
else if ($_GET["error"] == "invalidmail") {
echo '<p class="signuperror">Invalid email!</p>';
}
else if ($_GET["error"] == "passwordcheck") {
echo '<p class="signuperror">Your passwords do not match!</p>';
}
else if ($_GET["error"] == "usertaken") {
echo '<p class="signuperror">Username is already taken!</p>';
}
}
// Here we create a success message if the new user was created.
else if (isset($_GET["signup"])) {
if ($_GET["signup"] == "success") {
echo '<p class="signupsuccess">Signup successful!</p>';
}
}
?>
<form class="form-signup" action="includes/signup.inc.php" method="post">
<?php
// Here we check if the user already tried submitting data.
// We check username.
if (!empty($_GET["uid"])) {
echo '<input type="text" name="uid" placeholder="Username" value="'.$_GET["uid"].'">';
}
else {
echo '<input type="text" name="uid" placeholder="Username">';
}
// We check e-mail.
if (!empty($_GET["mail"])) {
echo '<input type="text" name="mail" placeholder="Email" value="'.$_GET["mail"].'">';
}
else {
echo '<input type="text" name="mail" placeholder="Email">';
}
?>
<input type="password" name="pwd" placeholder="Password">
<input type="password" name="pwd-repeat" placeholder="Repeat password">
<button type="submit" name="signup-submit">Signup</button>
</form>
<!--Here we create the form which starts the password recovery process!-->
<?php
if (isset($_GET["newpwd"])) {
if ($_GET["newpwd"] == "passwordupdated") {
echo '<p class="signupsuccess">Your password has been reset!</p>';
}
}
?>
<a class="p-forgetpwd" href="reset-password.php">Forgot your password?</a>
</section>
</div>
</main>
</body>
</html>
<?php
require "footer.php";
?>
The 2nd section of code is from the footer.php code:
<hr class="my-0 border-white">
<footer class="site-footer d-flex justify-content-center">
<section class="social-links py-3 text-center">
<ul class="list-inline">
<li class="list-inline-item"></li>
<li class="list-inline-item"></li>
<li class="list-inline-item"></li>
<li class="list-inline-item"></li>
</ul>
<span> © iStudy 2018</span>
</section>
</footer>
UPDATE: The CSS that links with the signup.php page code:
.wrapper-main {
width: 900px;
margin: 0 auto;
}
.section-default {
width: 100%;
padding: 20px;
border-radius: 6px;
background-color: #FFF;
}
.h1-signup-title { /* For the signup form page */
text-align: center;
font-size: 26px;
font-family: arial;
color: black;
}
.form-signup {
margin: 0 auto;
padding-top: 20px;
width: 200px;
}
.form-signup input {
width: calc(100% - 30px);
height: 30px;
padding: 0 15px;
margin-bottom: 6px;
border: 1px solid #CCC;
border-radius: 4px;
background-color: #F6F6F6;
float: left;
font-family: arial;
}
.form-signup button {
display: block;
height: 40px;
padding: 0 10px;
margin: 0 auto;
border: none;
border-radius: 4px;
background-color: #333;
font-family: arial;
font-size: 13px;
color: #FFF;
text-transform: uppercase;
text-align: center;
}
main {
padding-top: 20px;
}
.wrapper-main {
width: 900px;
margin: 0 auto;
}
To solve your problem, you will want to force your footer to the bottom. This will always keep your footer at the bottom your website no matter how much content you have on the page. Please note you will need to figure out and type in how tall your footer is.
html {
position: relative;
min-height: 100%;
}
body {
/* Margin bottom by footer height */
margin-bottom: 60px;
}
footer {
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 60px;
}

Table for specific user

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.

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

Categories