I am currently working on a profile page for my website. It is all going along pretty well so far, except on the edit profile page. The database does not seem to be updating the variables like it should be, and I have no clue why. There are 3 main blocks of code, and the actual input part is the issue I think.
Before that the variables are not updated, but after that block of code the variables are update (it is a form). By the way, if you want to know what the issue is, here it is. If a user inputs something, but then deletes it, it re-inputs the data on the form submit. Now, here are the 3 main blocks of code (in order):
Startup
function utf8_encode_string($value) {
if (empty($_POST[$value])) {
$str = "";
return $str;
}
else {
$str = utf8_encode(htmlspecialchars(trim($_POST[$value]), ENT_QUOTES));
return $str;
}
}
//Grabs all of the profile information
$accountinfoquery = "SELECT * FROM users WHERE username = :username";
$accountinfoparams = array(':username' => $accounturl);
try{
$accountinfostmt = $connection->prepare($accountinfoquery);
$accountinforesult = $accountinfostmt->execute($accountinfoparams);
}
catch(PDOException $ex){
echo ("Failed to run query: " . $ex->getMessage());
}
$accountinfocolumns = $accountinfostmt->fetch();
$firstnameinput = utf8_encode_string("firstname");
$lastnameinput = utf8_encode_string("lastname");
$ageinput = utf8_encode_string("age");
$locationinput = utf8_encode_string("location");
$quoteinput = utf8_encode_string("quote");
$genderinput = utf8_encode_string("gender");
$aboutinput = utf8_encode_string("about");
if (!$firstnameinput) {
$firstnameinput = utf8_encode(htmlspecialchars(trim($accountinfocolumns["firstname"]), ENT_QUOTES));
}
if (!$lastnameinput) {
$lastnameinput = utf8_encode(htmlspecialchars(trim($accountinfocolumns["lastname"]), ENT_QUOTES));
}
if (!$ageinput) {
if ($accountinfocolumns["age"] == "0") {
$ageinput = "";
}
else {
$ageinput = utf8_encode(htmlspecialchars(trim($accountinfocolumns["age"]), ENT_QUOTES));
}
}
if (!$locationinput) {
$locationinput = utf8_encode(htmlspecialchars(trim($accountinfocolumns["location"]), ENT_QUOTES));
}
if (!$quoteinput) {
$quoteinput = utf8_encode(htmlspecialchars(trim($accountinfocolumns["quote"]), ENT_QUOTES));
}
if (!$genderinput) {
$genderinput = utf8_encode(htmlspecialchars(trim($accountinfocolumns["gender"]), ENT_QUOTES));
}
if (!$aboutinput) {
$aboutinput = utf8_encode(htmlspecialchars(trim($accountinfocolumns["about"]), ENT_QUOTES));
}
//Final Check
$firstnamefinalcheck = False;
$lastnamefinalcheck = False;
$agefinalcheck = False;
$locationfinalcheck = False;
$quotefinalcheck = False;
$aboutfinalcheck = False;
Inputs
(IMPORTANT: I think the issue is near the button).
<form action="http://localhost/postin'/profiles/edit/<?php print utf8_decode($loggedin_session_permalink); ?>" method="post">
<div class="row" id="informationquoteholder">
<div id="informationtitlesmall" class="col-xs-12 col-sm-3">
Quote
</div>
<div id="quoteinputwidth" class="col-xs-12 col-sm-5 col-md-8">
<input type="text" name="quote" id="quoteinput" value="<?php print utf8_decode($quoteinput); ?>" />
</div>
<?php
if ($_POST) {
$quotetest1 = False;
$quotetest2 = False;
if (utf8_decode(trim($_POST["quote"])) == "") {
$quotefinalcheck = True;
$quoteinput = "";
}
else {
// Test #1 - Makes sure it fits the length requirements
if(mb_strlen(utf8_decode($quoteinput), "UTF-8") < 3 ) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Quote is too short. </div>
<?php
}
elseif(mb_strlen(utf8_decode($quoteinput), "UTF-8") > 100 ) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Quote is too long, maxium 100 characters.</div>
<?php
}
else {
$quotetest1 = True;
// Test #2 - Makes sure it does not have any restricted characters
if(!preg_match("~^[\p{L}\p{N},() _@.?!:;-]+$~u", utf8_decode($quoteinput))) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Quote contains restricted characters. </div>
<?php
}
elseif(preg_match('~(\S)(?:\1){10,}~mui', utf8_decode($quoteinput))) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Quote is not valid. </div>
<?php
}
else {
$quotetest2 = True;
// Final Check
if (($quotetest1) and ($quotetest2)) {
$quotefinalcheck = True;
$quoteinput = utf8_encode(htmlspecialchars(trim($_POST["quote"]), ENT_QUOTES));
}
else {
$quotefinalcheck = False;
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> There is a error. </div>
<?php
}
}
}
}
}
?>
</div>
</div>
</div>
<div class="col-xs-12">
<button id="profileinformationbutton" input type="submit" value="Login"> Update Profile </button>
</div>
<div class="col-xs-12">
<a href="http://localhost/postin'/profiles/<?php print utf8_decode($loggedin_session_permalink); ?>">
<div id="informationcancelbutton" input type="submit" value="Cancel"> Cancel </div>
</a>
</div>
</form>
Database update
<?php
if ($quotefinalcheck) {
$quote_for_database = "";
if (isset($quoteinput)) {
$quote_for_database = $quoteinput;
}
else {
$quote_for_database = "";
}
$inputquery = "UPDATE users SET quote = :quote, WHERE id = :id";
$datasend = $connection->prepare($inputquery);
$datasend->execute(array(':quote'=>utf8_decode($quote_for_database),
':id'=>$_SESSION["logged_in"]));
}
?>
I think the main issue is just the order of the way I am doing this. If you want the full code here it is (Please note, some parts are for different things):
<?php
require("C:\wamp\www\postin'\db_connection.php");
//Grabs the URL
$urlname = explode("/",$_SERVER['REQUEST_URI']);
$urlquery = "SELECT username FROM users WHERE permalink = :permalink";
$urlparams = array(':permalink' => $urlname[4]);
try{
$urlstmt = $connection->prepare($urlquery);
$urlresult = $urlstmt->execute($urlparams);
}
catch(PDOException $ex){
echo ("Failed to run query: " . $ex->getMessage());
}
$urlcolumns = $urlstmt->fetch();
$accounturl = $urlcolumns["username"];
if(!$urlcolumns){
header("Location: http://localhost/postin'/home.php");
exit();
}
else {
?>
<!DOCTYPE html>
<html>
<head>
<?php include("C:\wamp\www\postin'\includes\head.php");?>
<title> POSTIN' Profile <?php echo $accounturl; ?> </title>
<link type="text/css" rel="stylesheet" href="http://localhost/postin'/css/style.profile.php.css"/>
<link type="text/css" rel="stylesheet" href="http://localhost/postin'/css/style.editprofile.php.css"/>
</head>
<body>
<div id="wrapper" class="container">
<?php
//Stars the sessions
session_start();
//Makes sure the user is trying to edit there profile
if (!isset($_SESSION["logged_in"])) {
header("Location: http://localhost/postin'/home.php");
exit();
}
$sessionquery = "SELECT username FROM users WHERE id = :id";
$sessionparams = array(':id' => $_SESSION["logged_in"]);
try{
$sessionstmt = $connection->prepare($sessionquery);
$sessionresult = $sessionstmt->execute($sessionparams);
}
catch(PDOException $ex){
echo ("Failed to run query: " . $ex->getMessage());
}
$sessionfetch = $sessionstmt->fetch();
$loggedin_session_username = $sessionfetch["username"];
if($accounturl != $loggedin_session_username){
header("Location: http://localhost/postin'/home.php");
exit();
}
else {
//Adds the header and sidebar
include("C:\wamp\www\postin'\includes\header.php");
include("C:\wamp\www\postin'\includes\sidebar.php");
//Sets the "last_url" to this page
if (!isset($_SESSION["last_url"])) {
$_SESSION["last_url"] = "http://localhost/postin'/home.php";
}
$last_url = $_SESSION["last_url"];
//Grabs all of the profile information
$accountinfoquery = "SELECT * FROM users WHERE username = :username";
$accountinfoparams = array(':username' => $accounturl);
try{
$accountinfostmt = $connection->prepare($accountinfoquery);
$accountinforesult = $accountinfostmt->execute($accountinfoparams);
}
catch(PDOException $ex){
echo ("Failed to run query: " . $ex->getMessage());
}
$accountinfocolumns = $accountinfostmt->fetch();
$firstnameinput = utf8_encode_string("firstname");
$lastnameinput = utf8_encode_string("lastname");
$ageinput = utf8_encode_string("age");
$locationinput = utf8_encode_string("location");
$quoteinput = utf8_encode_string("quote");
$genderinput = utf8_encode_string("gender");
$aboutinput = utf8_encode_string("about");
if (!$firstnameinput) {
$firstnameinput = utf8_encode(htmlspecialchars(trim($accountinfocolumns["firstname"]), ENT_QUOTES));
}
if (!$lastnameinput) {
$lastnameinput = utf8_encode(htmlspecialchars(trim($accountinfocolumns["lastname"]), ENT_QUOTES));
}
if (!$ageinput) {
if ($accountinfocolumns["age"] == "0") {
$ageinput = "";
}
else {
$ageinput = utf8_encode(htmlspecialchars(trim($accountinfocolumns["age"]), ENT_QUOTES));
}
}
if (!$locationinput) {
$locationinput = utf8_encode(htmlspecialchars(trim($accountinfocolumns["location"]), ENT_QUOTES));
}
if (!$quoteinput) {
$quoteinput = utf8_encode(htmlspecialchars(trim($accountinfocolumns["quote"]), ENT_QUOTES));
}
if (!$genderinput) {
$genderinput = utf8_encode(htmlspecialchars(trim($accountinfocolumns["gender"]), ENT_QUOTES));
}
if (!$aboutinput) {
$aboutinput = utf8_encode(htmlspecialchars(trim($accountinfocolumns["about"]), ENT_QUOTES));
}
//Final Check
$firstnamefinalcheck = False;
$lastnamefinalcheck = False;
$agefinalcheck = False;
$locationfinalcheck = False;
$quotefinalcheck = False;
$aboutfinalcheck = False;
?>
<div id="mobilephonescrollplace">
Hold Here To Slide Screen
</div>
<div class="maincontentssection">
<!-- ========================================================================================================================== -->
<!-- WHERE THE USER CHANGES HIS PROFILE INFORMATION -->
<!-- ========================================================================================================================== -->
<div id="accountinformationholder" class="row">
<div id="picturequoteholder" class="col-xs-12 col-sm-12 col-md-12 col-lg-3">
<div class="row">
<div id="accountpictureholder" class="col-xs-12 col-sm-6 col-md-6 col-lg-12 margintopimageeditpage">
<div id="accountpictureview">
<img src="http://localhost/postin'/images/logo.png" id="accountpictureholderspecs">
</div>
</div>
<div id="changepictureholder" class="col-xs-12 col-sm-6 col-md-6 col-lg-12">
<div id="changepicture">
Change Picture
</div>
</div>
</div>
</div>
<div id="editinformationholder" class="col-xs-12 col-sm-12 col-md-12 col-lg-8">
<form action="http://localhost/postin'/profiles/edit/<?php print utf8_decode($loggedin_session_permalink); ?>" method="post">
<div class="row">
<div class="row">
<div id="importantinformation" class="col-xs-12">
(*) means field is required.
</div>
</div>
<div class="col-xs-12 col-sm-8">
<div class="row">
<div id="informationtitlesmall" class="col-xs-12 col-sm-5">
* First Name
</div>
<div id="informationfirstname" class="col-xs-12 col-sm-7">
<input type="text" name="firstname" id="firstnameinput" value="<?php print mb_ucfirst($firstnameinput); ?>" />
</div>
<?php
if ($_POST) {
$firstnametest1 = False;
$firstnametest2 = False;
// Test #1 - Makes sure it fits the length requirements
if(mb_strlen(utf8_decode($firstnameinput), "UTF-8") < 3 ) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> First name is not valid. </div>
<?php
}
elseif(mb_strlen(utf8_decode($firstnameinput), "UTF-8") > 25 ) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> First name is not valid. </div>
<?php
}
else {
$firstnametest1 = True;
// Test #2 - Makes sure it does not have any restricted characters
if(!preg_match("~^[\p{L}\p{N}]+$~u", utf8_decode($firstnameinput))) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> First name contains restricted characters. </div>
<?php
}
elseif(preg_match('~(\S)(?:\1){10,}~mui', utf8_decode($firstnameinput))) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> First name is not valid. </div>
<?php
}
else {
$firstnametest2 = True;
// Final Check
if (($firstnametest1) and ($firstnametest2)) {
$firstnamefinalcheck = True;
}
else {
$firstnamefinalcheck = False;
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> There is a error. </div>
<?php
}
}
}
}
?>
</div>
<div class="row">
<div id="informationtitlesmall" class="col-xs-12 col-sm-5">
* Last Name
</div>
<div id="informationlastname" class="col-xs-12 col-sm-7">
<input type="text" name="lastname" id="lastnameinput" value="<?php print mb_ucfirst($lastnameinput); ?>" />
</div>
<?php
if ($_POST) {
$lastnametest1 = False;
$lastnametest2 = False;
// Test #1 - Makes sure it fits the length requirements
if(mb_strlen(utf8_decode($lastnameinput), "UTF-8") < 3 ) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Last name is not valid. </div>
<?php
}
elseif(mb_strlen(utf8_decode($lastnameinput), "UTF-8") > 35 ) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Last name is not valid. </div>
<?php
}
else {
$lastnametest1 = True;
// Test #2 - Makes sure it does not have any restricted characters
if(!preg_match("~^[\p{L}\p{N}-]+$~u", utf8_decode($lastnameinput))) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Last name contains restricted characters. </div>
<?php
}
elseif(preg_match('~(\S)(?:\1){10,}~mui', utf8_decode($lastnameinput))) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Last name is not valid. </div>
<?php
}
else {
$lastnametest2 = True;
// Final Check
if (($lastnametest1) and ($lastnametest2)) {
$lastnamefinalcheck = True;
}
else {
$lastnamefinalcheck = False;
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> There is a error. </div>
<?php
}
}
}
}
?>
</div>
<div class="row">
<div id="informationtitlesmall" class="col-xs-12 col-sm-5">
Age
</div>
<div id="informationage" class="col-xs-12 col-sm-7">
<input type="text" name="age" id="ageinput" value="<?php print utf8_decode($ageinput); ?>" />
</div>
<?php
if ($_POST) {
$agetest1 = False;
$agetest2 = False;
if (utf8_decode(trim($_POST["age"])) == "") {
$agefinalcheck = True;
$ageinput = "";
}
else {
// Test #1 - Makes sure it fits the length requirements
if(mb_strlen(utf8_decode($ageinput), "UTF-8") > 3 ) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Age is not valid. </div>
<?php
}
elseif(utf8_decode($ageinput) > 125 ) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Age is not valid. </div>
<?php
}
elseif(utf8_decode($ageinput) < 14 ) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> You are too young. </div>
<?php
}
else {
$agetest1 = True;
// Test #2 - Makes sure it does not have any restricted characters
if(!preg_match("~^[0-9]+$~", utf8_decode($ageinput))) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Age is not valid. </div>
<?php
}
else {
$agetest2 = True;
// Final Check
if (($agetest1) and ($agetest2)) {
$agefinalcheck = True;
$ageinput = $_POST["age"];
}
else {
$agefinalcheck = False;
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> There is a error. </div>
<?php
}
}
}
}
}
?>
</div>
<div class="row">
<div id="informationtitlesmall" class="col-xs-12 col-sm-5">
Location
</div>
<div id="informationlocation" class="col-xs-12 col-sm-7">
<input type="text" name="location" id="locationinput" value="<?php print utf8_decode($locationinput); ?>" />
</div>
<?php
if ($_POST) {
$locationtest1 = False;
$locationtest2 = False;
if (utf8_decode(trim($_POST["location"])) == "") {
$locationfinalcheck = True;
$locationinput = "";
}
else {
// Test #1 - Makes sure it fits the length requirements
if(mb_strlen(utf8_decode($locationinput), "UTF-8") < 3 ) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Location is not valid. </div>
<?php
}
elseif(mb_strlen(utf8_decode($locationinput), "UTF-8") > 60 ) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Location is not valid. </div>
<?php
}
else {
$locationtest1 = True;
// Test #2 - Makes sure it does not have any restricted characters
if(!preg_match("~^[\p{L}\p{N},() .-]+$~u", utf8_decode($locationinput))) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Location contains restricted characters. </div>
<?php
}
elseif(preg_match('~(\S)(?:\1){10,}~mui', utf8_decode($locationinput))) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Location is not valid. </div>
<?php
}
else {
$locationtest2 = True;
// Final Check
if (($locationtest1) and ($locationtest2)) {
$locationfinalcheck = True;
$locationinput = utf8_encode(htmlspecialchars(trim($_POST["location"]), ENT_QUOTES));
}
else {
$locationfinalcheck = False;
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> There is a error. </div>
<?php
}
}
}
}
}
?>
</div>
</div>
<div class="col-xs-12 col-sm-3">
<div id="informationtiptext">
<strong>Remember:</strong> Anyone can see your profile, do not share information you do not want others to know!
</div>
</div>
</div>
<div class="row" id="informationquoteholder">
<div id="informationtitlesmall" class="col-xs-12 col-sm-3">
Quote
</div>
<div id="quoteinputwidth" class="col-xs-12 col-sm-5 col-md-8">
<input type="text" name="quote" id="quoteinput" value="<?php print utf8_decode($quoteinput); ?>" />
</div>
<?php
if ($_POST) {
$quotetest1 = False;
$quotetest2 = False;
if (utf8_decode(trim($_POST["quote"])) == "") {
$quotefinalcheck = True;
$quoteinput = "";
}
else {
// Test #1 - Makes sure it fits the length requirements
if(mb_strlen(utf8_decode($quoteinput), "UTF-8") < 3 ) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Quote is too short. </div>
<?php
}
elseif(mb_strlen(utf8_decode($quoteinput), "UTF-8") > 100 ) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Quote is too long, maxium 100 characters.</div>
<?php
}
else {
$quotetest1 = True;
// Test #2 - Makes sure it does not have any restricted characters
if(!preg_match("~^[\p{L}\p{N},() _@.?!:;-]+$~u", utf8_decode($quoteinput))) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Quote contains restricted characters. </div>
<?php
}
elseif(preg_match('~(\S)(?:\1){10,}~mui', utf8_decode($quoteinput))) {
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> Quote is not valid. </div>
<?php
}
else {
$quotetest2 = True;
// Final Check
if (($quotetest1) and ($quotetest2)) {
$quotefinalcheck = True;
$quoteinput = utf8_encode(htmlspecialchars(trim($_POST["quote"]), ENT_QUOTES));
}
else {
$quotefinalcheck = False;
?>
<div id="allinputboxerror" class="col-xs-12 col-sm-offset-5 col-sm-7"> There is a error. </div>
<?php
}
}
}
}
}
?>
</div>
<div class="row" id="informationgenderholder">
<div id="informationtitlesmall" class="col-xs-12 col-sm-3">
Gender
</div>
<div class="col-xs-12 col-sm-8" id="radioholder" >
<input type="radio" name="gender" value="Male" id="selectormale" class="col-xs-12 col-sm-4"> <!-- Gender Selector -->
<label for="selectormale"> Male </label>
<input type="radio" name="gender" value="Female" id="selectorfemale" class="col-xs-12 col-sm-4">
<label for="selectorfemale"> Female </label>
<input type="radio" name="gender" value="Other" id="selectorother" class="col-xs-12 col-sm-4">
<label for="selectorother"> Other </label>
</div>
</div>
<div class="row" id="aboutinformationeditboxholder">
<div id="informationtitlesmallabout" class="col-xs-12 col-sm-3">
About
</div>
<div class="col-xs-12 col-sm-8" id="aboutinformationeditbox">
<textarea id="aboutinformationboxstyle" rows="1" cols="15" name="about" maxlength="10000"><?php print utf8_decode($aboutinput); ?></textarea>
<div id="aboutcharactercount"> <span id="textareacharactercount">0</span> / 2500 </div>
<script>
function wordCount(val){
return {characters : val.length,};
}
var print = document.getElementById("textareacharactercount");
var grab = document.getElementById("aboutinformationboxstyle");
grab.addEventListener("input", function(){
var wordcountprint = wordCount( this.value );
print.innerHTML = (wordcountprint.characters);
}, false);
</script>
<?php
if ($_POST) {
$abouttest1 = False;
$abouttest2 = False;
if (utf8_decode(trim($_POST["about"])) == "") {
$aboutfinalcheck = True;
$aboutinput = "";
}
else {
// Test #1 - Makes sure it fits the length requirements
if(mb_strlen(utf8_decode($aboutinput), "UTF-8") < 3 ) {
?>
<div id="allinputboxerroraboutbox" class="col-xs-12 col-sm-7"> About section is too short. </div>
<?php
}
elseif(mb_strlen(utf8_decode($aboutinput), "UTF-8") > 2500 ) {
?>
<div id="allinputboxerroraboutbox" class="col-xs-12 col-sm-7"> About section is too long. </div>
<?php
}
else {
$abouttest1 = True;
// Test #2 - Makes sure it does not have any restricted characters
if(!preg_match("~^[\p{L}\p{N},() _@.?!:;\r\n-]+$~u", utf8_decode($aboutinput))) {
?>
<div id="allinputboxerroraboutbox" class="col-xs-12 col-sm-7"> About section contains restricted characters. </div>
<?php
}
elseif(preg_match('~(\S)(?:\1){50,}~mui', utf8_decode($aboutinput))) {
?>
<div id="allinputboxerroraboutbox" class="col-xs-12 col-sm-7"> About section is not valid. </div>
<?php
}
else {
$abouttest2 = True;
// Final Check
if (($abouttest1) and ($abouttest2)) {
$aboutfinalcheck = True;
$aboutinput = utf8_encode(htmlspecialchars(trim($_POST["about"]), ENT_QUOTES));
}
else {
$aboutfinalcheck = False;
?>
<div id="allinputboxerroraboutbox" class="col-xs-12 col-sm-7"> There is a error. </div>
<?php
}
}
}
}
}
?>
</div>
</div>
<div class="col-xs-12">
<button id="profileinformationbutton" input type="submit" value="Login"> Update Profile </button>
</div>
<div class="col-xs-12">
<a href="http://localhost/postin'/profiles/<?php print utf8_decode($loggedin_session_permalink); ?>">
<div id="informationcancelbutton" input type="submit" value="Cancel"> Cancel </div>
</a>
</div>
</form>
</div>
</div>
<!-- ========================================================================================================================== -->
<!-- AN AD -->
<!-- ========================================================================================================================== -->
<!-- BELOW WILL BE EXECUTED IF THE USER HAS ALLOWED ADS IN THERE PREFERENCES -->
<!-- DISPLAYS THE ADS -->
<?php
if (isset($_SESSION["logged_in"])) {
if ($loggedin_session_allowads == "false") {
}
else {
?>
<div class="row">
<?php include("C:\wamp\www\postin'\includes\ads\adleaderboard1.php");?>
</div>
<?php
}
}
else {
?>
<div class="row">
<?php include("C:\wamp\www\postin'\includes\ads\adleaderboard1.php");?>
</div>
<?php
}
?>
<!-- ========================================================================================================================== -->
<!-- UPDATES THE DATABASE -->
<!-- ========================================================================================================================== -->
<?php
if (($firstnamefinalcheck) and ($lastnamefinalcheck) and ($agefinalcheck) and ($locationfinalcheck) and ($quotefinalcheck)) {
$age_for_database = "";
if (isset($ageinput)) {
$age_for_database = $ageinput;
}
else {
$age_for_database = "";
}
$location_for_database = "";
if (isset($locationinput)) {
$location_for_database = $locationinput;
}
else {
$location_for_database = "";
}
$quote_for_database = "";
if (isset($quoteinput)) {
$quote_for_database = $quoteinput;
}
else {
$quote_for_database = "";
}
$about_for_database = "";
if (isset($aboutinput)) {
$about_for_database = $aboutinput;
}
else {
$about_for_database = "";
}
$inputquery = "UPDATE users SET firstname = :firstname, lastname = :lastname, age = :age, location = :location, quote = :quote, gender = :gender, about = :about WHERE id = :id";
$datasend = $connection->prepare($inputquery);
$datasend->execute(array(':firstname'=>mb_ucfirst($firstnameinput),
':lastname'=>mb_ucfirst($lastnameinput),
':age'=>utf8_decode($age_for_database),
':location'=>utf8_decode($location_for_database),
':quote'=>utf8_decode($quote_for_database),
':gender'=>$genderinput,
':about'=>utf8_decode($about_for_database),
':id'=>$_SESSION["logged_in"]));
}
?>
</div>
<?php include("C:\wamp\www\postin'\includes\bottom.php");?>
</div>
</body>
</html>
<?php }} ?>
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);right after the connection is opened, and add error reporting to the top of your file(s) right after your opening<?phptagerror_reporting(E_ALL); ini_set('display_errors', 1);see if it yields anything. Debugging is the first part you should learn while coding, before posting a question.