HTML button moving on page refresh? - php

So I noticed this bug the other day where the button for the log in will move to a different location when the page is refreshed. However, if page is loaded from link, then it stays in correct position. I am drawing a blank as to why this would do this, here is the link and the code to my site.
Website: http://www.clanrippgaming.net/
HTML:
<div class="login_box">
<li>
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forums/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
if (!$user->data["is_registered"]) {
?>
<div class="logged_out">
<form action="./forums/ucp.php?mode=login" method="post" enctype="multipart/form-data">
<input type="text" placeholder="username" style="height:20px;" maxlength="20" size="17px" name="username" />
<input type="password" placeholder="password" style="height:20px;" maxlength="50" size="16px" name="password" />
<div class="button">
<input type="image" name="login" value="Log in" src="images/login.png" width="28px" onmouseout="this.src='images/login.png'" onmouseover="this.src='images/loginhover.png'" onmouseout="t">
</div>
<div class="logged_out_txt">
<br>
<input type="checkbox" name="autologin" id="autologin" />
<font size="2" color="#BDBDBD">
Remember Me
<div class="forgot">
<font size="2">
Forgot Password?
</font>
</div>
<div class="New">
<br>
New Member? Register Now!
</div>
</div>
<input type="hidden" name="redirect" value="./../index.php" />
</form>
</div>
<?php
}
else {
echo "<div class='logged_in'>";
echo "<div class='welcome'>" . $user->data['username'];
"</div>";
echo "<br><div class='account'>Logout</div>";
echo "<div class='account'>Messages</div>";
echo "<div class='account'>My Account</div>";
echo "</div>";
}
?>
</li>
</div>
CSS:
.login_box {
float: right;
width: 330px;
height: 75px;
margin-top: 7px;
margin-right: -5px;
list-style: none;
}
.login_box li {
}
.login_box li a {
color: #BDBDBD;
text-decoration: none;
padding-left: 60px;
padding: 0px;
}
.logged_in {
background-image: url(images/bg_login2.png);
border: 3px solid#000000;
outline: 1px solid#BDBDBD;
width: 304px;
height: 55px;
margin-left: -2px;
padding-top: 5px;
}
.logged_out {
margin-right: 38px;
}
.logged_out_txt {
margin-top: -20px;
}

Update the following changes to your CSS classes and it will be alright.
CSS
.logged_out {
margin-right: 22px;
position: relative;
}
.button {
position: absolute;
top: 0;
right:0;
}
Remove display:inline; float:right; margin-top: 0; and margin-left: 4px from .button

Looking at your website I suggest making the following changes to your CSS:
.button {
display: inline-block;
float: right;
}
.logged_out {
margin-right: 22px;
}

Related

CSS styling not working in a <small> tag with a php script in it

I am having an issue where if I use a bootstrap class to style a tag containing a PHP script, it works. However, when I use my own styling and use an ID or class to add a color to it, it doesn't. I'm not sure why the php text styles with bootstrap, but not with a regular ID or class. I'm attaching the code and a picture of the PHP variable that has the text that echos if the inputs are empty. I added the style directly to the PHP string and it works, but I don’t know why it can't if it's not setup that way
<section id="contact">
<div class="container-fluid">
<div class="row">
<div class="col">
<h1 class="text-center">We Want to Hear from You!</h1>
</div><!--col-->
</div><!--row-->
<div class="row">
<div class="col-md-10 offset-md-1">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<div class="row">
<div class="form-group col-md-4">
<small class="small-text"><?php if(isset($firstNameError)){echo $firstNameError;}?></small>
<label for="firstName" class="sr-only">First Name</label>
<input type="text" class="form-control" id="firstName" placeholder="First Name" name="firstName">
</div><!--col-md-4-->
<div class="form-group col-md-4">
<small class="text-danger"><?php if(isset($lastNameError)){echo $lastNameError;}?></small>
<label for="lastName" class="sr-only">Last Name</label>
<input type="text" class="form-control" id="lastName" placeholder="Last Name" name="lastName">
</div><!--col-md-4-->
<div class="form-group col-md-4">
<small class="text-danger"><?php if(isset($emailError)){echo $emailError;}?></small>
<label for="email" class="sr-only">Email</label>
<input type="email" class="form-control" id="email" placeholder="Email" name="email">
</div><!--col-md-4-->
<div class="form-group col">
<small class="text-danger"><?php if(isset($messageError)){echo $messageError;}?></small>
<label for="message" class="sr-only">Message</label>
<textarea id="message" class="form-control" rows="6" name="message">Message</textarea>
</div>
<div class="col-md-12 text-center">
<button class="text-center btn btn-dark btn-lg" type="submit" name="submit" value="Submit" id="submit" role="button">Submit</button>
</div>
<?php
if(isset($_POST["submit"])) {
echo "<h4 class='text-success'>Your message has been sent. We will contact you shortly :)!</h4>";
}
?>
</div><!--row-->
</form>
</div><!--col-->
</div><!--row-->
</div><!--container-->
</section>
-------CSS--------
* {
font-family: Montserrat, Helvetica, sans-serif;
color: #828282;
}
#font-face {
font-family: "Riffic";
src: url(../Riffic.ttf);
src: url(../Riffic/rifficfree-bold-webfont.woff);
}
body {
padding-top: 65px;
position: relative;
}
#navbar {
background: #FF9D9D;
}
#navbarBrand {
font-family: 'Riffic', sans-serif;
color: white;
font-size: 26px;
}
.navbar-dark .navbar-nav .nav-link {
color: rgba(255,255,255,1);
}
.navbar-dark .navbar-toggler {
color: rgba(255,255,255,1);
border: solid 2px rgba(255,255,255,.5);
}
.btn-outline-light:hover {
color: #FF9D9D;
}
a.btn.btn-outline-light.waysToHelp:active {
color: #FF9D9D;
}
.waysToHelp {
margin-left: 10px;
}
.waysToHelp:hover {
color: #FF9D9D;
}
#mainImage {
padding-bottom: 100px;
}
section {
padding: 58px 0 80px;
}
h1 {
color: #FF9D9D;
padding: 10px 0 25px;
}
h2 {
color: #FF9D9D;
padding: 10px 0 25px;
}
figure {
max-width: 435px;
}
#figCaption {
color: #FF9D9D;
font-weight: 500;
font-style: italic;
}
#projectCol {
margin-top: 100px;
}
#message {
color: #828282;
}
#submit {
padding: 8px 50px;
background-color: #FF9D9D;
border: none;
}
.small-text {
color: #FF9D9D;
}
footer {
padding: 20px;
}
footer a {
color: #FF9D9D;
}
#heart {
color: #FF9D9D;
}
#media only screen and (max-width: 767px) {
#mainImage{
padding-bottom: 50px;
}
section {
padding: 15px 0 20px;
}
img {
padding-bottom: 15px;
}
h2{
margin-top: -70px;
}
#figure1 {
display: block;
margin: 0 auto;
}
#figure2 {
display: block;
margin: 0 auto;
}
#figure3 {
display: block;
margin: 0 auto;
}
}
#media only screen and (min-width: 767px) and (max-width: 1029px) {
img {
padding-bottom: 15px;
}
}
I have something close to your issue its all about the #FFF some time it not translate in browser correctly when it inside php code (I don't know why ) , Please open inspect element in your browser and see did the css apply correctly like <small style="color:#whatever ; " > if it lock like it just clear browser data ( crt+shfit+del ), or you can change the style to class and solve the issue .

3 clickable icons in textbox

I wanna have 3 clickable icons in textbox
can someone support me with this
I found this code for a single clickable icon
I tried more icons in it but is not working
#form1 div {
position: relative;
width: 400px;
padding: 5px;
border: 1px solid #000;
overflow: hidden
}
#form1 label {
float: left;
text-align: right;
width: 80px;
padding: 0 20px;
}
#form1 input {
width: 200px;
padding: 5px 40px 5px 5px;
float: left;
}
#form1 a {
float: left;
margin: 2px 0 0 -32px;
text-decoration: none;
width: 30px;
height: 25px;
background: transparant;
position: relative;
z-index: 99;
}
<form id="form1" method="post" action="">
<div>
<label for="text">Enter text:</label>
<input type="text" name="text" id="text" />
<a href="http://www.pmob.co.uk"><img src="/user/icos/6.gif" border="none">
</a>
</div>
</form>
How about this???
sample screenshot
<form id="form1" method="post" action="">
<div>
<label for="text">Enter text:</label>
<input type="text" name="text" id="text" />
<a href="http://www.url.com"><img src="/folder/img/name.png" height="20" width="20">
</a>
</div>
<input type="submit" value="submit"/>
</form>
You can expand from here, take a look at the picture.... if thats what you want

Rename file location AJAX PHP

I am developing a sort of library in which a user is able to upload different files and then only post those desired.
When the user uploads a file or files, these will be stored in a temporary folder. Later, by filling a form the user can post a selected file. As soon as the user pushs the submit button I want to move the file from the temporary folder to another folder suggested by the user.
At the moment, I am able to create the suggested folder. Nevertheless, I am getting an "access denied (code 5)" error, and the files do not appear on the new folder. I've read other issues, and added "Read and Write" permissions to my all users for all folders inside htdocs(XAMPP folder). Still, the error continues to appear.
I am running this script in an AJAX file (shown below in the JS code).
Here is my code. Hope you can help me and this can help others! Than you
// When the form is submitted we want for the temp file to be moved to the directory chosen by the user
$( "form" ).submit(function( event ) {
$directory = $('#directory').val();
$file = $('#fileid').val();
$.ajax({
url:'ajax/rename.php',
type:"POST",
data:({ directory:$directory,
file:$file
}),
success:function(data){
//window.location.href = 'home';//redirect to the homepage
alert(data);
},
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(err.Message);
}
});event.preventDefault();
});
AJAX CODE
<?php
require_once '../../app/models/DB.php';
require_once '../../app/models/Files.php';
require_once '../../app/init.php';
$db= DB::getInstance();
$files= new Files();
$directory = $_POST['directory'];
$file = $_POST['file'];
if (!file_exists('../' . $directory)) {
mkdir('../' . $directory, 0744, true);
chmod('../'. $directory, 0777);
}
$currentdirectory = $db->query("SELECT path FROM file WHERE id = '$file'")->first()->path;
rename('../' . $currentdirectory,'../' . $directory);
$data = $db->query("UPDATE file SET path = '$directory' WHERE id = '$file'");
echo('../' . $currentdirectory);
?>
.secondaryContainer{
margin:0 auto; width:86%;
height:58px;
background: linear-gradient(to bottom,#FBFBFB,#A7A6A6) #f3f3f3;
border-radius: 5px 5px 5px 5px;
}
#HomesearchBar{
float:right;
}
.boxHeader{
padding:15px 15px 0px 15px ;
}
#headerTab{
border-bottom:0px;
}
.filesBoxContent{
background-color: #aeaeae !important;
border-color: #818181 !important;
border-radius: 5px 5px 5px 5px;
}
#MainPageThumbnails{
margin-top: 15px;
}
#MainPageThumbnails{
text-align:justify;
}
.clicked {
border: 3px solid blue;
}
#mainPage{
max-width: 900px;
}
#mainPage h1, #mainPage h2 {
font-size: 28px;
color: #25A7DE;
font-weight: lighter;
text-align: left;
}
.postPage legend {
text-align: center;
background: #25A7DE;
color: #fff;
font-size: 18px;
padding: 4px;
-webkit-border-radius: 34px;
-moz-border-radius: 34px;
border-radius: 34px;
width: 34px;
height: 34px;
}
fieldset{
border-top: 1px solid #ccc;
}
.fileUpload {
position: relative;
overflow: hidden;
margin: 10px;
}
.fileUpload input.upload {
position: absolute;
top: 0;
right: 0;
margin: 0;
padding: 0;
font-size: 20px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
#banner_warning{
float:left;
}
.form-actions {
margin: 0;
background-color: transparent;
text-align: center;
}
/*---------Category CSS-------*/
.subcategoryList,.categoryList {
border-radius: 15px;
background-color: white;
border: 1px solid #ccc;
padding: 5px;
min-height:150px;
max-height:150px;
overflow-y: auto;
overflow-x:hidden;
margin-bottom:20px !important;
}
.categoryList{
float: left;
width:49%;
}
.subcategoryList{
float: right;
width:49%;
visibility: hidden;
}
.subcategoryList ul,.categoryList ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.subcategory,.category {
text-decoration: none;
color: #000;
-webkit-transition: font-size 0.3s ease, background-color 0.3s ease;
-moz-transition: font-size 0.3s ease, background-color 0.3s ease;
-o-transition: font-size 0.3s ease, background-color 0.3s ease;
-ms-transition: font-size 0.3s ease, background-color 0.3s ease;
transition: font-size 0.3s ease, background-color 0.3s ease;
display: block;
}
.subcategory:hover,.category:hover {
font-size: 15px;
background: #f6f6f6;
}
.input-group{
z-index: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- Form Container -->
<div id="mainPage" class="container">
<h1>Add New Post</h1>
<div class = "postPage">
<form action="" method="post">
<fieldset class="form-group">
<legend>1</legend>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Title*</span>
<input type="text" class="form-control" name="title" id="title" aria-describedby="basic-addon1" placeholder="Enter the post title">
</div>
<div class="fileUpload btn btn-primary">
<span>Choose Banner</span>
<input type="file" name="banner" id="uploadBtn" class="upload" />
</div>
<span id="thumbnail" ></span>
<div id="banner_warning">
<small class="banner">Choose a banner for your post.</small>
</div>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Description*</span>
<textarea class="form-control" name="description" id="description" rows="10" placeholder="Type a short description for this file"></textarea>
</div>
</fieldset>
<fieldset class="form-group">
<legend>2</legend>
<div class="categoryList">
<ul>
<?php foreach($category as $item):?>
<li class="category" id="<?php echo $item->id;?>"><?php echo $item->name; ?></li>
<?php endforeach; ?>
</ul>
<input type="hidden" name="category" id="category"/>
</div>
<div class="subcategoryList">
<ul>
</ul>
<input type="hidden" name="subcategory" id="subcategory"/>
</div>
<!-- Trigger/Open The Modal -->
<div class="form-actions">
<button type="button" id="myBtn" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-paperclip" aria-hidden="true"></span> Add Media
</button>
</div>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Directory</span>
<input type="text" class="form-control" name="directory" id="directory" aria-describedby="basic-addon1">
<input type="hidden" name="filename" id="filename"/>
<input type="hidden" name="fileid" id="fileid"/>
</div>
</fieldset>
<fieldset class="form-group">
<legend>3</legend>
<label for="keywords"><h3>Keywords</h3></label>
<textarea class="form-control" name="keywords" id="keywords" rows="3"></textarea>
<small class="text-muted">Separate words by either '/' or ';'</small>
</fieldset>
<!--Token will be generated here. Model Token will be called for this-->
<input type="hidden" name = "token" value="<?php echo Token::generate(); ?>">
<input type="submit" value="Post">
</form>
</div>
</div>
<!-- End of Form Container -->
Firstly i would suggest your sanitize the user input:
$directory = $_POST['directory'];
$file = $_POST['file'];
Later you use $directory in SQL query, could give SQL injection issue.
Secondly check all the file/folder permissions of the parent folder in which the mkdir command makes its new folder.

what is the error in file handling concept in below php program ?

whenever i try to create a new txtfile using create button although the file get create but the data is not written into the file. i just het a blank file. what is the error ?
<?php
error_reporting(0);
if(isset($_POST['sub']))
{
$fname=$_POST["txtfile"];
$cont=$_POST['txtarea'];
if($_POST['sub']=="create")
{
fopen($fname,"w");
fwrite($fname, $cont);
}
else if($_POST['sub']=="read")
{
echo file_get_contents($fname);
}
else if($_POST['sub']=="delete")
{
unlink($fname);
}
else if($_POST['sub']=="append")
{
$cont=$_POST['txtarea'];
$fp=fopen($fname,"a");
fwrite($fp,$cont);
}
}
?>
here is the html code of above program. should i insert the php code for reading the file into the textarea code in html.?
<!DOCTYPE html>
<html>
<h3>file handling concept</h3>
<style type="text/css">
#form{
height: 200px;
width: 400px;
margin: 10px;
}
label {
float: left;
margin-right: 10px;
width: 70px;
padding-top: 5px;
font-size: 15px;
}
#form input, #form textarea{
padding: 5px;
width: 306px;
font-family: Helvetica, sans-serif;
font-size: 15px;
margin: 0px 0px 0px 0px;
border: 2px solid #ccc;
}
#button input{
float: right;
margin: 5px;
width: 60px;
padding: 5px;
border: 1px solid #ccc;
}
</style>
<div id="form">
<form method="POST" action="filehandling.php">
<label for="name">Filename:</label>
<input type="text" name="txtfile" placeholder="file-name.txt" />
<label for="name">content:</label>
<textarea name="txtarea" placeholder="write some content">
</textarea>
<div id="button">
<input type='submit' name='sub' value='create'>
<input type='submit' name='sub' value='delete'>
<input type='submit' name='sub' value='append'>
<input type='submit' name='sub' value='read'>
</div>
</form>
</div>
</html>
Your file creation and writing method should be as follows:
if($_POST['sub']=="create")
{
$fp = fopen($fname,"wb");
fwrite($fp,$cont);
fclose($fp);
}
I think you should use handle while creating the file too like below.
if($_POST['sub']=="create")
{
$fh = fopen($fname,"w");
fwrite($fh, $cont);
fclose($fh);
}
Also in else if($_POST['sub']=="append") there is no need to define $cont again as its already define with the same value.
so
else if($_POST['sub']=="append")
{
$cont=$_POST['txtarea'];
$fp=fopen($fname,"a");
fwrite($fp,$cont);
}
becomes
else if($_POST['sub']=="append")
{
$fp=fopen($fname,"a");
fwrite($fp,$cont);
fclose($fp);
}

Div tag does not contain content

I've created a form that enters comments onto my blog posts but when the comments are displayed on the webpage the background color that I added to the div is either to big or to small. I've provided the code below. Any help is appreciated!
<h2 id="comments-title">Comments</h2>
<div id="comment-list">
<?php
}
$commenttimestamp = strtotime("now");
$sql = "SELECT * FROM php_blog_comments WHERE entry='$id' ORDER BY timestamp";
$result = mysql_query ($sql) or print ("Can't select comments from table php_blog_comments.<br />" . $sql . "<br />" . mysql_error());
while($row = mysql_fetch_array($result)) {
$timestamp = date("l F d Y", $row['timestamp']);
printf("<div class='comment-ind'><p id='comments'><a id='username' href=\"%s\">%s</a> %s</p>", stripslashes($row['url']), stripslashes($row['name']), $timestamp);
print("<p class='comments'>" . stripslashes($row['comment']) . "</p><div class='clr'><br></div></div>");
}
?>
<form id="commentform" method="post" action="process.php">
<p><input type="hidden" name="entry" id="entry" value="<?php echo $id; ?>" />
<input type="hidden" name="timestamp" id="timestamp" value="<?php echo $commenttimestamp; ?>">
<input type="text" name="name" id="name" title="Name (required)" /><br />
<input type="text" name="email" id="email" title="Mail (will not be published) (required)" /><br />
<input type="text" name="url" id="url" title="Website" value="http://" /><br />
<br />
<textarea title="Your Comment Goes Here" name="comment" id="comment"></textarea></p>
<p><input type="submit" name="submit_comment" id="submit_comment" value="Add Comment" /></p>
</form>
</div>
CSS:
#comments-title {
background-color: #282828;
width: 567px;
height: 30px;
font-size: 25px;
font-family: arial;
color: #ffffff;
padding: 5px;
padding-top: 6px;
padding-bottom: 4px;
}
#comment-list{
border:1px solid #dadada;
width: 565px;
padding: 5px;
font-family: Helvetica;
font-size: 18px;
}
#comments {
width: 480px;
font-size: 12px;
color: #444444;
}
.comments {
width: 480px;
height: 20px;
}
.comment-ind {
background-color: #eeeeee;
width: 548px;
position: relative;
min-height: 10px;
margin: 5px;
padding: 8px;
}
Image:
Your problem is with height: 20px;. You can change it to min-height: 20px; and then it will be at least that height, but the way you have it, it will always be 20px tall regardless of the content.
Are we seeing the whole css that applies to this div. Looking at the screen shot I would guess that the paragraph of text is floated left and the containing div is not wrapping. Try removing the height and adding overflow:hidden to the containing .comments div. That way the height will adjust with the size of the contain.

Categories