Embarcadero RadPHP XE2 - php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" DIR=ltr >
<head>
<title>MPage1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="viewport" content="width=320,user-scalable=yes,initial-scale=1, minimum-scale=1, maximum-scale=1">
<script src="/rpcl-bin/jquerymobile/js/base64.js"></script>
<script src="/rpcl-bin/jquerymobile/js/jquery-1.6.1.min.js"></script>
<script src="/rpcl-bin/jquerymobile/js/functions.js"></script>
<script>
jQuery(document).bind('mobileinit', function(){
jQuery.noConflict();
jQuery.extend(jQuery.mobile , {
loadingMessage: 'Loading',
pageLoadErrorMessage: 'Error Loading Page',
autoInitialize: true,
defaultTransition: 'slide'
});
});</script>
<script src="/rpcl-bin/jquerymobile/js/jquery.mobile-1.0b1.js"></script>
<link rel="stylesheet" href="/rpcl-bin/jquerymobile/css/jquery.general.css" />
</head>
<body style=" margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; " >
<div data-role="page" id="MPage1_page" >
<link rel="stylesheet" href="/unit1.php?header_file=css" />
<script src="/unit1.php?header_file=js"></script>
<form style="margin-bottom: 0" id="MPage1" name="MPage1" method="post" target="_self" action="/unit1.php"><input type="hidden" name="serverevent" value=""><input type="hidden" name="serverparams" value="">
<table width="320" style="height:480px" border="0" cellpadding="0" cellspacing="0" ><tr><td valign="top">
<div id="ComboBox1_outer" style="Z-INDEX: 0; LEFT: 66px; WIDTH: 185px; POSITION: absolute; TOP: 82px; HEIGHT: 18px">
<select name="ComboBox1" id="ComboBox1" size="1" style=" font-family: ; font-size: ; cursor: default;height:16px;width:185px;" tabindex="0" > <option value="0" >value0</option>
<option value="1" selected="selected" >value1</option>
</select>
</div>
</td></tr></table>
</form></div>
</body>
</html>
<!-- MPage1 end -->
I've installed RadPHP XE2 on Windows 7 machine.
I've created a new mobile application and added a combobox to the form. I added 2 items (value0, value1) to the combobox and set the item index to 0.
When I run the application this the selected value is displayed above the combobox. This happens in IE and Chrome (latest version) How do I remove this?
EDIT: I've attached the downloaded HTML. Strange. When I save it to a .html file and open it in a browser, the page displays correctly, but running it from the IDE, it doesn't

Related

Contenteditable div height limit

Hey guys I have problems with contenteditable height. With code like this:
function Preview() {
var x = document.getElementById("code").value;
document.getElementById("preview").innerHTML = x;
}
.preview{
text-align: left;
color: white;
margin-left: 10px;
max-height: 300px;
overflow: auto;
}
<section id="main">
<div id="gra">
<input type="hidden" id="current-code" name="current-code" />
<textarea id="code" name="code">
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>A Simple PHP File</title>
</head>
<body>
<h1><?php echo "Hello, world!"; ?></h1>
</body>
</html>
</textarea>
<div class="flex">
Preview
Reset
</div>
</div>
<div id="gra">
<div contenteditable="true" class="preview" id="preview">
</div>
</div>
</section>
When I enter code with more I can observe effect like this:
Anyone can help me with limit contenteditable height?
try this code
and also change color: red; instead of color:white because its not see anything on white screen
function Preview() {
var x = document.getElementById("code").value;
document.getElementById("preview").innerHTML = x;
}
function Reset() {
document.getElementById("preview").innerHTML = "";
}
.preview {
text-align: left;
color: red;
margin-left: 10px;
max-height: 300px;
overflow-y: scroll;
border: solid 1px #ddd;
}
<section id="main">
<div id="gra">
<input type="hidden" id="current-code" name="current-code" />
<textarea id="code" name="code">
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>A Simple PHP File</title>
</head>
<body>
<h1><?php echo "Hello, world!"; ?>you write php code hear so it will not print on html</h1>
</body>
</html>
</textarea>
<div class="flex">
Preview
Reset
</div>
</div>
<div id="gra">
<div contenteditable="true" class="preview" id="preview">
</div>
</div>
</section>

How can I get PHP INCLUDE working?

below is my code for php include. I guess I'm inputting the right code, but it just don't seem to abide:
Here is my headertop.php:
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>HOME</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="description" content="Slide Down Box Menu with jQuery and CSS3" />
<meta name="keywords" content="jquery, css3, sliding, box, menu, cube, navigation,
portfolio, thumbnails"/>
<link rel="shortcut icon" href="images/art_favicon.png" type="image/x-
icon"/>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen"/>
</head>
<header>
<?php
<div id="headertop">
<div id="adams">
<p><span style="color: #F60;">A</span>ncajas <span style="color:
#F60;">D</span>igital <span style="color: #F60;">A</span>rts & <span style="color:
#F60;">M</span>edia <span style="color: #F60;">S</span>olutions</p>
</div>
</div>
?>
</header>
</head>
</html>'
And here is my index.php:
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>HOME</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="description" content="Slide Down Box Menu with jQuery and CSS3" />
<meta name="keywords" content="jquery, css3, sliding, box, menu, cube, navigation,
portfolio, thumbnails"/>
<link rel="shortcut icon" href="images/art_favicon.png" type="image/x-
icon"/>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen"/>
<style>
body{
background-image: url(images/graphy.png);
font-family:Arial, Helvetica, sans-serif;
margin: 0;
padding: 0;
}
</style>
</head>
<header>
<?php
include ('headertop.php');
?>
</header>
<body>
<div id="contents">
</div>
</body>
</html>'
And of course my CSS for the header part:
'#headertop{
width: 1050px;
height: auto;
background-color: #252525;
margin-left: auto;
margin-right: auto;
position: inherit;
border-top: solid #F60 2px;
margin-bottom: 0px;
/*border-bottom: solid #F60 1px;*/
}
#adams{
font-family:"Trajan Pro";
font-weight: 100;
font-size: 24px;
text-align: center;
color: #CCC;
padding-bottom: 6px;
margin-bottom: 17px;
}
header{
width: 1050px;
height: 300px;
/*background-image:url(../interactive/product_slideshow.swf);*/
/*background-color: #999;*/
margin-left: auto;
margin-right: auto;
}'
Thank you guys for the support.
This should be throwing somewhere an error:
<?php
<div id="headertop">
It is within your headertop.php. Furthermore, I recommend you to turn errors on while coding so this doesn't happen again.
You don't need to set up the full html in the file you're including, only the bit you want to include. Try changing headertop.php to this:
<div id="headertop">
<div id="adams">
<p>
<span style="color: #F60;">A</span>ncajas
<span style="color: #F60;">D</span>igital
<span style="color: #F60;">A</span>rts &
<span style="color: #F60;">M</span>edia
<span style="color: #F60;">S</span>olutions
</p>
</div>
</div>

Page layout issues with PHP , HTML, and CSS

For some reason my CSS is not formatting my div tags into the correct spots on the page. It works on all my other pages but this one has a lot more PHP in it than normal and I am wondering if that is the problem.
Page
<!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">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
require("protect/serverInfo.php");
$myusername=$_POST[Email];
$mypassword=$_POST[Password];
$result = mysql_query("SELECT * FROM Customers WHERE Email='$myusername' AND Password=$mypassword");
$count=mysql_num_rows($result);
if($count==1){
while($row = mysql_fetch_array($result)){
?>
<div class="wrapper">
<div class="customerHead">';
<h1>
<?php echo $row['Customer'] ?>
</h1>
</div>
<div class="customerInfoMain">
Company: <?php echo $row['Company'] ?><br />
State: <?php echo $row['State'] ?>
</div>
<div class="customerCards">';
<img src="<?php echo $row['imagePathFront'] ?>" width="400px" height="303px" align="center" alt="" />
<img src="<?php echo $row['imagePathBack'] ?>" width="400px" height="303px" align="center" alt="" />
</div>
<div class="customerComments">';
<h5>Changes Made:</h5><br /> <?php echo $row['Comments'] ?>
</div>
</div>
<?php
}
}
else {
echo "Wrong Username or Password";
}
?>
</body>
</html
>
CSS
.customerCards{
top: 150px;
position: relative;
width: 425px;
border: 3px;
border-style:solid;
border-color: black;
background-color: silver;
z-index:1;
}
.customerInfoMain{
top: 200px;
position: relative;
width: 200px;
left: 520px;
border: 3px;
border-style:solid;
border-color: black;
background-color: silver;
z-index:2;
}
.customerComments{
position: relative;
width: 200px;
left: 580px;
border: 3px;
border-style:solid;
border-color: black;
background-color: silver;
z-index:2;
}
.wrapper{
position: absolute;
left: 50%;
width: 900px;
margin-left: -475px;
}
Source after page load
<!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">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
Wrong Username or Password
</body>
</html>
its because your wrapper just starting if there is user..
But what happend if you put your wrapper around the PHP, like:
<!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">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="wrapper">
<?php
require("protect/serverInfo.php");
$myusername=$_POST[Email];
$mypassword=$_POST[Password];
$result = mysql_query("SELECT * FROM Customers WHERE Email='$myusername' AND Password=$mypassword");
$count=mysql_num_rows($result);
if($count==1){
while($row = mysql_fetch_array($result)){
?>
<div class="customerHead">';
<h1>
<?php echo $row['Customer'] ?>
</h1>
</div>
<div class="customerInfoMain">
Company: <?php echo $row['Company'] ?><br />
State: <?php echo $row['State'] ?>
</div>
<div class="customerCards">';
<img src="<?php echo $row['imagePathFront'] ?>" width="400px" height="303px" align="center" alt="" />
<img src="<?php echo $row['imagePathBack'] ?>" width="400px" height="303px" align="center" alt="" />
</div>
<div class="customerComments">';
<h5>Changes Made:</h5><br /> <?php echo $row['Comments'] ?>
</div>
<?php
}
}
else {
echo "Wrong Username or Password";
}
?>
</div>
</body>
</html>
"Then you should have a little bit of the CSS action?"
Split the code by purpose functionality and calculations are not meant to be in the same place, html should be rendered last. Keeping on working like this will bring you a lot of trouble. Things should be done like this:
loginProcess.php contains:
if(isset($_SESSION["user"]) {
$row = $_SESSION["user"];
}
include("loginPage.php");
?>
and this is longinPage.php (you can include either of them in which on you want). Either include loginPage.php at the end of loginProcess.php or include loginProcess.php at the begining of loginPage.php
so loginPage.php contains
< !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">
< head>
< meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
< title>Untitled 1
< link href="stylesheet.css" rel="stylesheet" type="text/css" />
< /head>
< body>
if(isset($_SESSION['user'])) {
< div class="wrapper">
< div class="customerHead">';
<h1><!---you know the row from before---/>
<?php echo $row['Customer'] ?>
</h1>
</div>
<div class="customerInfoMain">
Company: <?php echo $row['Company'] ?><br />
State: <?php echo $row['State'] ?>
</div>
<div class="customerCards">';
<img src="<?php echo $row['imagePathFront'] ?>" width="400px" height="303px" align="center" alt="" />
< a href ="something/<?php echo $row['imagePathBack'] ?>" target="_blank">
< img src="" width="400px" height="303px" align="center" alt="" />
</div>
<div class="customerComments">';
<h5>Changes Made:</h5><br /> <?php echo $row['Comments'] ?>
</div>
</div>
<?php
}
}
else {?>
<form action="/loginProcess.php" (or loginPage.php if loginPage includes the loginProcess) method="POST">
<input type="text" name="Email" value=""/>
<input type="password" name="Password" value=""/>
<input type="submit" value="login"/>
</form>
<?php}?>
?>
first the login form will be shown and the user will input his credentials, those credentials will be checked and if they are ok the SESSION['user'] is set (remeber you need a session start for that) now as long as the session persists you will not need to request for login all the time. Anyway, if you do not want for some reason to fully separate Database Concerns/Process Concerns/Viewing Concerns, at leas you must separate the Process from the Viewing(Keeping Database concerns in the processing area). Checkout some frameworks online or try to find a way to write code with a little more care, otherwise you will keep on having useless problems that waste your time.

Form upload issue

I'm trying to implement this method of making a nice form upload:
www.kavoir.com/2009/02/styling-file-upload-select-input-control-input-typefile.html/
which is amazing and simple, but my only issue is that every time I select a file it's showing up as "C:\fakepath\filename". I'm on a mac and I cannot for the life of me figure out where this is coming from! Here's my code:
<?php
error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', '1');
if ($_POST['submit'] == "Submit") {
$temp_file = $_FILES['upload']['tmp_name']."/".$_FILES['upload']['name'];
$target_file = getcwd()."/uploads/".$_FILES['upload']['name'];
// if (!move_uploaded_file($temp_file,$target_file)) {
//
// }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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"/>
<title>untitled</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<style>
.upload {
position:relative;
width:250px;
height:135px;
border:1px solid #666;
padding:10px;
background:#DDD;
}
.loading {
background:rgba(50,50,50,0.8);
position:absolute;
top:0;
left:0;
width:250px;
height:135px;
}
.realupload {
position:absolute;
bottom:0;
right:0;
/* start of transparency styles */
opacity:0;
-moz-opacity:0;
filter:alpha(opacity:0);
/* end of transparency styles */
z-index:2; /* bring the real upload interactivity up front */
width:200px;
}
form .fakeupload {
/* background:url(uploadify/select.png) no-repeat 100% 50%;
*/ }
form .fakeupload input {
width:238px;
font-family:Arial,sans-serif;
padding:5px;
border:1px solid #666;
background:#FFF;
outline:none;
}
label {
width:120px;
height:30px;
}
label img {
cursor:pointer;
}
.upload a.cancel {
position:absolute;
top:10px;
right:10px;
}
</style>
</head>
<body>
<div class="upload">
<form name="file" method="post" action="test.php" enctype="multipart/form-data">
<label for="realupload"><img src="uploadify/select.png" /></label>
<div class="fakeupload">
<input type="text" name="fakeupload" /> <!-- browse button is here as background -->
</div>
<input type="file" name="upload" id="realupload" class="realupload" onchange="this.form.fakeupload.value = this.value;" />
<input id="submit" type="submit" name="submit" value="Submit" />
</form>
<a class="cancel" href="test.php"><img src="uploadify/cancel.png" /></a>
<div class="loading"></div>
</div>
<script>
$(document).ready( function() {
$('div.loading').fadeOut(0);
});
$('form input.submit').click( function() {
$('div.loading').fadeIn(400);
});
</script>
</body>
</html>
That's on the browser's security level. I've encountered this on Windows (IE), but surprisingly you're on a Mac. Try other browsers or change the security options of your current browser. Make it not too conservative.
Also, try using other site's upload forms.

Unable to execute a php script through CURL

I have a PHP script A which displays data from database.
I have another another script B which gets the content of script A .But I need the content after script A is executed . But this is not happending .
// Script A
enter code here
<?php
session_start();
if(!isset($_SESSION['username']))
{
print "You have not logged in";
header('Location: index.htm');
}
session_write_close();
?>
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv
="content-language" content="cs" />
<meta name="robots" content="all,follow" />
<meta name="author" content="All: ... [Nazev webu - www.url.cz]; e-mail: info#url.cz" />
<meta name="copyright" content="Design/Code: Vit Dlouhy [Nuvio - www.nuvio.cz]; e-mail: vit.dlouhy#nuvio.cz" />
<title>WAVES 1.0!</title>
<meta name="description" content="..." />
<meta name="keywords" content="..." />
<link rel="index" href="./" title="Home" />
<link rel="stylesheet" media="screen,projection" type="text/css" href="./css/main.css" />
<link rel="stylesheet" media="print" type="text/css" href="./css/print.css" />
<link rel="stylesheet" media="aural" type="text/css" href="./css/aural.css" />
<script type="text/javascript" src="js/jquery-1.2.6.pack.js"></script>
<script language="javascript" type="text/javascript">
function getQueryParams( val )
{
//Use the window.location.search if we don't have a val.
var query = val || window.location.search;
query = query.split('?')[1]
var pairs = query.split('&');
var retval = {};
var check = [];
for( var i = 0; i < pairs.length; i++ )
{
check = pairs[i].split('=');
retval[check[0]] = check[1];
}
return retval;
}
var values = getQueryParams();
var v = values['id'];
$(function()
{
$.getJSON("getviewresults.php?id="+v, function(data)
{
$.each(data, function(entryIndex, entry)
{
var name = entry['tid'];
var user = entry['status'];
var p= entry['description'];
var f = entry['time'];
var stime = entry['stime'];
$('<tr> <td>'+name+'</td> <td > '+p+'</td> <td> '+user+'</td> <td>'+f+'</td> <td> Log </td> <td>Device Log </td><td> LAN </td> </tr> ').appendTo('#container');
});
});
});
</script>
</head>
<body>
<!-- Main -->
<div id="main" class="box">
<!-- Header -->
<div id="header" style="left: 0px; width: 100%; top: 1px; height: 61px">
<!-- Logotyp -->
<h1 id="logo" style="left: 46px; top: 19px">WAVES 1.0!<strong>!</strong><span></span></h1>
<hr class="noscreen" />
<img src="Design/logo.jpg" style="right:0px; width: 134px; position: absolute;
top: -2px; height: 61px" />
</div> <!-- /header -->
<!-- Main menu (tabs) -->
<div id="tabs" class="noprint" style="width:100%; left: 0px; position: relative; top: 0px; height:24px">
<h3 class="noscreen">Navigation</h3>
<ul class="box">
<li>Home<span class="tab-l"></span><span class="tab-r"></span></li>
<li>Package<span class="tab-l"></span><span class="tab-r"></span></li>
<li >Configs<span class="tab-l"></span><span class="tab-r"></span></li>
<li>Live<span class="tab-l"></span><span class="tab-r"></span></li>
<li id="active">Results<span class="tab-l"></span><span class="tab-r"></span></li>
<li>Log out<span class="tab-l"></span><span class="tab-r"></span></li>
</ul>
<hr class="noscreen" />
</div> <!-- /tabs -->
<!-- Page (2 columns) -->
<!-- /page -->
<div style="border-right: #336699 thin solid; border-top: #336699 thin solid; left: 0px;
border-left: #336699 thin solid; width: 100%; border-bottom: #336699 thin solid;
position: relative; top: 0px; height: 480px; overflow:auto">
<table id="container" style="left: 0px; width:100%; position: relative; ">
<tr>
<td style="width: 100px">
<strong>Testid</strong></td>
<td style="width: 382px">
<strong>Description</strong></td>
<td style="width: 100px">
<strong>Status</strong></td>
<td style="width: 100px">
<strong>Time Taken</strong></td>
<td style="width: 100px">
<strong>Log </strong></td>
<td style="width: 100px">
<strong>Device Log </strong></td>
<td style="width: 100px">
<strong>LAN </strong></td>
</tr>
</table>
</div>
</div>
<!-- Footer -->
<!-- /footer -->
<!-- /main -->
</body>
</html>
// Script B
$ch = curl_init();
$url = "http://localhost/waves/viewresults.htm?id=".$id;
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
chdir("temp/file");
$myFile = "summary.htm";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $data);
fclose($fh);
The file summary.htm just has the code of the script A , which means it has not executed nnd hence has not data from the database .
What am I doing wrong ?
So I started to answer without reading your code but now see that you are using JavaScript to output the data from Script A instead of using PHP.
Why it wont work: You are dynamically creating a table at run time using client side JavaScript. This will render properly in a browser but will not render via curl. libcurl does not support javascript.
Suggested Solution
I would suggest that you modify getviewresults.php and follow this tutorial to buffer the output to a file or you could also optionally just rewrite Script A to use a server side script.
This was a really entertaining problem thank you.
Try renaming "viewresults.htm" to "viewresults.php" so it's parsed as PHP (you could use mod_rewrite to internally redirect viewresults.htm to viewresults.php so your URLs don't change).
Open the URL you're trying to get in your browser - i.e. http://localhost/waves/viewresults.htm?id=X (with correct value of X) - and see what content is output.
If you still see PHP code displayed in your browser then you know that the file is not being parsed as PHP. By default only filenames with .php on the end will be executed as PHP.
Also, I don't think the code in Script A is going to be executed properly anyway because the session variables won't be set.

Categories