First of all, let me show you a bit of code:
index.php
<?php echo localize('New directory'); ?>
So, as you can see, I use new-directory-dialog.php as a dialog window. All works fine on local machine, using Wamp server on Win 7 x64. But on my web host server, every dialog page is displayed with ?> (or ?>) chars.
HTML tab in Firebug shows this output:
<html class="ui-mobile">
<head>
<base href="http://pantljika-online.info/link/new-directory-dialog.php">
</head>
<body class="ui-mobile-viewport ui-overlay-a">
?>
<title>Novi direktorij</title>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1" name="viewport">
I have no clue why is this happening.
Here is entire code for dialog page:
<?php
include('localize.php');
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo localize('New directory'); ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<div data-role="page" data-theme="<?php echo $_SESSION['data-theme']; ?>" >
<form action="index.php" method="post">
<fieldset>
<div data-role="header">
<h1><?php echo localize('New directory'); ?></h1>
</div>
<div data-role="content">
<label for="new-directory-name">
<?php echo localize('Name'); ?>:
</label>
<input type="text" id="new-directory-name" name="new-directory-name" />
</div>
<div data-role="footer">
<h4>
<button type="submit" name="submit" value="submit-value"><?php echo localize('Create'); ?></button>
</h4>
</div>
</fieldset>
</form>
</div>
</body>
</html>
OK, problem solved. I deleted PHP closing tag (?>) in one of the included php files and it stopped showing up on dialogs. Also I had to encode all php files from UTF8 to UTF8 without BOM. Otherwise jQuery puts head metatags and title tag inside body element...
Related
So all I want is to rotate my webcam using a servo moteur, so when I click one of the three buttons (which the program will execute a python script) I get no result! Please any help?
The Code:
<?php
if (isset($_POST['rotateright'])) {
shell_exec("python Rotateright.py");
}
elseif (isset($_POST['rotatedefault'])) {
shell_exec("python defaultpositon.py");
}
elseif (isset($_POST['rotateleft'])) {
shell_exec("python Rotateright.py");
}
?>
<html lang="fr">
<head>
<meta charset="utf-8">
<link href="camerasurveillance.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="container1">
<img class="home" src="home.png"/>
</div>
<div class="container">
<br><br><br>
<!--<img class="live" src="http://192.168.1.8:8082/?action=stream"
width="500" height="350" alt="Live Feed" title="Raspberry pi" />-->
<br>
<form method="POST">
<input class="Rotater" type="submit" name="rotateright" value="Rotation
à droite">
<input class="default" type="submit" name="rotatedefault"
value="Position initiale">
<button class="Rotatel" name="rotateleft">Rotation à gauche</button>
</from>
</div>
</div>
So I am using XAMPP but when I click on a link it redirects me to localhost/dashboard instead of the page I want. How can I fix this?
This is the code of the index page
<!DOCTYPE html>
<html>
<head>
<title>SG Weredi</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="loginpagina.js"></script>
</head>
<body>
<div class="header">
Your App Name
</div>
<div class="container-fluid">
<img class =" logo" src="http://www.weredi.nl/logo.png">
</div>
<?php if( !empty($user) ): ?>
<br />Welcome <?= $user['email']; ?>
<br /><br />You are successfully logged in!
<br /><br />
Logout?
<?php else: ?>
<h1>Please Login or Register</h1>
Login or
Register
<?php endif; ?>
</body>
</html>
The only link that is correct is Register.
You should do the same for login:
Login
instead of
Login.
The same solution is for link to home page of project:
<div class="header">
Your App Name
</div>
instead of
<div class="header">
Your App Name
</div>
because href="/" on your site redirects you to index.php in C:/xampp/htdocs which redirects to C:/xampp/htdocs/dashboard/ (localhost/dashboard).
Try Changing port number to new one and restart the apache server.
I changed port number from 8082 to 8084 and restarted the server. This worked for me.
I have recently setup a Fedora 20 VPS with LAMP. My PHP is working properly as you can see from output below:
http://talkoot.co.in/info.php
My problem is when I access page below, the php script is printed out instead of being executed. If one 'Views Source' then the entire code is visible.
http://talkoot.co.in/WebBackend/admin/login.php
Can someone help me out. Here is the code for login.php:
<?php
include 'init.php';
if(isset($_SESSION['admin'])){
header('Location: index.php');
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>Login - CPanel</title>
<link type="text/css" rel="stylesheet" href="libs/css/materialize.min.css" media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="libs/css/style.css" media="screen,projection"/>
</head>
<body>
<div class="container">
<div class="card publish-form-container">
<?php
if(isset($_POST['username'],$_POST['password'])){
$__USERS->adminLogin($_POST);
}
?>
<form class="col s12" method="POST" action="" >
<div class="input-field">
<input id="username-field" type="text" name="username">
<label for="username-field">Username...</label>
</div>
<div class="input-field">
<input id="password-field" type="password" name="password">
<label for="password-field">Password...</label>
</div>
<div>
<button class="btn waves-effect waves-light pull-right" type="submit">Login
<i class="mdi-content-send right"></i>
</button>
</div>
</form>
</div><!-- Post Card //-->
</div>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="libs/js/materialize.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.materialboxed').materialbox();
});
</script>
</body>
</html>
Your server is not enabled for Short Open Tag there are 2 scenarios
enable it from php.ini short_open_tag = On or using htaccess
Use <?php instead of <?
P.S: i have shared a link which can explain you why i presented 2 options
As I can see in your phpinfo page:
short_open_tag Off Off
that means the short open tag are now allowed
So, anything you put inside short tags <? ?> won't be parsed as PHP. You'd rather put it inside standard tags <?php ?> block.
So I am trying to access a certain webpage within my site.
In my index, I use a isset($_GET() parameter to access another page. My code for the index.php is as follows:
<!DOCTYPE html>
<html>
<head>
<?php require ("includes/database.php"); ?>
<title>Offstreams Admin Panel</title>
<link rel="stylesheet" type="text/css" href="styles/admin_body.css" />
<link rel="stylesheet" type="text/css" href="styles/admin_header.css" />
<link rel="stylesheet" type="text/css" href="styles/admin_footer.css" />
<link rel="stylesheet" type="text/css" href="styles/admin_postspace.css" />
</head>
<body>
<header>
<!--Header Info Here -->
</header>
<div class="wrapper">
<div class="sidebar">
<ul>
<li>Post New Band</li>
</ul>
</div>
<article>
<?php
if (isset($_GET['post_new_band'])){
require ("includes/post_new_band.php");
echo "Page accessed";
} else {
echo "Page not accessible.";
}
?>
</article>
</div>
</body>
</html>
I have it echo page not available when "index.php?page" doesn't exist. But when it does exist, such as "index.php?post_new_band" (code below) nothing is posted. The sever and database work, that is for sure. MySQL isn't the problem since I am trying to get the html to work.
Code for "post_new_band.php":
<!DOCTYPE html>
<html>
<head>
<!-- Head Info Goes Here -->
</head>
<body>
<h1>Insert New Band</h1>
<form action='index.php?post_new_band' method='post'>
<b>Insert New Band</b><input type='text' name='band_name' />
<b>Insert Band Origin</b><input type='text' name='band_origin' />
<input type='submit' name='insert_band' value='Add Band' />
</form>
<?php
if (isset($_POST['post_new_band'])){
$band_name = $_POST['band_name'];
if($band_name==''){
echo "<script>alert ('Please Insert Band Name')</script>";
echo "<script>window.open('index.php?post_new_band','_self')</script>"
} else {
$insert_band_name = "insert into Band (band_name) values ('$band_name')";
$run_band_name = mysql_query("$insert_band_name");
echo "<script>alert ('New Category Added')</script>";
echo "<script>window.open('index.php?post_new_band','_self')</script>"
}
}
?>
</body>
</html>
You can only use a request key once - so dont use $_GET['post_new_band'] and $_POST['post_new_band'] in the same request. Change one of the keys.
This is pretty stupid, but it actually turned out to be a syntax error involving semi-colons. *Slap to the face.
Hi i had an issue reported for my script (https://github.com/joshf/Indication/issues/6) about echo statements printing rather than excecuting
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Indication</title>
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="resources/bootstrap/css/bootstrap.css" type="text/css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 60px;
}
</style>
<link href="resources/bootstrap/css/bootstrap-responsive.css" type="text/css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<!-- Nav start -->
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="#">Indication</a>
</div>
</div>
</div>
<!-- Nav end -->
<!-- Content start -->
<div class="container">
<div class="page-header">
<h1><? echo WEBSITE; ?></h1>
</div>
<div class="alert alert-error"><h4 class="alert-heading">Error</h4><p>ID cannot be blank.</p><p><a class="btn btn-danger" href="javascript:history.go(-1)">Go Back</a></p></div></div></body></html>
Notice the echo WEBSITE
The PHP code is
die("<div class=\"alert alert-error\"><h4 class=\"alert-heading\">Error</h4><p>ID does not exist.</p><p><a class=\"btn btn-danger\" href=\"javascript:history.go(-1)\">Go Back</a></p></div></div></body></html>");
!
Is this a code issue or a configuration issue, im unable to reproduce it
This is probably because you are using php short tag <?..?>. Please avoid using them and switch to long one <?php....?>
Probably you have turned off short tags in the server.
It is not a good idea to use
<? /* something */ ?>
<?=echo $something;?>
Because in some servers short tags are disabled.
Try:
<?php echo WEBSITE; ?>