I know that there are many similar questions and solutions available everywhere for this situation. Apology for the repetition, let me describe my pain:
All efforts to give permission to python script for php based web access goes in vain. No any kind of permission works in my situation:
<html>
<head>
<?php
if (isset($_POST['CronON']))
{
exec("sudo python /var/www/cron_on.py");
}
if (isset($_POST['CronOFF']))
{
exec("sudo python /var/www/cron_off.py");
}
?>
<title></title>
</head>
<body>
<form method="post">
<table
style="width: 75%; text-align: left; margin-left: auto; margin-right: auto;"
border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="text-align: center;">CRON ON</td>
<td style="text-align: center;">CRON OFF</td>
</tr>
<tr>
<td style="text-align: center;"><button name="CronON">ON</button></td>
<td style="text-align: center;"><button name="CronOFF">OFF</button></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
Pressing the button doesn't product any output, no change at all. This question is a follow-up from my previous question: How to tell python not to interpret hash symbol as comment?
Related
I found a strange behaviour in my css style. I created a login page that can be accessed from a link wihtin home page. If I access login page from a link within home page or login page itself, everything looks fine. But, whenever I refresh login page, the header looks weird. And all of this happen only if <form> element is exists, without <form> element, there's no problem.
So, what causes this to happen? And how do I fix this?
Note: Everything after this is only attachment for my question details.
The login file page written like this:
<?php require_once($_SERVER['DOCUMENT_ROOT'].'/config/core.php'); ?>
<html>
<?php include_once($root.'/includes/head.php');?>
<body>
<div id="wrapper">
<?php include_once($root.'/includes/header.php');?>
<?php include_once($root.'/includes/navigation.php');?>
<section>
<article>
<h2>Login</h2>
<form action="<?php echo $current_file;?>" method="post">
<table align="center" border="0" cellpadding="0" cellspacing="15">
<tr>
<td width="100">Username</td>
<td>:</td>
<td><input type="text" name="username" maxlength="50" size="35"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input type="password" name="password" maxlength="50" size="35"></td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit" value=" Login "><input type="submit" value=" Reset "></td>
</tr>
</table>
</form>
</article>
</section>
<?php include_once($root.'/includes/news.php');?>
<?php include_once($root.'/includes/footer.php');?>
</div>
</body>
</html>
The header.php file that I included written like this:
<header>
<div id="logo">
<img src="/images/arh.png" />
<h1>The Header</h1>
</div>
</header>
And, the css file for header element is written like this:
header {
background-color: #000; height: 120px;
}
#logo {
float: left;
}
#logo img {
height: 100px; padding: 10px;
}
#logo h1 {
color: #ccc; float: right; font-size: 36px; padding: 30px;
}
The result if i access login.php page from link:
And, if i refresh the page:
i had pretty much that same problem. Matewka is right.
there was a small error in my html on my header. i had my div in the middle of my table.
What i had
<div>
<table>
<tr>
<td>
</td>
</tr>
</div>
</table>
what i changed it to
<div>
<table>
<tr>
<td>
</td>
</tr>
</table>
</div>
I just moved my div to the end of my table. I don't know how i did this, but being up for a few days or staring at the same thing over and over you start missing things. I would double check the html, it might be that simple. (are you using height % ?) do you have borders?
okay, so my head is going to explode right now, i'm searching 5 hours non stop for my problem..
i want the menu2.html which is inside a table, to appear on the end of the page, After the end of the Content!
i tried a lot, like:
1-position: absolute; bottom: 0;
2-position: absolute; left: 100px; top: 150px; etc etc...
But this is not what im looking for!
I could put the menu2 after the content only by editing the top:150 But there are a lot of pages with different contents, so the menu2 doesn't suit in the other pages!
I hope you can help me.
This Is My PHP file:
<style type="text/css">
.menu2 {
background-image: url('<?=$profpic;?>');
background-attachment:fixed;
background: yellow;
}
</style>
<title>Hello</title>
</head>
<body>
<table width="100%" height="58%" border="0" cellspacing="0" cellpadding="2" class="heading">
<tr>
<td>
<?php include('menu.html');?>
</td>
</tr>
<tr>
<td><img src="pictures/logo.png" width="1335" height="300"></td>
</tr>
</table>
<table width="85%" height="1%" border="1" cellspacing="0" cellpadding="2">
<tr>
<td>
<?php include('menu2.php');?>
</td>
</tr>
</table>
<?php
$profpic = "pictures/bg.jpg";
?>
</body>
</html>
It's not clear to me what you are trying to do here, but I'll take a shot at helping you. First of all, you can't have multiple <html>, <head>, and <body> tags on the same page. Only one set of these are allowed. Secondly, change the file type of menu2 to php instead of html if you want to include it there.
<style type="text/css">
.menu2 {
background-image: url('<?=$profpic;?>');
background-attachment:fixed;
position: absolute;
background: yellow;
}
</style>
<title>Hello</title>
</head>
<body>
<table width="100%" height="58%" border="0" cellspacing="0" cellpadding="2" class="heading">
<tr>
<td>
<?php include('menu.html');?>
</td>
</tr>
<tr>
<td><img src="pictures/logo.png" width="1335" height="300"></td>
</tr>
</table>
<table width="85%" height="1%" border="1" cellspacing="0" cellpadding="2">
<tr>
<td>
<?php include('menu2.php');?>
</td>
</tr>
</table>
<?php
$profpic = "pictures/bg.jpg";
?>
</body>
</html>
menu2.php
<div class="menu2">
//menu2 contents
</div>
I've been editing my MyBB portal.php, and up until recently it was displaying fine. I had added a custom welcome block above the recent posts, and it was displaying fine.
Today I went in to tidy up the code, adding new lines (enter) and indents to make the code more legible. Now, after doing this something went badly wrong. Instead of showing the full MyBB page styles, all it shows is the tags like {$header}. Here's the code:
<html>
<head>
<title>{$mybb->settings['bbname']}</title>
{$headerinclude}
</head>
<body>
{$header}
<table width="100%" cellspacing="0" cellpadding="{$theme['tablespace']}" border="0" align="center">
<tr><td valign="top" width="200">
{$welcome}
{$pms}
{$search}
{$stats}
{$whosonline}
{$latestthreads}
</td>
<td> </td>
<td valign="top">
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="trow1">
<span class="smalltext">
<!--Main Welcome Panel-->
<p style="text-align: center;">
<img alt="" src="http://axelcraft.net/images/welcome.png" style="width: 1024px;" /></p>
<p style="text-align: center;">
<span style="color:#696969;"><span style="font-size: 24px;"><em><span style="font-family: hutrmold;">Get ready for a whole new minecraft experience.</span></em></span></span></p>
<!--Slideshow-->
<center>
<iframe src="http://axelcraft.net/images/slides/slideshow.html" width="800" height="320" scrolling="no" frameBorder="0" style="overflow:hidden;"></iframe>
</center>
<!--End Slideshow-->
<p style="text-align: center;">
<span style="font-size:20px;">
<span style="font-family: 'trebuchet ms', helvetica, sans-serif;">
Thanks for visiting AxelCraft! Start by <span style="color:#385947;"><span style="">signing up</span></span> to get the latest news and updates on the server as well as to register for <span style="color:#385947;">contests</span> and <span style="color:#385947;">events</span>!
</span>
</span>
</p>
<!--End Welcome Panel-->
</span>
</td>
</tr>
</table>
<br />
{$announcements}
</td>
</tr>
</table>
{$footer}
</body>
</html>
Now, when you navigate to portal.php, it only shows the {$} tags along with the html paragraph. It's supposed to be showing sidebars and headers left and right like MyBB does. See what I mean here.
Compare that to the normal forum page here.
I can't figure out what's wrong or why it's not displaying properly.
I could be wrong but are you missing an '>' here
<tr><td
<table width="100%" cellspacing="0" cellpadding="{$theme['tablespace']}" border="0" align="center">
<tr><td valign="top" width="200">
Trying to create proper PDF document, using PHP and TCPDF.
Can you help me, how can I use writeHTML function to create and center table, in TCPDF?
Tryed with:
$html = '
<div style="margin-left: auto; margin-right: auto; width: 50%">
<table border="1" width="200" align="center"><tr><td><b>Invoice number: '.$this->xInvoiceNumber.'</b></td></tr></table>
<br />
<table border="1" width="200" align="center"><tr><td>'.$this->xClient.'</td></tr></table>
<br />
</div>
... but no luck.
You have to make a table with 3 columns, set the width for every one of them and in the middle one you have to create your table.
<table>
<tr>
<td style="width:25%"></td>
<td style="width:50%"><table><tr><td>Your content</td></tr></table></td>
<td style="width:25%"></td>
</tr>
</table>
I'm not proud of this method but it's working :)
Ok, so I don't know if there is solution for my problem...
However, I did manage to solve it by using writeHTMLCell funcion, ie.
$this->writeHTMLCell(50, 0, 50, 50, 'cellcontent', 'LRTB', 1, 0, true, 'L');
If somebody can find better solution, please reply.
Tnx!
Try this code; it worked for me:
<table style="width:100%">
<tr>
<td style="width:30%">left margin</td>
<td style="width:40%">
<table border="1" style="width:100%">
<thead>
<tr>
<td style="width:100%" colspan="2"></td>
</tr>
<tr>
<td style="width:40%"><b></b></td>
<td style="width:60%"><b></b></td>
</tr>
</thead>
</table>
</td>
<td style="width:30%">rigth margin</td>
</tr>
</table>
Try replacing your opening div tag with this...
<div style="margin:5px auto; width:50%">
Never done anything like this however, this is the code you would need to center a table that is the cross browser compatible
<div style="text:align:center;">
<table style="margin:0px auto" border="1" width="200" align="center">
<tr>
<td><b>Invoice number: </b></td>
</tr>
</table>
<br />
<table style="margin:0px auto"border="1" width="200" align="center">
<tr>
<td>Client</td>
</tr>
</table>
<br />
</div>
If pdfs support css i would advise styling the html elements using css
table{
border:1px solid black;
margin:0px auto;
text-align:center;
width:200px;
}
Hope this helps!
I'm trying to delete a record in mysql using php. What do I have to add in my code so that there will be a delete confirmation first. Because in my current code, it automatically deletes the record corresponding to the pnum inputted.
<html>
<style>
input { font-size: 16px;}
</style>
<?php include('header.php'); ?>
<div id="main_content">
</div>
<?php include('footer.php'); ?>
<head>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form action="DeletebyPnumIn.php" method="post">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="9" style="background:#9ACD32; color:white; border:white 1px solid; text-align: center"><strong><font size="3">Delete In-patient</strong></td>
</tr>
<td><font size="3">Patient #:</td>
<td></td>
<td><input type="text" name="pnum" value="" maxlength="15" /><br/></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Delete" /></td>
</form>
</tr>
</table>
<body>
</body>
</html>
Here is the form action:
<html>
<style>
input { font-size: 16px;}
</style>
<?php include('header.php'); ?>
<div id="main_content">
</div>
<?php include('footer.php'); ?>
<head>
<?php
$con = mysql_connect("localhost","root","nitoryolai123$%^");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("hospital", $con);
mysql_query("DELETE FROM t2 WHERE PNUM='{$_POST["pnum"]}'") ;
mysql_close($con);
echo "<script>alert('Record successfully deleted!')</script>";
?>
Please help.
There are numerous ways to provide delete confirmation, ranging from simple and haphazard to complex and robust. The simplest approach is probably a Javascript confirmation dialog. To implement this, you'll want to add the functionality on the page where they click "Delete", not on the PHP side.
For instance:
Delete
By the way, watch out for SQL injection. You need to sanitize your inputs before dropping POST or GET data into an SQL string.
The simplest way, given your current code would be just to add an onsubmit action to your form.
<form action="DeletebyPnumIn.php" method="post" onsubmit="return confirm('Really Delete?');">
or something similar.
A JavaScript Confirm box should do the trick!
http://www.tizag.com/javascriptT/javascriptconfirm.php
You could also do it in pure PHP using another page... but that's likely to annoy your users...
You could simply use onsubmit="return confirmationMessage()" for the <form>. Of course this only works if JavaScript is enabled. The confirmationMessage should ask the user whether to delete or not, and return true if so, false if not.