I am currently making a bio section for a website and so far I have a way to "edit the profile". What I want to happen is the text that is inserted be saved into a file I have already created. Here's the current code that I have with their according names.
Profile Editing Page (editprofile.php)
<?php
session_start();
if (!isset($_SESSION['username'])) {
$_SESSION['msg'] = "You must log in first";
header('location: login.php');
}
if (isset($_GET['logout'])) {
session_destroy();
unset($_SESSION['username']);
header("location: login.php");
}
$username = $_SESSION['username'];
$file = "extra/" . $username . ".png";
if (!file_exists($file))
$file = 'extra/defaultProfile.png';
?>
<html>
<title> Home Page </title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<header>
<div class="container">
<nav>
<ul>
<li>Home</li>
<li>Downloads</li>
<li>Chat</li>
<li>Profile</li>
<li class="logout">Logout</li>
</ul>
</nav>
</div>
</header>
<body>
<div class="profileimg">
<img src=<?php echo $file; ?> width="125" height="125">
</div>
<div class="profilename">
<p style="position: absolute; top: 8px; left: 130px; color: white; font-size: 30px;"><?php echo $username ?></p>
</div>
<div class="biotext">
<textarea style="position: absolute; top: 75px; left: 132.5px; width: 450px; height: 87px;"></textarea>
</div>
</body>
<footer>
<div class="status">Currently logged in as <?php echo $username ?></div>
</footer>
</html>
The Display Profile Page (profile.php)
<?php
session_start();
if (!isset($_SESSION['username'])) {
$_SESSION['msg'] = "You must log in first";
header('location: login.php');
}
if (isset($_GET['logout'])) {
session_destroy();
unset($_SESSION['username']);
header("location: login.php");
}
$username = $_SESSION['username'];
$file = "extra/" . $username . ".png";
if (!file_exists($file))
$file = 'extra/defaultProfile.png';
?>
<html>
<title> Home Page </title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<header>
<div class="container">
<nav>
<ul>
<li>Home</li>
<li>Downloads</li>
<li>Chat</li>
<li>Profile</li>
<li class="logout">Logout</li>
</ul>
</nav>
</div>
</header>
<body>
<div class="profileimg">
<img src=<?php echo $file; ?> width="125" height="125">
</div>
<div class="profilename">
<p style="position: absolute; top: 8px; left: 130px; color: white; font-size: 30px;"><?php echo $username ?></p>
</div>
<div class="biotext">
<iframe width=25% height=9.5% src="getbio.php" background-color='white' style=" position: absolute; top: 75px; left: 132.5px;"></iframe>
</div>
<p>Edit Your Profile</p>
</body>
<footer>
<div class="status">Currently logged in as <?php echo $username ?></div>
</footer>
</html>
The Part to get the bio text from a file (getbio.php)
<?php
session_start();
if (!isset($_SESSION['username'])) {
$_SESSION['msg'] = "You must log in first";
header('location: login.php');
}
if (isset($_GET['logout'])) {
session_destroy();
unset($_SESSION['username']);
header("location: login.php");
}
$username = $_SESSION['username'];
$bioFile = "bio/" . $username . ".txt";
if (!file_exists($bioFile))
$bioFile = 'bio/defaultBio.txt';
?>
<style>body {background-color: #f1f1f1;}
</style><body><?php echo nl2br( file_get_contents($bioFile) );
?></body>
CSS (main.css)
body {
margin: 0;
background: #222;
font-family: arial;
font-weight: 500;
}
.container {
width: 100%;
margin: 0 auto;
}
header {
background: #55d6aa;
}
header::after {
content: '';
display: table;
clear: both;
}
nav {
float: left;
width: 100%;
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 70px;
padding-top: 10px;
padding-bottom: 10px;
position: relative;
}
nav a {
color: #444;
text-decoration: none;
text-transform: uppercase;
font-size: 14px;
}
nav li:hover {
color: #000;
}
nav li::before {
content: '';
display: block;
height: 5px;
background-color: #444;
position: absolute;
top: 0;
width: 0%;
transition: all ease-in-out 250ms;
}
nav li:hover::before {
width: 100%;
}
.logout {
float: right;
margin-right: 50px;
}
.status {
position: absolute;
bottom: 5px;
right: 5px;
color: green;
}
.download {
display: inline-block;
text-decoration: none;
list-style: none;
}
.download a{
color: lime;
text-decoration:none;
padding-left: 50px;
}
.download a:hover{
color: green;
text-decoration:none;
}
.download li {
display: inline;
float: right;
padding-top: 17.5px;
}
The CSS is just for good viewing of the website and the other parts are for reference. I'm not sure how to save the text from the textarea (part of the editprofile.php) to files inside a folder called /bio. If anyone can help me, I'd be really thankful.
What is missing from your code is a way to send the data entered on the edit page to the server for processing and saving. Obviously, you cannot open a file that has not been created.
The html element used to send data to a server is <form> which interacts with editing (input) elements such as <textarea>.
I suggest some learning on your part. Here is one place to start.
Related
I've tried everything I know to make the height of the black part change according to the "samples" in the picture above. Whenever I add new "sample" that will go down the black part does not follow. Is there something wrong in my code, if there is please let understand how to fix it cause Im new at this.
Here is my code:
body,
html,
.yourteachers,
.fullpage
{
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
.fullpage
{
background-color: black;
}
.leftForm
{
background-color: #2c384a;
width: 204px;
height: 100%;
float: left;
font-family: calibri;
color: white;
text-align: center;
}
.yourteachers
{
text-align: center;
}
.announcementSlider
{
background-color: #323f4f;
color: white;
font-size: 24px;
height: 280px;
width: 200px;
margin: 20px;
display: inline-block;
}
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/teachers.css">
</head>
<body>
<header>
<nav>
<div class="nav-wrapper blue">
<div class="container">
Teachers
<i class="material-icons">menu</i>
<ul class="hide-on-med-and-down right">
<li><a id="dashb">Home</a></li>
<li><a id="logout">Log Out</a></li>
</ul>
</div>
</div>
</nav>
</header>
<div class="fullpage">
<div class="leftForm hide-on-med-and-down">
<img src="pictures/default-avatar-250x250.png">
<p class="name">
<?php echo $name; ?>
</p>
<p class="section">
<?php echo $grade; ?>-
<?php echo $section; ?>
</p>
</div>
<div class="leftForm sidenav blue center" id="slide_out">
<img src="pictures/default-avatar-250x250.png">
<p class="name">
<?php echo $name; ?>
</p>
<p class="section">
<?php echo $grade; ?>-
<?php echo $section; ?>
</p>
</div>
<div class="yourteachers">
<?php
while ($row = mysqli_fetch_array($query)) {
echo '<a class="announcementSlider" href="teacherinfo.php?id=' . $row['IDNum'] . '">
<img src="pictures/blank photo.png" class="teacherpic"><br>
<span>'.$row['LastName'].'</span><br>
<span>'.$row['Grade'].' - </span>
<span>'.$row['Section'].'</span>
</a>';
}
?>
</div>
</div>
<script type="text/javascript">
var a = document.getElementsByClassName("announcementSlider");
for (i = 0; i < a.length; i++) {
a[i].onclick = function() {
location.href = "teacherinfo.php";
};
}
</script>
<script src="js/teachers.js"></script>
<script src="sameFunctions.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script type="text/javascript">
const slide_menu = document.querySelectorAll(".sidenav");
M.Sidenav.init(slide_menu, {});
</script>
<footer>
<div class="foot">
<div class="socialMed">
</div>
</div>
</footer>
</body>
</html>
It's because your .fullpage needs to follow .yourteachers 's height. And your .leftForm has float: left but it's parent (.fullpage) still doesn't know the exact height of it's children. To fix it, you need to add clear: both by using div with additional .clearboth class or css :before or :after pseudo-selector.
see my fiddle here
In my approach above, I'm using fixed sidebar and add margin-left on .yourteachers to fix sidebar height issue. For better implementation, I recommend you to use flex box so you keep your sidebar not using fixed position.
<!-- language-all: lang-css -->
body, html, .yourteachers, .fullpage {
margin: 0;
padding: 0;
}
body, html {
width: 100%;
height: 100%;
background: black;
}
.fullpage {
overflow: hidden
}
.leftForm{
background-color: #2c384a;
width: 204px;
height: 100%;
float: left;
font-family: calibri;
color: white;
text-align: center;
}
.yourteachers{
text-align: center;
}
.announcementSlider{
background-color: #323f4f;
color: white;
font-size: 24px;
height: 280px;
width: 200px;
margin: 20px;
display: inline-block;
}
Have u tried height: 100vh? Height is automatically adjusting, so just height: 100% means 100% height of parent.
I'm having some problems with my login feature using php with multiple users, I'm not using a database as this is a school assignment.
So the assignment is as follows "create an associative array with usernames as keys and encrypted passwords using password_hash. Once the user has logged in it shall print out the users name." We got a template that we should use, I will paste all the necessary code. So the problem I am having is, that when I try to log in as a user it keeps redirecting me so that I get the "too many redirects" error.
login.php
<?php
session_start();
if(isset($_POST['password'],$_POST['username'])){
include("pwd.php");
include("user.php");
$key = $_POST['username'];
if(isset($user[$key])){
$_SESSION['inloggad'] = true; // Användaren har anget rätt uppgifter.
$_SESSION['user'] = $_POST['username'];
}
}
if(isset($_SESSION['inloggad'])){
header("Location: index.php");
}
else{
echo "<h1>Vänligen logga in!</h1>";
}
?>
login.html
<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="utf-8" >
<title>Sessioner</title>
</head>
<body>
<form method="post" action="login.php">
Username: <input type="username" name="username" size="20" /><br />
<br>
Password: <input type="password" name="password" size="20" /><br />
<input type="submit" value="Logga in" name="login"/>
</form>
</body>
</html>
user.php
<?php
$user['admin'] = '$2y$10$9NyoNcqG9sh0KOrVnUXLr.KscgDy0L1S0klYXK67oxVBVsElbbGja';
$user['hank'] = '$2y$10$tQNcTINMIcotw0IczQ1nTuOVRIpbuqh5M/k.mLpz7ZiZl8q2WA0Cy';
$user['elias'] = '$2y$10$tQNcTINMIcotw0IczQ1nTuOVRIpbuqh5M/k.mLpz7ZiZl8q2WA0Cy';
?>
start.php
<h1>Välkommen</h1>
<?php
include("login.php");
if(isset($_POST['password'],$_POST['username'])){
echo '<h1>' . $_POST['username'] . '</h1>';
}
?>
index.php
<?php session_start(); ?>
<!doctype html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<title>Länka in med PHP</title>
<link href="css/styleSheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<header>
<?php include("header.php"); ?>
</header><!-- header -->
<section id="leftColumn">
<nav>
<?php
if(isset($_SESSION['inloggad'])){
include("meny.php");
}else{
include("login.html");
}
?>
</nav>
<aside>
<?php include("aside.php"); ?>
</aside>
</section><!-- End leftColumn -->
<main>
<section>
<!-- Lägg in innehållet här -->
<?php
$page = "start";
if(isset($_GET['page']))
$page = $_GET['page'];
switch($page){
case 'blogg': include('blogg.php');
break;
case 'bilder': include('bilder.php');
break;
case 'kontakt': include('kontakt.php');
break;
case 'klotter': include('klotter.php');
break;
default: include('start.php');
}
?>
</section>
</main><!-- End main -->
<footer>
<?php include('footer.php'); ?>
</footer><!-- End footer -->
</div><!-- End wrapper -->
</body>
</html>
styleSheet.css
#CHARSET "UTF-8";
* {
margin:0;
padding:0;
font-family:Verdana, Geneva, sans-serif;
}
body{
font-size: 100%;
}
p {
font-size: 0.8em;
margin-bottom: 10px;
margin-top: 5px;
margin-right: 10px;
text-align: justify;
}
/* Wrapper */
#wrapper {
width: 800px;
margin-left: auto;
margin-right:auto;
margin-top:10px;
border: 2px solid rgba(0,0,0,0.8);
}
/* End wrapper */
/* Header */
header {
text-align:center;
height: 60px;
background-image: url("../bilder/bgImg.png");
color: white;
}
header h1{
font-family: Arial;
font-size: 1.9em;
padding-top: 0.25em;
}
header time{
float: right;
margin-right: 2em;
font-size: 0.8em;
}
/* End header */
nav{
border-radius: 5px; /* CSS3 */
border: 1px solid #999;
padding: 4px;
margin-bottom:5px;
}
nav ul {
list-style:none;
}
nav li{
margin-top: 5px;
border: 1px solid #000;
}
nav li a{
display:block;
font-size: 0.8em;
text-decoration: none;
color: #aa0000;
padding-left: 15px;
background-color:#FFC;
}
nav li a:hover, #leftColumn li a:active, #leftColumn li a:focus{
background-color: gray;
color: #ffffff;
}
aside {
-moz-border-radius: 5px; /* Ger rundade hörn i Firefox */
border-radius: 5px; /* CSS3 */
border: 1px solid #999;
padding: 4px;
margin-bottom:5px;
}
aside p {
font-size: 0.8em;
}
/* leftColumn */
#leftColumn {
float: left;
width: 180px;
margin: 8px;
}
#leftColumn h1 {
font-family:Arial, Helvetica, sans-serif;
font-size: 0.9em;
}
/* End leftColumn */
/* Main */
main {
margin-top: 8px;
margin-left:200px;
}
main h1{
font-family: Arial, Helvetica, sans-serif;
font-size: 1.4em;
}
main h2{
font-family: Arial, Helvetica, sans-serif;
font-size: 1.1em;
}
main section{
float:right;
width: 99%;
}
form label,a{
font-size: 0.8em;
}
/* End content */
/* Footer */
footer {
height: 30px;
background-image: url("../bilder/bgImg.png");
color: white;
font-size: 0.75em;
clear:both;
}
footer #footerRight{
float:right;
padding: 5px;
}
footer #footerLeft{
float:left;
padding: 5px;
}
/* End footer */
the rest of the template is not really necessary for me to paste as it's just html code for the website, I just linked the css code if you want to check what the page looks like yourself. If you need any more information that I might have forgotten to write please notify me.
I know there's a problem with me using include("login.php") in the start.php, I just don't know how to solve it as I need the information submitted in the login form. The page controller is stating that start.php is the default page the template uses in the section.
EDIT: sorry I was not clear about this part. it only happens once I enter the correct details, for example, admin:12345.
EDIT 2:
new start.php code
<?php
include("login.php");
if(isset($_SESSION['user'])){
echo '<h1>Välkommen</h1>' . '<h1>' . $_SESSION['user'] . '</h1>';
}
?>
Full login.php I'm using:
<?php
session_start();
if (isset($_POST['password'], $_POST['username'])) {
include("pwd.php");
include("user.php");
$key = $_POST['username'];
if (isset($user[$key])) {
$_SESSION['inloggad'] = true; // Användaren har anget rätt uppgifter.
$_SESSION['user'] = $_POST['username'];
}
if (isset($_SESSION['inloggad']) && ($_SESSION['inloggad'] === TRUE)) {
header("Location: index.php");
} else {
echo "<h1>Vänligen logga in!</h1>";
}
}
In the index.php file there is a line default: include('start.php'); that can cause this page to redirect to itself because file start.php includes file login.php which has header("Location: index.php"). The same problem would apply in case any other included file on this page lead to inclusion of header("Location: index.php")
Okay so I have found after some long research a code that I will include here that adds prev/next url at bottom of page. What I am doing is making a portfolio that in the future I will add pages and remove, so I needed a php code that would run pages using the footer.php and go to next in line. Example it would show page1.php, page2.php, page3.php, page4.php and so on. That all works great in the code I have. What I would like now is to put a variable name on each page of what that portfolio piece will be then have it echo next to the previous and next button. I can get it to work, but it shows the existing name on each prev/next button.
If I am not making sense just tell me and I will explain it differently. I hope someone can help, been trying to get my portfolio done for some time now! :)
Here is my header.php
<html>
<head>
<title>PAGINATION TEST</title>
<link rel="stylesheet" type="text/css" href="./css/style.css" />
</head>
<nav>
<div id="nav_menu">
<ul>
<li>HOME</li>
<li>ABOUT</li>
<li>CONTACT</li>
</ul>
</div>
</nav>
<body>
Here is my page1.php
<?php //THIS IS THE PREVIOUS/NEXT LINK TITLE FOR EACH PORTFOLIO PAGE
session_start();
$_SESSION['link-title'] = "wonder woman";
?>
<?php include('header.php') ?>
<div id="main_body">
PAGE 1
</div>
<?php include('footer.php') ?>
Here is my footer.php
<?php
session_start(); //this NEEDS to be at top of the page before any output etc
?>
<?php
$pinfo = pathinfo($_SERVER["SCRIPT_FILENAME"]);
$reqpath = dirname($_SERVER["REQUEST_URI"]);
$linkname = ($_SESSION['link-title']);
if(preg_match("/(.*?)(\d+)\.php/", $pinfo["basename"], $matches)) {
$fnbase = $matches[1];
$fndir = $pinfo["dirname"];
$linkTitle = $linkname;
$current = intval($matches[2]);
$next = $current + 1;
$prior = $current - 1;
$next_file = $fndir . DIRECTORY_SEPARATOR . $fnbase . $next . ".php";
$prior_file = $fndir . DIRECTORY_SEPARATOR . $fnbase . $prior . ".php";
$next_link = $linkTitle . $next;
$prev_link = $linkTitle . $prior;
if(!file_exists($next_file)) $next_file = false;
if(!file_exists($prior_file)) $prior_file = false;
if($prior_file) {
$link = $reqpath . DIRECTORY_SEPARATOR . basename($prior_file);
// echo "Prior";
}
if($prior_file && $next_file) {
// echo " / ";
}
if($next_file) {
$link = $reqpath . DIRECTORY_SEPARATOR . basename($next_file);
// echo "Next";
}
if($prev_link) {
$prevTitle = $prev_link;
}
if($next_link) {
$Title = $next_link;
}
}
?>
<div id="pagination_container">
<div id="previous_link">
<!-- PREVIOUS -->
<?php if($prior_file) {
$link = $reqpath . DIRECTORY_SEPARATOR . basename($prior_file);
echo "PREVIOUS";
// echo $_SESSION['link-title'];
echo $prevTitle;
}
?>
</div>
<div id="next_link">
<!-- NEXT -->
<?php if($next_file) {
$link = $reqpath . DIRECTORY_SEPARATOR . basename($next_file);
echo $Title;
// echo $_SESSION['link-title'];
echo "NEXT";
}
?>
</div>
</div>
<div id="footer">
copyright blah blah
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</body>
</html>
here is my css
body,html {
padding: 0;
margin: 0;
overflow-x: hidden;
}
#nav_menu {
background-color: pink;
width: 100%;
height: 80px;
}
#nav_menu ul {
text-align: right;
}
#nav_menu li {
list-style-type: none;
display: inline-block;
padding-right: 20px;
padding-top: 30px;
}
#main_body {
width: 100%;
background-color: #dbdbdb;
height: 400px;
padding: 20px;
color: #333333;
}
#pagination_container {
width: 100%;
background-color: pink;
display: flex;
}
#previous_link {
width: 50%;
background-color: purple;
color: white;
display: flex;
float: left;
text-align: left;
padding-top: 50px;
padding-bottom: 50px;
padding-left: 20px;
}
#previous_link:hover {
color: white;
transition: 0.5s all;
}
#previous_link:link {
color: white;
text-decoration: none;
}
#next_link {
width: 50%;
background-color: purple;
color: white;
text-align: right;
padding-top: 50px;
padding-bottom: 50px;
padding-right: 20px;
border-left: 1px solid #dbdbdb;
}
#next_link a:visited {
color: white;
}
#next_link a:link {
color: white;
text-decoration: none;
}
#next_link a:hover {
color: blue;
transition: 0.5s all;
}
#next_link:hover {
background-color: pink;
transition: 0.5s all;
}
#footer {
text-align: center;
padding-top: 20px;
}
Here is page2.php for example of how it works now
<?php //THIS IS THE PREVIOUS/NEXT LINK TITLE FOR EACH PORTFOLIO PAGE
session_start();
$_SESSION['link-title'] = "superman";
?>
<?php include('header.php') ?>
<div id="main_body">
PAGE 2
</div>
<?php include('footer.php') ?>
I've tried a couple things and I can't seem to get this to update instead of recreating the file.
With A LOT of help from users here I created a menu template for our chef here at my facility. He enters his information and it creates a menu automatically with an image all kinds of fancy things.
What I'm hoping now is if he needs to change a menu item he doesn't have to retype every days information back in. I've read up on FILE_APPEND as well as fopen but don't seem to be doing what I need.
Here's the script I'm utilizing.
<?php
$MessageMondayMain = $_POST['MessageMondayMain'];
$MessageTuesdayMain = $_POST['MessageTuesdayMain'];
$MessageWednesdayMain = $_POST['MessageWednesdayMain'];
$MessageThursdayMain = $_POST['MessageThursdayMain'];
$MessageFridayMain = $_POST['MessageFridayMain'];
$MessageMonday = $_POST['MessageMonday'];
$MessageTuesday = $_POST['MessageTuesday'];
$MessageWednesday= $_POST['MessageWednesday'];
$MessageThursday = $_POST['MessageThursday'];
$MessageFriday = $_POST['MessageFriday'];
$MessageDate = $_POST['MessageDate'];
ob_start();
?>
<META http-equiv='Content-Type' content='text/html; charset=UTF-8'>
<html>
<head>
<title>GCH Cafe Menu</title>
<style>
.menu {
padding-top: 22px;
padding-right: 350px;
box-sizing: border-box;
margin: 0 auto;
line-height: 100%;
color: black;
overflow-y: scroll;
}
.menu h1 {
padding-top: 1px;
font-size: 40px;
font-family: candara;
position: relative;
}
.menu h2 {
z-index:3
font-size: 30px;
font-family: Time New Roman;
text-decoration: Underline;
color: black;
text-transform: uppercase;
color: rgb(54,113,91);
}
.menu h3 {
z-index:3
font-size:25px;
font-family: candara;
text-transform: uppercase;
text-weight: bold;
color: rgb(152,180,155);
}
.menu h4 {
z-index:3
font-family: candara;
font-size: 18px;
line-height:100%;
width: 650px;
color: gray;
}
.container {
position:absolute;
}
.outline {
position: absolute;
left: -570px;
z-index:1
}
.chef {
position: absolute;
top: 90px;
left: 150px;
z-index:2
}
.date {
position: absolute;
top: 810px;
right: 210px;
z-index:2
}
</style>
</head>
<body bgcolor="#f2f2f2">
<center>
<div class="container">
<img class="outline" src="plain.png" height="825" width="750">
<img class="chef" src="chef.png" height="690" width="450">
</div>
<div class="menu">
<h1><img src="cafe2.png" height="100" width="225"></h1>
<br>
<h2>Monday</h2>
<h3>-<?php echo nl2br ($MessageMondayMain);?>-</h3>
<h4><?php echo nl2br($MessageMonday); ?></h4>
<h2>Tuesday</h2>
<h3>-<?php echo nl2br ($MessageTuesdayMain);?>-</h3>
<h4><?php echo nl2br($MessageTuesday); ?></h4>
<h2>Wednesday</h2>
<h3>-<?php echo nl2br ($MessageWednesdayMain);?>-</h3>
<h4><?php echo nl2br($MessageWednesday); ?></h4>
<h2>Thursday</h2>
<h3>-<?php echo nl2br ($MessageThursdayMain);?>-</h3>
<h4><?php echo nl2br($MessageThursday); ?></h4>
<h2>Friday</h2>
<h3>-<?php echo nl2br ($MessageFridayMain);?>-</h3>
<h4><?php echo nl2br($MessageFriday); ?></h4>
<div class="date">
<h2>Menu Date:<br><br><?php echo ($MessageDate);?></h2>
</div>
</div>
</div>
</center>
</body>
</html>
<?php
$html = ob_get_contents();
ob_end_clean();
$filename = "menu.html";
file_put_contents($filename, $html);
echo file_get_contents("menu.html");
?>
<?php include('_header.php'); ?>
<?php
// if you need the user's information, just put them into the $_SESSION variable and output them here
echo WORDING_YOU_ARE_LOGGED_IN_AS . $_SESSION['user_name'] . "<br />";
//echo WORDING_PROFILE_PICTURE . '<br/><img src="' . $login->user_gravatar_image_url . '" />;
echo WORDING_PROFILE_PICTURE . '<br/>' . $login->user_gravatar_image_tag;
?>
<div>
<?php echo WORDING_LOGOUT; ?>
<?php echo WORDING_EDIT_USER_DATA; ?>
</div>
<?php include('_footer.php'); ?>
After logging in when it displays the "you are logged in" it is in the top left corner of my page and I need it in the top right corner.
I have tried multiple methods and none of them seem to solve my issue
here is the _header.php file, I have tried finding the "your logged in" section but unable to locate it.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>php-login-advanced</title>
<style type="text/css">
/* just for the demo */
body {
font-family: Arial, sans-serif;
font-size: 12px;
margin: 10px;
}
label {
position: relative;
vertical-align: middle;
bottom: 1px;
}
input[type=text]
{ position: absolute;
display: block;
top: 45px;
right: 30px;
}
input[type=password]
{ position: absolute;
display: block;
top: 80px;
right: 30px;
}
input[type=submit]
{ position: absolute;
display: block;
top: 115px;
right: 30px;
}
input[type=email] {
top: 30px;
right: 25px;
display: block;
margin-bottom: 15px;
}
input[type=checkbox] {
margin-bottom: 15px;
}
</style>
</head>
<body>
<?php
// show potential errors / feedback (from login object)
if (isset($login)) {
if ($login->errors) {
foreach ($login->errors as $error) {
echo $error;
}
}
if ($login->messages) {
foreach ($login->messages as $message) {
echo $message;
}
}
}
?>
<?php
// show potential errors / feedback (from registration object)
if (isset($registration)) {
if ($registration->errors) {
foreach ($registration->errors as $error) {
echo $error;
}
}
if ($registration->messages) {
foreach ($registration->messages as $message) {
echo $message;
}
}
}
?>
Add style="float:right;" to the div
Or better put this in a separate CSS file, in a CSS class declaration, and add the class to you div.
It would be something like
<div class="pull-right">
Add in the head of your HTML file :
<link rel="stylesheet" type="text/css" href="mycss.css" />
And in the mycss.css file:
.pull-right {
float:right;
}