Button CSS Query - php

I have a page that lists 3 buttons, outputted by a PHP if statement, each wrapped in a separate "a" tag. My problem is, when i update the CSS, the width of the buttons change, but the height will not.
I'm seriously baffled, I've checked all other id's and classes to check for conflicts etc, but cannot see anything obvious. The width alters when changed within the developer tools on chrome, but the height will not.
I may be missing something obvious, as i tend to do that, but cannot for the life in me see the issue.
Any help is appreciated.
Code: (Note: I am using an "admin" account, so $admin = 1.)
<?php
ini_set('display_errors', 'On');
session_start();
if($_SESSION['login'] == 0) {
header('Location: /includes/session_expired.php');
}
$admin = $_COOKIE['admin'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../stylesheet/main_stylesheet.css">
<link href="https://fonts.googleapis.com/css?family=Titillium+Web:400,700" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../js/date_time.js"></script>
<script type="text/javascript" src="../js/jquery.js"></script>
<?php
if($admin == 0) {
echo '<script type="text/javascript" src="../js/success_timer.js"></script>';
}
?>
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/divunk/html5.js"></script><![endif]-->
</head>
<body id="nauthBody">
<div id="nauth-container">
<div id="nauth-inner-container">
<div id="nauth-content">
<?php
if($admin == 0) {
echo ' <p>You are not authorised to view this page.</p>
<span id="timer"></span>';
} elseif ($admin == 1) {
echo ' <p>Please select an element to manage:</p>
<div id="system_selection">
<input class="system_button" type="button" name="users" value="Users"/>
<input class="system_button" type="button" name="authorised_comps" value="Authorised Computers"/>
<input class="system_button" type="button" name="resource_management" value="Resource Management"/>
</div>';
}
?>
</div>
</div>
</div>
</body>
</html>
And CSS:
.system_button {
height: 35px;
width: 65%;
}
#system_selection a {
cursor: pointer;
}
#system_selection {
height: auto;
width: auto;
}

right click on your button, use inspect element to find the style on this button. You will find which style has effect on it.

In the end I altered the code to the below. This was inspired by #divinecomedian's comment above, made me realise I could use a form wrapped around each button and change it a Submit input.
Problem solved.
Code: (From inside the "nauth-content" div)
<?php
if($admin == 0) {
echo ' <p>You are not authorised to view this page.</p>
<span id="timer"></span>';
} elseif ($admin == 1) {
echo ' <p>Please select an element to manage:</p>
<div id="system_selection">
<form action="user_management.php" method="post">
<input class="system_button" type="submit" name="users" value="Users"/>
</form>
<form action="authorised_devices.php" method="post">
<input class="system_button" type="submit" name="authorised_comps" value="Authorised Computers"/>
</form>
<form action="resource_management.php" method="post">
<input class="system_button" type="submit" name="resource_management" value="Resource Management"/>
</form>
</div>';
}
?>
Thanks to everyone that had some input!

Related

Make div visible using only PHP as event listener

I am testing to set up an "button event listener" that would show a hidden div at button click. Below code works, my question is more if there are other ways of solving this, with only HTML/CSS and PHP ?
I am fully aware the "button event listener" in this particular case is more of a "superglobal $_POST variable" checker.
The purpose of the test was more to see if the button press can be scanned from PHP itself (skipping other logics such as JS or jquery, etc).
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
</head>
<body>
<!-- Styling -->
<style>
.myDiv {display:none;}
</style>
<!-- Form -->
<form method="post">
<button type="submit" name="button">Show div</button>
</form>
<div class="myDiv">MyDiv text...</div>
<pre>
<?php
// Logics
// Button event listener
print_r($_POST);
if(isset($_POST['button'])) {
echo "You pressed the button!";
echo "<style> .myDiv {display:block} <style>";
}
?>
</body>
</html>
first check if is post request and do visibility with php variable:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
</head>
<body>
<?php
$display = 'none';
if(!empty($_POST)) {
if(array_key_exists('button', $_POST)) {
$display = 'block';
}
}
?>
<style>
.myDiv {display:<?php echo $display;?>;}
</style>
<!-- Styling -->
<!-- Form -->
<form method="post">
<button type="submit" name="button">Show div</button>
</form>
<div class="myDiv">MyDiv text...</div>
<pre>
<?php
print_r($_POST);
// Logics
// Button event listener
?>
</body>
</html>

How to delete data in the current page then redirecting to another page with a back button

My current page is displayitems.php. I got a button type='hidden' with a style and a background image of the button and a hidden input type='hidden .'
I can retrieve the id of the image when clicked. Whenever I click on the button (with image) it displays the the exact image of the button in another page which is userdetails.php and I got a back button that will redirect to displayitems.php.
Now my problem here is if I click another button (image) it display the past image instead of a new one can any of you delete the past image then display the current button that I click
This is my homepage
<?php
require 'header.php';
?>
<main>
<?php
require 'uploaditems.php';
echo "<br>";
require 'loginlogout.php';
echo "<div>";
require 'displayitems.php';
echo "</div>";
?>
</main>
My displayitems.php
<?php
if(isset($_SESSION['userId'])){
require "includes/dbh.php";
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="style.css" type="text/css" media="screen" href="style.php"/>
<script src="main.js"></script>
<style>
.product{
border:1px solid
margin:-1px 19px 3px -1px;
padding: 10px;
text-align:center;
bacgkround-color:#efefef;
}
</style>
</head>
<body>
<?php
include_once 'includes/dbh.php';
$sql="SELECT * FROM gallery ORDER BY orderitems DESC;";
$stmt=mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql)){
echo "sql statement failed in displayitems.php";
}else{
mysqli_stmt_execute($stmt);
$result=mysqli_stmt_get_result($stmt);
if(mysqli_num_rows($result)>0){
while($row=mysqli_fetch_assoc($result)){
?>
<div class="col-md-3">
<form method="POST" action="userdetails.php">
<input type="hidden" name="hiddenId" value=<?php echo $row['idGallery'];?>>
<div class="product" style="float: left;">
<button type="hidden" name='displaydetails'
style='background-
image:url(images/<?php echo $row['imgFullNameGallery'];?>
);width:150px; height:200px; margin:auto; background-size:100% 100%; b
ackground-repeat:no-repeat;>
</button>
</form>';
<br>
<br><br><h3><?php echo $row['nameitem']?></h3>
<h3><?php echo $row['price']?></h3>
<br>
</div>
</div>
<?php
}
}
}
}
?>
</body>
</html>
and my userdetails.php
<?php
session_start();
if(isset($_POST['displaydetails'])){
if(isset($_SESSION['userId'])){
This is how I got the hidden id of the image
$idofimg=$_POST['hiddenId'];
require 'includes/dbh.php';
And i've created a query where I want all the data of the hidden id
$sql="SELECT * FROM gallery WHERE idGallery=? ;";
$stmt=mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql)){
echo "sql statement failed in displayitems.php";
}else{
mysqli_stmt_bind_param($stmt,'i',$idofimg);
mysqli_stmt_execute($stmt);
$result=mysqli_stmt_get_result($stmt);
if(mysqli_num_rows($result)>0){
while($row=mysqli_fetch_assoc($result)){
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-
scale=1">
<link rel="stylesheet" type="text/css" media="screen"
href="main.css" />
<script src="main.js"></script>
</head>
<body>
<img src="images/<?php echo $row['imgFullNameGallery'];?>" style
=width:330px; height:300px; margin:auto; background-size:100% 100%;
background-repeat:no-repeat;>
<div>
<h3>Details</h3>
<table>
<tr>
<td>Condition:</td>
<td>ha</td>
</tr>
</div>
This is where I want to put my condition where I will delete all this current data and go back to index2.php and then when clicked another image button it will display the current image not the past image
<form action='index2.php' method='POST'>
<button type='submit'>BACK</button>
<?php
$count=1;
?>
</form>
<?php
}
}
}
} else{
echo "fail";
}}
?>
</body>
</html>
here in my displayitems.php my input type="hidden" name="hiddenId" value=> is only getting 1 value when the button type="hidden" name='displaydetails'> is not getting any value when clicked. So when I go to userdetails.php it only display 1 details because of the input type. so I should remove the input type in displayitems.php and just give the button a value so whenever it was click it will generate a new id and display also a new details.
just change this to displayitems.php
<input type="hidden" name="hiddenId" value=<?php echo $row['idGallery'];?>>
<div class="product" style="float: left;">
<button type="hidden" name='displaydetails'
style='background-
image:url(images/<?php echo $row['imgFullNameGallery'];?>
);width:150px; height:200px; margin:auto; background-size:100% 100%; b
ackground-repeat:no-repeat;>
</button>
to this
<div class="product" style="float: left;">
<button type="hidden" name='displaydetails' value=<?php echo
$row['idGallery'];?>
style='background-
image:url(images/<?php echo $row['imgFullNameGallery'];?>
);width:150px; height:200px; margin:auto; background-size:100% 100%; b
ackground-repeat:no-repeat;>
</button>
and to userdetails.php
if(isset($_POST['displaydetails'])){
if(isset($_SESSION['userId'])){
$idofimg=$_POST['hiddenId'];
to this
if(isset($_POST['displaydetails'])){
if(isset($_SESSION['userId'])){
$idofimg=$_POST['displaydetails'];

My code is working on local but doesnt work in server [duplicate]

This question already has answers here:
How do I get PHP errors to display?
(27 answers)
Closed 3 years ago.
i have 6 php pages, all work perfectly on pc and on host. except one, my search.php doesn't work on host (by the way it works on pc perfectly too). Somehow when i try to run search.php i don't even get error, only thing which i get is white screen. Here my codes ;
<?php
session_start();
if(!$_SESSION['auth'])
{
echo 'bu sayfaya erişim izniniz yok.';
header("Location: uyegirisi.html");
}
?>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>First try</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<style>
li
{
display: inline;
padding: 0px 20px 0px 20px;
}
ul
{
padding:10px;
background: rgba(0,0,0,0.5);
}
a
{
color: black;
font-size: 30px;
}
p
{
color: #0f0f0f;
font-size: 24px;
font-family: Helvetica;
}
.bor
{
font-size: 23px;
border:2px;
}
.hr
{
color : #0000F8;
size : 4;
}
</style>
</head>
<body>
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4" align="center">
<header>
<ul>
<li>Kayıt ekranı</li>
<li> Çıkış Yap</li>
</ul>
</header>
<form action="musteriarama.php" method="get">
<div class="hiza">
<label for="Arama"></label>
<input type="text" class="form-control" id="Arama" name="Arama">
</br>
</br>
<input class="but btn btn-primary btn-lg" type="submit" name="gonder" value="Müşteri Ara">
</div>
</form>
</div>
<div class="col-md-4"></div>
</div>
</body>
</html>
<?php
$db =new mysqli('localhost', 'root', '' , 'musteritakip');
if($db->connect_errno) die ('Bağlantı hatası:' . $db->connect_errno);
if(isset($_GET['gonder'])){
#Ekleme işlemi
$stmt = $db ->prepare("select * from musteri_bilgileri where (isim like ?)");
if($stmt === FALSE) die("Sorgu hatası". $db ->error);
$ara ='%'.$_GET['Arama'].'%';
$stmt->bind_param("s", $ara);
$stmt->execute();
$sonuc =$stmt->get_result();
if($sonuc -> num_rows <1) die("<p>"."bulunamadı");
while ($row = $sonuc->fetch_array())
{
echo '<div>';
echo '<p>'.$row['isim'];
echo '&nbsp&nbsp ';
echo $row['soyad'];
echo '&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp';
echo '<form action="detaylar.php" method="post">';
echo'<input type="hidden" value="'.$row['id'].'" name="gelenid">';
echo '<input type ="submit" value="Detaylar" style="margin-bottom:-35px;" name="detaylargonder"></input>';
echo '<hr width="100%" >';
echo '</form>';
echo '</br>';
echo '</br>';
echo '</div>';
}
}
?>
You must have missed something while you were uploading it. You haven't clearly described what's not working or about the error, we can only advice you.Follow below steps to solve your issue:
First add error_reporting(E_ALL); ini_set('display_errors', 'On'); at top of your script.
Check the browser's console log's, it will display relevant errors.
As you are getting blank page, please check your code, you might be getting 500 internal server error when you haven't code it correctly.
Check your syntax.
Check your application & DB configuration.

Dynamically generated "submit" buttons in PHP

First time posting here (so please be gentle, as I am a relative PHP newbie).
I am building an intranet for our company and one of the things I need to do is to create a form that lists all outstanding sales orders (pulled from our accounting database) and provides a "submit" button beside each one to create the relevant work order.
Here is the code:
<div class="report_column">
<div class="report_header">
<div class="report_column_title" style="width:150px;margin-left:5px">ship date</div>
<div class="report_column_title" style="width:200px">customer</div>
<div class="report_column_title" style="width:140px;text-align:right">item</div>
<div class="report_column_title" style="width:120px;text-align:right">quantity</div>
</div>
<?php
// Open connection
include 'includes/dbconnect.php';
// Perform query
$result = mysqli_query($con,"SELECT * FROM tSalOrdr ORDER BY dtShipDate ASC");
// Retrieve results
while($row = mysqli_fetch_array($result)) {
$order = $row['lId'];
if ($row['bCleared'] == 0) {
$shipdate = substr($row['dtShipDate'], 0,10);
$customer = $row['sName'];
$po = $row['sComment'];
echo '<div class="report_item" style="width:750px";>';
echo '<form class="form" action="index.php?page=form&item=create_work_order" method="POST">';
echo '<div class="report_item_date" style="width:120px">'.$shipdate.'</div>';
echo '<div class="report_item_name" style="width:530px">'.$customer;
echo '<input type="hidden" name="po" value="'.$po.'" />';
echo '<input type="submit" class="submit" style="height: 25px;width:100px;margin:0px;padding:0px;margin:0px" value="work order"/>';
echo '</div>';
$result2 = mysqli_query($con,"SELECT * FROM tSOLine WHERE lSOId=$order ORDER BY sDesc ASC");
while($row = mysqli_fetch_array($result2)) {
if ($row['dRemaining'] <> 0) {
echo '<div class="report_item_details">';
echo '<div class="report_item_item">'.$row['sDesc'].'</div>';
echo '<div class="report_item_quantity">'.$row['dRemaining'].'</div>';
echo '</div>';
}
}
echo '</form>';
echo '</div>';
}
}
// Close connection
mysqli_close($con);
?>
</div>
What happens when I do this is that the first "submit" button will, for some reason, send me back to "index.php". The other buttons will load the correct page, however, they do not POST the required value.
Is there something I am doing wrong or is this something that needs different methodology than what I am currently using? My research on this seems to indicate that perhaps I should use javascript or an array to deal with this, but, having never dealt with either, I am not sure how to proceed. Any pointers would be appreciated.
Thanks.
#maniteja: The index.php is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<title></title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<link href="css/forms.css" rel="stylesheet" type="text/css" />
<link rel="icon" type="image/ico" href="favicon.ico" />
<script type="text/javascript" src="scripts/jquery-2.1.0.min.js" ></script>
<script type="text/javascript" src="scripts/tabcontent.js" ></script>
</head>
<body>
<!-- BEGIN MAIN CONTENT -->
<div id="wrapper">
<!-- BEGIN HEADER -->
<div id="header">
<img src="images/logo.jpg">
</div>
<!-- END HEADER -->
<!-- BEGIN MAIN MENU -->
<div id="leftcolumn">
<?php include 'includes/menu.php'; ?>
</div>
<!-- END MAIN MENU -->
<!-- BEGIN CONTENT FRAME -->
<div id="rightcolumn">
<div id="content_area">
<?php
if (isset($_GET['page']))
{$page = $_GET['page'];
include('pages/' . $page . '.php');}
else {include('pages/home.php');}
?>
</div>
</div>
<!-- END MAIN CONTENT -->
</body>
</html>
I've made seventeen other forms with it, so I don't think that it is the problem. I'm hoping that this is just a typo or a logic error on my part.
u can use
<button type='submit' class='' name='' onclick=''>Submit</button>
Try to do onclick. See my example below.
input type="button" name="submit" onclick='location.href="index.php?id=$id"'
AS far as I understand, you are making your forms go to index.php:
echo '<form class="form" action="index.php?page=form&item=create_work_order" method="POST">';
Can you explain what is your expected behavior when a button is pushed?

PHP not running in iFrame

Hi I am trying to make a personal code playground... I am using Code Mirror to turn into looking like an IDE (I also plan to add features of an IDE later but...). My current code is basically..
HTML (index.html)
<html>
<head>
<link href="main.css" rel="stylesheet" type="text/css" />
<script src="http://codemirror.net/lib/codemirror.js"></script>
<link href="http://codemirror.net/lib/codemirror.css" rel="stylesheet" />
<script src="http://codemirror.net/mode/htmlmixed/htmlmixed.js"></script>
<script src="http://codemirror.net/mode/css/css.js"></script>
<script src="http://codemirror.net/mode/javascript/javascript.js"></script>
</head>
<body>
<div class="codewindow">
<form id="codePush" action="codePush.php" method="POST" target="codeResults">
<textarea id="htmlWindow"></textarea>
<textarea id="cssWindow"></textarea>
<textarea id="jsWindow"></textarea>
<input type="submit" />
</form>
<script class="code">
var htmlCodeMirror = CodeMirror(function(elt) {
htmlWindow.parentNode.replaceChild(elt, htmlWindow);
}, {value: "<!-- HTML goes here -->",
lineNumbers: true,
mode: "text"});
</script>
<script class="code">
var cssCodeMirror = CodeMirror(function(elt) {
cssWindow.parentNode.replaceChild(elt, cssWindow);
}, {value: "/* CSS goes here. */",
lineNumbers: true,
mode: "css"});
</script>
<script class="code">
var jsCodeMirror = CodeMirror(function(elt) {
jsWindow.parentNode.replaceChild(elt, jsWindow);
}, {value: "// JavaScript goes here.",
lineNumbers: true,
mode: "javascript"});
</script>
</div>
<div class="output">
<iframe id="codeResults" name="codeResults" target="codePush.php" width="100%" height="100%" frameBorder="0.5" scrolling="yes"></iframe>
</div>
</body>
PHP (codePush.php)
<!DOCTYPE html>
<html>
<head>
<style>
<?php
echo $_GET['cssWindow'];
?>
</style>
<script type="text/javascript">
<?php
echo $_GET['jsWindow'];
?>
</script>
</head>
<body>
<?php
echo $_GET['htmlWindow'];
?>
</body>
</html>
I have made sure the link to the iFrame works because when adding text to the PHP file in the body section it displays when submit is pressed.
I hope I have made it clear and would appreciate any help...
Just for reference I am a bit of a NOoB when it comes to PHP
I'm not entriely sure what you're trying to achieve with all the code you provided, but here's a simplified version that will fix the main issue of the code not processing in codePush.php:
<div class="codewindow">
<form id="codePush" action="codePush.php" method="POST" target="codeResults">
HTML:<textarea id="htmlWindow" name="htmlWindow"></textarea>
CSS:<textarea id="cssWindow" name="cssWindow"></textarea>
JS:<textarea id="jsWindow" name="jsWindow"></textarea>
<input type="submit" />
</form>
</div>
<div class="output">
<iframe id="codeResults" name="codeResults" target="codePush.php" width="100%" height="100%" frameBorder="0.5" scrolling="yes"></iframe>
</div>
CodePush.php
<!DOCTYPE html>
<html>
<head>
<style>
<?php
echo $_POST['cssWindow'];
?>
</style>
<script type="text/javascript">
<?php
echo $_POST['jsWindow'];
?>
</script>
</head>
<body>
<?php
echo $_POST['htmlWindow'];
?>
</body>
</html>
Note that CodePush.php uses 'POST' not 'GET' so that it is consistent with your form. You were also missing 'name' attributes on the textareas which is what is used in the post (not the ids).
You might want to consider adding in some checks if the fields aren't complete to avoid errors etc.

Categories