Redirecting to PHP file in Flask - php

I am running a localhost website using Flask and python. I have some php files that I want to run when the users click a button. Problem is that Flask isn't recognizing the PHP file as PHP code and the code is showing up as text on the webpage. It's showing the text of all the echo statements, but the words in those statements correspond to variable in the code that allow the user to login and logout of the website. What do I do?
Python Code:
#app.route('/example.php')
def phpexample():
return render_template('example.php')
This shows a html page with text resulting from the echo statements.
The PHP code (example.php):
<?php
require ('steamauth/steamauth.php');
?>
<html>
<head>
<title>Eliminate Phishers! Join Steap now</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<!--[if lte IE 8]><script src="css/ie/html5shiv.js"></script><![endif]-->
<script src="js/jquery.min.js"></script>
<script src="js/skel.min.js"></script>
<script src="js/init.js"></script>
<noscript>
<link rel="stylesheet" href="css/skel.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/style-wide.css" />
</noscript>
<!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]-->
</head>
<body>
<!-- Header -->
<div id="header">
<span class="logo icon fa-paper-plane-o"></span>
<h1>Welcome. This is Steap</h1>
<p>A website designed to help eliminate phishers
<br />
and hackers on Steam.</p>
</div>
<!-- Main -->
<div id="main">
<header class="major container small">
<h3>
<?php
if(!isset($_SESSION['steamid'])) {
echo "welcome guest! <br />\n please login ";
steamlogin(); //login button
} else {
include ('steamauth/userInfo.php');
$url = $steamprofile['profileurl'];
if ($steamprofile['personastate'] == 0) {
$state = '<span style="color:#616161";>(Offline)</span>';
$picture = '<span style="color:#616161";><img src="'.$steamprofile['avatarfull'].'" title = "" alt = ""></span>';
} else if ($steamprofile['personastate'] == 1) {
$state = '<span style="color:#006EFF";>(Online)</span>';
$picture = '<span style="border: 10px dotted #006EFF;"><img src="'.$steamprofile['avatarfull'].'" title = "" alt = ""></span>';
} else if ($steamprofile['personastate'] == 2) {
$state = '<span style="color:#006EFF";>(Busy)</span>';
$picture = '<span style="border-color:#006EFF border-style: solid";><img src="'.$steamprofile['avatarfull'].'" title = "" alt = ""></span>';
} else if ($steamprofile['personastate'] == 3) {
$state = '<span style="color:#006EFF";>(Away)</span>';
$picture = '<span style="border-color:#006EFF border-style: solid";><img src="'.$steamprofile['avatarfull'].'" title = "" alt = ""></span>';
} else if ($steamprofile['personastate'] == 4) {
$state = '<span style="color:#006EFF";>(Snooze)</span>';
$picture = '<span style="border-color:#006EFF border-style: solid";><img src="'.$steamprofile['avatarfull'].'" title = "" alt = ""></span>';
} else if ($steamprofile['personastate'] == 5) {
$state = '<span style="color:#006EFF";>(Looking to Trade)</span>';
$picture = '<span style="border-color:#006EFF border-style: solid";><img src="'.$steamprofile['avatarfull'].'" title = "" alt = ""></span>';
} else if ($steamprofile['personastate'] == 6) {
$state = '<span style="color:#006EFF";>(Looking to Play)</span>';
$picture = '<span style="border-color:#006EFF border-style: solid";><img src="'.$steamprofile['avatarfull'].'" title = "" alt = ""></span>';
}
//Protected content
echo "Welcome back" . "</br> </br>" . $picture ."</br>". $steamprofile['personaname'] . "</br>" .$state . "</br>". "Steam ID: ". $steamprofile['steamid'] . "</br>";
echo 'Steam Profile' . "</br> </br>" . "<form action=\"steamauth/logout.php\" method=\"post\"><input value=\"Logout\" type=\"submit\" /></form>"; // Display their avatar!
}
?>
</h3>
</header>
<footer class="major container small">
<ul class="actions">
<li>Get Phishers</li>
</ul>
</footer>
</div>
<!-- Footer -->
<div id="footer">
<div class="container small">
<header class="major last">
<h2>Questions or comments?</h2>
</header>
<p>Program not working? Not detecting the phishers properly? <br \> Send us a message. We'll be sure to back to you as soon as possible.</p>
<form method="post" action="#">
<div class="row collapse-at-2">
<div class="6u">
<input type="text" name="name" placeholder="Name" />
</div>
<div class="6u">
<input type="email" name="email" placeholder="Email" />
</div>
</div>
<div class="row">
<div class="12u">
<textarea name="message" placeholder="Message" rows="6"></textarea>
</div>
</div>
<div class="row">
<div class="12u">
<ul class="actions">
<li><input type="submit" value="Send Message" /></li>
</ul>
</div>
</div>
</form>
<ul class="icons">
<li><span class="label">Twitter</span></li>
<li><span class="label">Facebook</span></li>
<li><span class="label">Instagram</span></li>
<li><span class="label">Github</span></li>
<li><span class="label">Dribbble</span></li>
</ul>
<ul class="copyright">
<li>© Steap 2014 All rights reserved.</li><li>Design: HTML5 UP</li>
</ul>
</div>
</div>
</body>
</html>

Maybe you should run php server (such as Apache or another) on other port (such as 8080) and when you call any php file, make request from your flask server to php server. And result getting from php server show with flask server. I hope, you can find the way how to send request from flask to other server.

render_template() isn't support PHP.
You can use subprocess to run PHP script:
import subprocess as sp
#app.route('/example.php')
def phpexample():
out = sp.run(["php", "example.php"], stdout=sp.PIPE)
return out.stdout

Flask is not compatible with php. So it can't read php code.

Have you considered using JQuery Ajax?
Here's an example:
You have a file called get_name.php witch contains:
<?php echo "Hello, my name is John"; ?>
Using Jquery ajax function I call the get_name.php
$.ajax({
url : 'get_name.php',
success : function(data) {
console.log(data);
}
});
The output in the console would be:
Hello, my name is John
So, with the returned data you can do whatever you want.

Related

How can i automatically save the image inside a website when i click the add to cart?

how can I automatically save this pizza image, and save it to my local folder? I can easily save the other information, but I'm encountering automatically saving the image itself in a local folder?
I'm fetching the other data from different table, but the I can't save the image itself. I'm have no intention of using foreign key for no.
backend.php
if (isset($_POST['addcart'])) {
$con = connection();
$fetch = singleInfo();
$name = $fetch['name'];
$price = $fetch['price'];
$image = $fetch['image'];
$new_image = '../images/' . $image;
$stmt = $con->prepare("INSERT INTO `cart`(`name`, `price`,`image`) VALUES ('$name','$price','$new_image')");
$stmt->execute();
}
index.php
<?php
session_start();
require('../backend/clientbackend.php');
$fetch = singleInfo();
$current_price = $fetch['price'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./style/style.css">
<title>E-Commerce</title>
</head>
<body>
<nav>
<div class="left">
<h4 class="navbar-header"> Branding </h4>
<ul>
<li>Home</li>
<li>Shop</li>
<li>About</li>
</ul>
</div>
<div class="right">
<button class="loginButton">Login</button>
</div>
</nav>
<article>
<form method="post" class="product-description">
<div class="left">
<div class="left-title" name="name"> <?php echo $fetch['name']; ?> </div>
<div class="left-info">
<p class="left-description"> <?php echo $fetch['desc']; ?> </p>
<span class="price" name="price"> $ <strong> <?php echo $fetch['price']; ?></strong> </span>
</div>
<div class="left-increment">
<div class="addition">+</div>
<input type="number" class="current_value" value="1" min="1">
<div class="subtraction">-</div>
<button class="gotoCart" name="addcart" type="submit"> Add To Cart </button>
Go to cart
</div>
</div>
<div class="right">
<div class="right-image">
<img name="image" src="<?php echo '../uploads/' . $fetch['image']; ?>" alt="">
</div>
</div>
</form>
</article>
<footer>
<div class="footer-container">
<div class="box1">
<h3>Ecommerce Branding</h3>
<span>School Activity</span>
</div>
<div class="box2">
<h3>Colegio De San Lorenzo
</h3>
<span>Congressional Ave, Project 8, Quezon City, Metro Manila</span>
</div>
<div class="box3">
<h3>Emman Cruz</h3>
<span> zurcemozz#gmail.com</span>
</div>
</div>
</footer>
<script>
const addBtn = document.querySelector('.addition');
const subBtn = document.querySelector('.subtraction');
let currentValue = document.querySelector('.current_value');
let stock = 1;
addBtn.addEventListener("click", function() {
stock = stock + 1
currentValue.value = stock;
console.log(currentValue.value);
})
subBtn.addEventListener("click", function() {
if (stock <= 0) {
stock = 0;
} else {
stock = stock - 1
currentValue.value = stock;
console.log(currentValue.value);
}
})
</script>
</body>
</html>
you can copy the image file from '../uploads/' to '../images/' and then you save it .
you can do this with copy function
copy documentations
copy() example :
<?php
$image = '../uploads/'.$fetch['image'];
$new_image= '../images/'.$fetch['image'];
if (!copy($image , $new_image)) {
echo "failed to copy $image ...\n";
}
?>

How to add shortcut to single product page in ajax action.php file

I'm making a website for my school and my website is like a laptop store and the main thing in my webpage is a product filter. I have made the product filter, it works great, but the problem is that I added shortcuts that send you to a single product page by clicking one of the products in the product filter. You can click on a product when you just came in the website and haven't messed with the product filter and it sends you to the single product page, but once you search for something using the filter the filtrated product cant be clicked on and you have to refresh the page to select your product. This is happening, because when you come in the website, you see index.php, but once you use the product filter, you are seeing action.php.
here is a part of my code from index.php:
<?php
$sql="SELECT * FROM Laptop";
$result=$conn->query($sql);
if ($result-> num_rows > 0) {
while($row=$result->fetch_assoc()){
$Laptop_ID = $row['Laptop_ID'];
?>
<?php echo "<a href='single_laptop.php?Laptop=" . $Laptop_ID ."'>" ?>
<div class="col-md-3 mb-2" style="color: blue">
<div class="card-deck">
<div class="card boarder-secondary">
<div class="card-img-overlay">
<h6 class="text-light bg-success text-center rounded p-1">
<?= $row['Nosaukums']; ?></h6>
</div>
<br>
<img src="<?= $row['Bilde']; ?>" class="card-img-top">
<div class="card-body">
<p>
Procesors : <?= $row['Procesors']; ?><br>
Videokarte : <?= $row['Videokarte']; ?><br>
RAM : <?= $row['RAM']; ?><br>
</p>
</div>
</div>
</div>
</div>
<?php }
}else {
echo "nav rezultātu";
}?>
</div>
</div>
</div>
And here is my action.php:
<?php
require 'dataB.php';
if(isset($_POST['action'])){
$sql = "SELECT * FROM Laptop WHERE Modelis !=''";
if(isset($_POST['Modelis'])){
$Modelis = implode("','", $_POST['Modelis']);
$sql .="AND Modelis IN('".$Modelis."')";
}
if(isset($_POST['Tips'])){
$Tips = implode("','", $_POST['Tips']);
$sql .="AND Tips IN('".$Tips."')";
}
if(isset($_POST['RAM'])){
$RAM = implode("','", $_POST['RAM']);
$sql .="AND RAM IN('".$RAM."')";
}
if(isset($_POST['Procesors'])){
$Procesors = implode("','", $_POST['Procesors']);
$sql .="AND Procesors IN('".$Procesors."')";
}
if(isset($_POST['Videokarte'])){
$Videokarte = implode("','", $_POST['Videokarte']);
$sql .="AND Videokarte IN('".$Videokarte."')";
}
$result = $conn->query($sql);
$output='';
if($result->num_rows>0){
while($row=$result->fetch_assoc()){
$output .='
<div class="col-md-3 mb-2" style="color: blue">
<div class="card-deck">
<div class="card boarder-secondary">
<div class="card-img-overlay">
<h6 class="text-light bg-success text-center rounded p-1">
'.$row['Nosaukums'].'</h6>
</div>
<br>
<img src="'.$row['Bilde'].'" class="card-img-top">
<div class="card-body">
<p>
Procesors : '.$row['Procesors'].'<br>
Videokarte : '.$row['Videokarte'].'<br>
RAM : '.$row['RAM'].'<br>
</p>
</div>
</div>
</div>
</div>';
}
} else {
$output = "<h3>No Products Found!<h3>";
}
echo $output;
}
?>
I need to figure out how to properly put the code from index.php, where it makes it possible to redirect me to single.laptop.php, to action.php, so I can redirect to single_laptop.php with no problems using the product filter.
$(document).keydown(function(e){
var keycode=e.keyCode;
if (keycode == 27)
{
$("#change").trigger('click');
}
});
$("#change").click(function() {
//do what you need
if($("#radio:checked").length==0)
{
alert("abc");
return false;
}
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#3.3.7/dist/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#3.3.7/dist/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
Press ESC
</body>
</html>

Duplicating instead of updating

Hello guys
I have a db with guides that in admin mode can be edited. I have just remade the input area and all is good except when logged in as admin i cant update guides, it simply creates a new guide instead of simply updating.
Please be gentle with me as i am a beginner in the coding world, + i would love some fresh eyes on this :) thank you very much
my dashboard code
<?php include("header.php"); ?>
<?php
if(!isset($_SESSION['isLogin']) && $_SESSION['isLogin'] != "YES"){
die("<script> window.location = 'login.php' </script>");
}
$error=false;
$success=false;
if(isset($_GET) && !empty($_GET)) {
$id = base64_decode($_GET['id']);
$user_id = $_SESSION['userInfo']['id'];
$selectSql = "SELECT * FROM guides WHERE 1 = 1 AND user_id = " . $user_id . " AND id = " . $id;
$result = $conn->query($selectSql);
$id = 0;
$title = $step2 = $step3 = $step4 = $step5 = $step6 = $step7 = $step8 = $step9 = '';
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$id = $row['id'];
$title = $row['title'];
$step2 = $row['step2'];
$step3 = $row['step3'];
$step4 = $row['step4'];
$step5 = $row['step5'];
$step6 = $row['step6'];
$step7 = $row['step7'];
$step8 = $row['step8'];
$step9 = $row['step9'];
}
}
}
if(isset($_POST) && !empty($_POST)){
$user_id = $_SESSION['userInfo']['id'];
if($_POST['id']){
$sqlInsert = 'UPDATE guides SET title = "'.htmlentities($_POST["title"]).'", step2 = "'.htmlentities($_POST["step2"]).'", step3 = "'.htmlentities($_POST["step3"]).'", step4 = "'.htmlentities($_POST["step4"]).'", step5 = "'.htmlentities($_POST["step5"]).'", step6 = "'.htmlentities($_POST["step6"]).'", step7 = "'.htmlentities($_POST["step7"]).'", step8 = "'.htmlentities($_POST["step8"]).'", step9 = "'.htmlentities($_POST["step9"]).'" WHERE id = ' . $_POST['id'] . ' AND user_id = ' . $_SESSION['userInfo']['id'];
}else{
$sqlInsert = 'INSERT INTO guides(user_id, title, step2, step3, step4, step5, step6, step7, step8, step9)VALUES ("' .$user_id. '", "'.htmlentities($_POST["title"]).'", "'.htmlentities($_POST["step2"]).'", "'.htmlentities($_POST["step3"]).'", "'.htmlentities($_POST["step4"]).'", "'.htmlentities($_POST["step5"]).'", "'.htmlentities($_POST["step6"]).'", "'.htmlentities($_POST["step7"]).'", "'.htmlentities($_POST["step8"]).'", "'.htmlentities($_POST["step9"]).'")';
}
if ($conn->query($sqlInsert) === TRUE) {
if($_POST['id']){
$success = "Your guide has been updated successfully!";
}else{
$success = "Your guide has been added successfully!";
}
$_SESSION['success'] = $success;
header("Location: dashboard.php");
}else{
$error[] = "Error Message: ".$conn->error;
}
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Guideory - share your knowledge</title>
<link href="css/style.css" rel="stylesheet" type="text/css" media="all"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-
scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Guideory - share your knowledge" />
<!--web-fonts-->
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<link rel="stylesheet" href="css/style.css">
<!--web-fonts-->
</head>
<body>
<div class="header">
</div>
<!---header--->
<!---main--->
<div class="main">
<div class="main-section">
<div class="login-form">
<h2>Share a piece of your knowledge</h2>
<br>
<h4>You can create up to 8 steps, not including the title.
Atleast one step is required. When writing your guide, remember that other
people have to be able to read it, so be as specific as possible.</h4>
<form role="form" method="post">
<div id="step-1">
<ul>
<li class="text-info" id="title">Title:</li>
<li><input type="text" value="<?php echo $title;
?>" name="title" id="title" placeholder="Enter the title for your guide here"
required></li>
<div class="clear"></div>
</ul>
<ul>
<li class="text-info" id="step2">Step 1:</li>
<li><textarea name="step2" id="step2"
placeholder="Enter the description for step 1 here" required><?php echo
$step2; ?></textarea></li>
<div class="clear"></div>
</ul>
<br>
<ul>
<li class="text-info">Step 2:</li>
<li><textarea name="step3" placeholder="Enter the
description for step 2 here"><?php echo $step3; ?></textarea></li>
<div class="clear"></div>
</ul>
<ul>
<li class="text-info">Step 3:</li>
<li><textarea name="step4" placeholder="Enter the
description for step 3 here"><?php echo $step4; ?></textarea></li>
<div class="clear"></div>
</ul>
<ul>
<li class="text-info">Step 4:</li>
<li><textarea name="step5" placeholder="Enter the
description for step 4 here"><?php echo $step5; ?></textarea></li>
<div class="clear"></div>
</ul>
<ul>
<li class="text-info">Step 5:</li>
<li><textarea name="step6" placeholder="Enter the
description for step 5 here"><?php echo $step6; ?></textarea></li>
<div class="clear"></div>
</ul>
<ul>
<li class="text-info">Step 6:</li>
<li><textarea name="step7" placeholder="Enter the
description for step 6 here"><?php echo $step7; ?></textarea></li>
<div class="clear"></div>
</ul>
<ul>
<li class="text-info">Step 7:</li>
<li><textarea name="step8" placeholder="Enter the
description for step 7 here"><?php echo $step8; ?></textarea></li>
<div class="clear"></div>
</ul>
<ul>
<li class="text-info">Step 8:</li>
<li><textarea name="step9" placeholder="Enter the
description for step 8 here"><?php echo $step9; ?></textarea></li>
<div class="clear"></div>
</ul>
<input type="submit" value="Create guide">
</form>
</div>
</div>
</div>
</body>
</html>
There is no input with name id so $_POST['id'] doesn't exist and that's why there's an insert instead of update.
And some extra hints
!isset($_SESSION['isLogin']) && $_SESSION['isLogin'] != "YES"
You probably want isset($_SESSION['isLogin']) here since when the variable is not set it can never be YES
isset($_GET) && !empty($_GET)
You can drop isset here and only use empty.
while ($row = $result->fetch_assoc()) {
Only the last row is stored in those variables, since you are overwriting them.

Can't get login feature to work

I'm currently learning PHP and am creating a small CMS feature that includes a login area. I have used the code below which includes an include header file that contains the doctype/head info and the opening tag. It also includes the header content. I also have a connection file for connecting to the db.
My header include code is:
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title><?php echo $pagetitle ?></title>
<link rel="stylesheet" href="../stylesheets/foundation.css">
<link rel="stylesheet" href="../stylesheets/app.css">
<style>#import url(http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800); #import url (http://fonts.googleapis.com/css?family=Kreon:100,200,300,400);</style>
<script src="../javascripts/modernizr.foundation.js"></script>
</head>
<body>
<div class="subHeader">
<div class="row">
<div class="four columns logo">
<img src="../images/logo.png" alt="logo" />
</div>
<div class="eight columns navigation right">
<ul class="navigationMain">
<li class="<?php if($navcurrent == "home"){echo "navigationActive";} ?>">Home</li>
<li class="<?php if($navcurrent == "services"){echo "navigationActive";} ?>">Services</li>
<li class="<?php if($navcurrent == "work"){echo "navigationActive";} ?>">Recent Work</li>
<li class="<?php if($navcurrent == "about"){echo "navigationActive";} ?>">About</li>
<li class="<?php if($navcurrent == "contact"){echo "navigationActive";} ?>">Contact</li>
</ul>
</div>
<div class="twelve columns titlesection">
<h2><?php echo $headTitle ?></h2>
<h4><?php echo $headsubTitle ?></h4>
</div>
</div><!--End Feature Row-->
</div><!--End Feature-->
<div class="underbar">
<div class="bordertriangle"></div>
<div class="row">
<div class="eight columns"> </div>
<div class="three columns right socialcontainer">
<ul class="socialicons">
<li><a><img id="linkedinIcon" src="../images/socialli.png" alt="linkedin icon" /></a></li>
<li><a><img id="twitterIcon" src="../images/socialtw.png" alt="twitter icon" /></a></li>
<li><a><img id="facebookIcon" src="../images/socialfb.png" alt="facebook icon" /></a></li>
</ul>
</div>
</div>
When I open the admin page, the username password form, header and footer appear as they should. If I test the errors, they return as they should. However, when I successfully log in using a valid username and password, no content appears except the what is included in the header file. Can anyone point me in the direction of what i might be doing wrong? Any help would be much appreciated. I am a relative noob to PHP...
<?php
$pagetitle = "Admin";
$navcurrent = "home";
$headTitle = "ADMIN AREA";
$headsubTitle = "SITE ADMINISTRATION AREA";
include_once('../includes/connection.php');
include_once('../includes/headeradmin.php');
if (isset($_SESSION['logged_in'])) {
echo('Successfully Logged In');
} else {
if (isset($_POST['username'], $_POST['password'])){
$username = $_POST['username'];
$password = $_POST['password'];
if (empty($username) or empty($password)){
$error = 'An Error Has Occurred - All Fields Are Required';
}
else{
$query = $pdo->prepare('SELECT * FROM users WHERE user_name = ? AND user_password = ?');
$query->bindValue(1, $username);
$query->bindValue(2, $password);
$query->execute();
$num = $query->rowCount();
if ($num == 1) {
$_SESSION['logged_in'] = true;
header('location: index.php');
exit();
}
else{
$error = 'The username/password you entered was incorrect - Please try again';
}
}
}
?>
<div class="row">
<div class="four columns centered">
<?php if (isset($error)) { ?>
<h5 style="color: #e63333;"><?php echo $error; ?></h5>
<br />
<br />
<?php } ?>
<form action="index.php" method="post">
<input type="text" name="username" placeholder="Username" />
<input type="password" name="password" placeholder="Password" />
<input type="submit" value="Login" />
</form>
</div>
</div>
You can't use the header('location: index.php'); line if you've already output content (i.e - html code) to the browser when you included the header in this line include_once('../includes/headeradmin.php');
read the documentation of header - Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP
you need to redirect the user with the header() function before you output the head html of the admin page

Random <hr/> that I don't know how to get rid of!

I have just searched the document to find it, I removed the <hr class="cmdbar"></hr> but it is still there! Do any of you see anything else?
<?php print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<font face="Segoe UI">
<body>
<script type="text/javascript">
/*function detectBrowser()
{
var browser = navigator.appCodeName;
if (browser!="Mozilla") {document.location.href="noaccess.php"; alert(browser);}
}
detectBrowser();
*/
</script>
<title>Second</title>
<link rel="stylesheet" type="text/css" href="allCSS.css"/>
<center>
<!--<img align="right" src="logo.png" id="headerimg"/>-->
<input type="image" id="headerimg" src="logo.png" align="right" onclick="toggleh();"/>
<ul align="center" class="">
<div class="menu">
<ul class="nav">
<li><strong>Home</strong>
<ul>
<li>Games</li>
<li>Browse</li>
<li>Catalogue</li>
<li>Forums</li>
</ul>
</li>
<li><strong>Games</strong>
<ul>
<li>Profile</li>
<li>Settings</li>
</ul>
</li>
<li><strong>Contact</strong>
<ul>
<li>Phone</li>
<li>Email</li>
<li>Mail</li>
</ul>
</li>
</div>
</center>
</body>
<center>
<?php
echo '<div id="msg">';
include 'message.txt';
echo '</div>';
//include 'hits.txt';
?>
<p>
<?php
function ChangeText($txt)
{
$txt='<script type="text/javascript">get();</script>';
echo '<script type="text/javascript">change();</script>';
$filename="message.txt";
$fp=fopen($filename,'w');
fwrite($fp,'<h4 class="hmsg">' . $txt . '</h4>');
fclose($fp);
}
?>
<script type="text/javascript">
<!--
window.onload=enter;
function enter()
{
//alert("Welcome!");
//hideCMD();
}
function get(text)
{
text=document.getElementById("ta").value;
return text;
}
function toggleh()
{
var element=document.getElementById("headerimg");
if (element.style.display!="none"){element.style.display="none";}
else {element.style.display="";}
}
function change(text)
{
text=document.getElementById("ta").value;
if (text=="toggle") {toggleh(); return;}
if (text=="home") {document.location.href="index.html"; return;}
if (text.match("goto:*")) {var loc=text.substring(5,text.length); document.location.href=loc; return;}
if (text.match("ban:*")) {var loc=text.substring(4,text.length); document.location.href=loc; return;}
document.getElementById("msg").innerHTML='<h2 class="hmsg">'+text+'</h2>';
}
function hideCMD()
{
document.getElementById("cmd").style.display="none";
}
//-->
</script>
</head>
<body>
<div id="msg">
</div>
<p id="cmd">
<input class="panela" type="text" value="" id="ta" maxLength="20"/>
<input class="panelb" type="image" src="submit.png" alt="Submit" onclick='change();'/>
</p>
</center>
<p class="hide">-</p>
</font>
</html>
Here it is <hr class="cmdbar"></hr>, line: 126. CTRL + F generally works with most text editors.
Here it is:
<p id="cmd">
<hr class="cmdbar"></hr>
<input class="panela" type="text" value="" id="ta" maxLength="20"/>
<input class="panelb" type="image" src="submit.png" alt="Submit" onclick='change();'/>
</p>
Browsers do treat <hr></hr> as a proper <hr /> too, although that's not supposed to be so according to W3C specs.
You could also use Firebug for Firefox. It's a neat add-on that helps you find code based on the appearance of the web page.

Categories