Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Edit three - In which we find out I am really not very clever
False alarm people, I can't use php in my current setup. I will go beat my head against a wall for a while. Thanks for your help and suggestions anyway.
I am attempting to follow this tutorial in order to allow a "Mobile/Full" switch on my responsive website. However, the link being used to display the option is showing both at once, not an 'either or' situation like it's supposed to.
The tutorial is using a little bit of PHP, which I don't know yet, so I don't know exactly where the error is. It all looks fine to me, but this code:
<div id="toggleView">
<?php if ( $fixedwidth == '1' ): ?>
Switch to Mobile site
<?php else: ?>
Switch to Full site
<?php endif; ?>
</div>
Should display only one of the strings, but instead it displays both links like this:
?fixedwidth=0">Switch to Mobile site ?fixedwidth=1">Switch to Full site
I'm thinking it's a syntax problem with the ["Script_Name"] segment but I don't know what the correct syntax should be.
EDIT
This is the PHP I've inserted on my page to detect the change in fixedwidth:
<?php
$fixedwidth = '';
// Check if the query string contains our key and assign its value to $fixedwidth
if ( isset($_GET['fixedwidth']) && ($_GET['fixedwidth'] != "") ) {
$fixedwidth = $_GET['fixedwidth'];
}
// Check if a cookie has already been set
if ( isset($_COOKIE['fixedwidth']) ) {
if ( $fixedwidth == '0' ) {
// If the value is '0', delete the cookie
setcookie('fixedwidth', '', time() - 60, '/');
} else {
// Value is not '0', so no need to get the cookie value
$fixedwidth = '1';
}
} else if ( $fixedwidth == '1') {
// The user wants fixed width, so set a cookie
$expires = 60 * 60 * 24 * 60 + time();
setcookie('fixedwidth', '1', $expires, '/');
}
?>
So, I've basically copy-pasted this from the tutorial to try and get this functionality on my page but I don't know if it's actually correct.
Edit 2 - Electric Boogaloo
Here's the code from the page in question:
<%# Master Language="c#" CodeFile="Standard.master.cs" Inherits="Standard_" %>
<%# Register Src="/include/menu_left.ascx" TagName="menu_left" TagPrefix="uc4" %>
<%# Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<?php
$fixedwidth = '1';
// Check if the query string contains our key and assign its value to $fixedwidth
if ( isset($_GET['fixedwidth']) && ($_GET['fixedwidth'] != "") ) {
$fixedwidth = $_GET['fixedwidth'];
}
// Check if a cookie has already been set
if ( isset($_COOKIE['fixedwidth']) ) {
if ( $fixedwidth == '0' ) {
// If the value is '0', delete the cookie
setcookie('fixedwidth', '', time() - 60, '/');
} else {
// Value is not '0', so no need to get the cookie value
$fixedwidth = '1';
}
} else if ( $fixedwidth == '1') {
// The user wants fixed width, so set a cookie
$expires = 60 * 60 * 24 * 60 + time();
setcookie('fixedwidth', '1', $expires, '/');
}
?>
<!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 id="Head1" runat="server">
<title>Website Title</title>
<asp:ContentPlaceHolder ID="MetaDescriptionHolder" runat="server" Visible="true">
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="MetaKeywordsHolder" runat="server" Visible="true">
</asp:ContentPlaceHolder>
<meta name="author" content="website" />
<?php
// Only insert the meta[name="viewport"] element if responsive is not disabled
if ( $fixedwidth = '1' ): ?>
<meta name="viewport" content="width=1400, initial-scale=1" />
<?php endif; ?>
<link rel="shortcut icon" href="favicon.ico" />
<link rel="stylesheet" type="text/css" href="fontawesome/css/font-awesome.min.css">
<link href="favicon.ico" rel="shortcut icon" />
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700' rel='stylesheet' type='text/css'>
<style type="text/css"><!-- #import url("../../../css/responsive.css?t=<%= DateTime.Now.Ticks %>"); --></style>
<%--<style type="text/css"><!-- #import url("../../../css/main-cs.css?t=<%= DateTime.Now.Ticks %>"); --></style>--%>
<script language="javascript" type="text/javascript" src="../../../js/jquery1.4.2.js"></script>
<script language="javascript" type="text/javascript" src="../../../js/validation.js"></script>
<script language="javascript" type="text/javascript" src="../../../js/functions.js"></script>
<script language="javascript" type="text/javascript" src="/js/browser-selector.js"></script>
<script src="/js/jquery.autocomplete.js" type="text/javascript"></script>
<asp:ContentPlaceHolder ID="slideshowHolder" runat="server" Visible="true">
</asp:ContentPlaceHolder>
<script type="text/javascript">
$(document).ready(function () {
$("#<%=txtSearch.ClientID %>").autocomplete('/SearchTextBox.ashx');
});
</script>
<script type="text/javascript">
function displayLogin(obj) {
if (obj.checked) {
if (!confirm('If you tick this box then you will no longer need to log in when visiting website from this computer.\n\nYou can disable this feature at any time by logging out.\n\nDon\'t use this option unless you are the only person who has access to this computer.\n\nWARNING:\nIf you do decide to use this option you will be liable for the actions of anyone who uses your login to access website.'))
{ obj.checked = false; }
}
}
var mouse_is_inside = false;
$(document).ready(function () {
$('#login_box').hover(function () {
mouse_is_inside = true;
}, function () {
mouse_is_inside = true;
});
});
</script>
</head>
<body>
<form id="Form1" runat="server">
<div class="top-menu">
<div class="top-menu-holder">
<div class="top-menu-tabs">
<div class="top-menu-tabs-shop-on">
<strong>Online Store</strong>
</div>
<div class="top-menu-tabs-residential">
<a href="http://www. <strong>IT Services</strong></a>
</div>
<div class="top-menu-tabs-services">
Business <strong>IT Services</strong>
</div>
</div>
<div class="top-menu-menu">
<ul>
<li class="line">Contact</li>
<li class="line">About</li>
<li class="line">Feedback</li>
<li class="line"><a href="/testimonials.aspx" alt="Testimonials" title="Testimonials">
Testimonials</a></li>
<li class="line">Employment</li>
<li class="line">Awards</li>
<li class="line">Vouchers</li>
<li class="line">Promotions</li>
</ul>
</div>
</div>
</div>
<div class="page-content">
<div class="shop-header">
<div class="shop-header-logo">
<a href="/">
<img alt="Online Store" src="/images/shop-logo.png" /></a>
</div>
<div class="shop-header-phone">
Freephone<br />
</div>
<div class="shop-header-ad" style='<%# "display:" + (c.CustomerID >0 || Convert.ToInt32(c.GetTotalsForCart()[0]) > 0 ? "none": "") %>'>
<a href="https://shop.eset.co.nz/shop/?mode=tr&resellerid=IyUqXygK">
<img alt="eset free 30 day trial" src="/images/top-strip-ad/eset-trial.jpg" title="eset free 30 day trial" /></a>
</div>
<asp:Panel ID="pnlCart" runat="server">
<div class="shop-header-cart">
<div class="shop-header-cart-label-cart">
Shopping Cart:</div>
<div class="shop-header-cart-label-link">
<a id="A12" class="white" href="~/cart.aspx" runat="server">Shopping Cart:</a></div>
<div class="shop-header-cart-label">
Items:</div>
<div class="shop-header-cart-details">
<asp:Label ID="lblProducts" runat="server"></asp:Label></div>
<div class="shop-header-cart-label">
Total:</div>
<div class="shop-header-cart-details">
$<asp:Label ID="lblCost" runat="server"></asp:Label></div>
<div class="shop-header-cart-button">
<div class="green-button">
<a id="A6" href="~/cart.aspx" runat="server">View Cart</a>
</div>
</div>
</div>
</asp:Panel>
<asp:Panel ID="pnlAccount" runat="server" Visible="false">
<div class="account-menu">
<ul>
<li><a id="A2" href="~/saved-carts.aspx" runat="server">Saved Carts</a></li>
<li id="lstAccountModule1" runat="server" visible="false" class="line"><a id="A3"
href="~/transactions.aspx" runat="server">Transactions</a></li>
<li id="lstAccountModule2" runat="server" visible="false" class="line"><a id="A4"
href="~/orders.aspx" runat="server">Orders</a></li>
<li id="lstServiceModule1" runat="server" visible="false" class="line"><a id="A5"
href="~/service-tickets.aspx" runat="server">Service Tickets</a></li>
<li id="lstManageModule" runat="server" visible="false" class="line"><a id="A7"
href="~/manage.aspx" runat="server">Manage</a></li>
</ul>
</div>
</asp:Panel>
</div>
<div class="shop-menu-login-bar">
<asp:Panel ID="pnlLoggedOut" runat="server" autocomplete="off">
<ul>
<li>
Log In
</li>
<li class="line">
Register
</li>
</ul>
</asp:Panel>
<asp:Panel ID="pnlLoggedIn" runat="server" autocomplete="off">
<ul>
<li>
Logout
</li>
<li class="line">
<a id="A9" href="~/update-details.aspx" runat="server">My Details</a>
</li>
</ul>
</asp:Panel>
<asp:Panel ID="pnlsearch3" runat="server" DefaultButton="btnsearch3">
<div class="search-3">
<asp:TextBox ID="txtSearch3" runat="server" Class="search-textbox-3" onblur="if(this.value == '') { this.value='Enter keyword or product code'; isSet=true; }"
onmouseover="if(this.value == 'Enter keyword or product code') { this.value='';isSet = true; }"
onmouseout="if(this.value == '' && !isSet) { this.value='Enter keyword or product code'; isSet=>false; }"
MaxLength="255" Text="Enter keyword or product code" ontextchanged="btnsearch3_Click" />
<asp:ImageButton ID="btnsearch3" Class="search-icon-3" ImageAlign="Right" BackColor="White" runat="server" Width="20" Height="20" OnClick="btnsearch3_Click" ImageUrl="~/images/search-icon.gif" />
</div>
</asp:Panel>
</div>
<div class="shop-menu">
<div class="shop-menu-float-left">
<ul>
<li><asp:HyperLink runat="server" ID="hlComputers" NavigateUrl="/Computers/Index.aspx" Text="Computers" ToolTip="View Products in Computers Category"/></li>
<li class="line"><asp:HyperLink ID="hlElectronics" NavigateUrl="/Electronics/Index.aspx" runat="server" tooltip="View Products in Electronics Category" Text="Electronics"/></li>
<li class="line"><asp:HyperLink ID="hlExLease" NavigateUrl="/Computers/Ex-Lease/index.aspx" runat="server" tooltip="View our Ex-Lease Items" Text="Ex-Lease"/></li>
<li class="line"><asp:HyperLink ID="hlClearance" NavigateUrl="/search.aspx?S=Clearance+Item&picture=0" runat="server" tooltip="View our Clearence Items" Text="Clearance"/></li>
<li class="line"><asp:HyperLink ID="hlRepairs" NavigateUrl="/Christchurch-Computer-Repairs-and-Service.aspx" runat="server" tooltip="View our Store Service Department" Text="Repairs" /></li>
</ul>
</div>
<div class="shop-menu-float-right">
<asp:Panel ID="pnlLogin" runat="server" autocomplete="off">
<div class="green-button">
Log In
</div>
<div class="my-details">
<div class="green-button">
Register
</div>
</div>
<div id="login_box">
<div id="login_box_content">
<div class="login-row">
<h2 class="login">
Login<a onclick="javascript:$('#login_box').fadeOut("fast");"><img alt=''
src="/images/close.png" class="login-close" /></a></h2>
</div>
<div class="login-row">
<div class="login-label">
Email</div>
<div class="login-field">
<input type="text" id="txtLoginEmail" autocomplete="off" name="txtLoginEmail" tabindex="1" maxlength="255"
class="login-input" /></div>
</div>
<div class="login-row">
<div class="login-label">
Password</div>
<div class="login-field">
<input type="password" name="txtLoginPassword" autocomplete="off" id="txtLoginPassword" tabindex="2"
maxlength="255" class="login-input" />
</div>
</div>
<div class="login-remember">
<div class="login-remember-field">
<input name="auto_login" id="auto_login" onclick="displayLogin(this);" tabindex="3" type="checkbox" />
</div>
<div class="login-remember-label">
Remember Me
</div>
</div>
<div class="login-button">
<div class="green-button">
<input type="image" causesvalidation="false" src="/images/log-in.png" alt="login" title="login" tabindex="4" runat="server" id="login" />
</div>
</div>
<div class="login-remember">
Forgot your password?
</div>
</div>
</div>
<input type="hidden" name="previousPage" value="<%=strPreviousPage %>" />
</asp:Panel>
<asp:Panel ID="pnlLogoutMenu" runat="server">
<div class="green-button">
Logout
</div>
<div class="my-details">
<div class="green-button">
<a id="A1" href="~/update-details.aspx" runat="server">My Details</a>
</div>
</div>
</asp:Panel>
<asp:Panel ID="pnlSearch" runat="server" DefaultButton="ImageButton1">
<div class="search-textbox">
<asp:TextBox ID="txtSearch" runat="server" CssClass="search" onblur="if(this.value == '') { this.value='Enter keyword or product code'; isSet=true; }"
onmouseover="if(this.value == 'Enter keyword or product code') { this.value='';isSet = true; }"
onmouseout="if(this.value == '' && !isSet) { this.value='Enter keyword or product code'; isSet=>false; }"
MaxLength="255" Text="Enter keyword or product code" ontextchanged="btnSearch_Click" /><asp:ImageButton ID="ImageButton1" Class="search-icon" ImageAlign="Right" Width="15" Height="15" BackColor="White" runat="server" OnClick="btnSearch_Click" ImageUrl="~/images/search-icon.gif" />
</div>
</asp:Panel>
</div>
<input type="hidden" name="previousPage" value="<%=strPreviousPage %>"
</div>
<asp:Panel ID="pnlmsearch" runat="server" DefaultButton="btnmsearch" Visible="true">
<div class="search-m">
<asp:TextBox ID="txtSearchM" runat="server" Class="search-textbox-m" onblur="if(this.value == '') { this.value='Enter keyword or product code'; isSet=true; }"
onmouseover="if(this.value == 'Enter keyword or product code') { this.value='';isSet = true; }"
onmouseout="if(this.value == '' && !isSet) { this.value='Enter keyword or product code'; isSet=>false; }"
MaxLength="255" Text="Enter keyword or product code" ontextchanged="btnmsearch_Click" />
<asp:ImageButton ID="btnmsearch" Class="search-icon-m" ImageAlign="Right" BackColor="White" runat="server" Width="30" Height="30" OnClick="btnmsearch_Click" ImageUrl="~/images/search-icon.gif" />
</div>
</asp:Panel>
<div class="content-holder">
<div class="page-content-menu">
<uc4:menu_left ID="Menu_left" runat="server" />
</div>
<div class="page-content-info">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</div>
<div class="footer">
<div id="toggleView">
<?php if ( $fixedwidth == '1' ) { ?>
Switch to Mobile site
<?php } else { ?>
Switch to Full site
<?php } ?>
</div>
<div class="footer-content">
<div class="footer-content-border">
<div class="footer-payment-method">
<div class="footer-payment-method-border">
<div class="footer-payment-text">
Secure online payments with <strong>3D Secure</strong></div>
<div class="footer-payment-visa-verified">
<img runat="server" src="/images/verified-by-visa.png" alt="Verified by Visa" title="Verified by Visa" /></div>
<div class="footer-payment-mastercard-securecode">
<img runat="server" src="/images/mastercard-securecode.png" alt="MasterCard SecureCode" title="MasterCard SecureCode" /></div>
<div class="footer-payment-visa">
<img runat="server" src="/images/visa-logo.png" alt="site accepts Visa" title=site accepts Visa" /></div>
<div class="footer-payment-mastercard">
<img runat="server" src="/images/mastercard-logo.png" alt="Global PC accepts Mastercard"
title="site accepts Mastercard" /></div>
<div class="footer-payment-payment-express">
<img runat="server" src="/images/payment-express.png" alt=" accepts Payment Express"
title=" PC accepts Payment Express" /></div>
</div>
</div>
<div class="footer-social-media">
<div class="footer-title">
Social Media</div>
<div class="footer-facebook">
<a runat="server" href="http://www.facebook.com/" target="_blank">
<img runat="server" src="/images/facebook.png" border="0" alt="Become a fan of on Facebook"
title="Become a fan of on Facebook" /></a>
</div>
</div>
<div class="footer-links-left">
<div class="footer-title">
Shopping</div>
Home<br />
View cart<br />
Promotions<br />
Create Account
</div>
<div class="footer-links-right">
<div class="footer-title">
About </div>
Contact us<br />
About us<br />
Stores<br />
Suppliers<br />
Feedback
</div>
<div class="footer-legal">
<div class="footer-title">
Legal Information</div>
Terms and Conditions<br />
Privacy policy<br />
<asp:Label ID="lblCopyright" runat="server"></asp:Label>
</div>
</div>
</div>
</div>
</div>
</form>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-8649565-1");
pageTracker._trackPageview();
} catch (err) { }</script>
</body>
</html>
To make this a bonafide answer, from the comments and your edits it can be seen that you are attempting to write PHP code into an ASPX file who's language is set to C#, and that is why it does not work.
You need to rewrite this using ASP.net's template syntax, not PHP.
You're not using proper PHP syntax for conditionals.
Here's a fixed version:
<div id="toggleView">
<?php if ( $fixedwidth == '1' ) { ?>
Switch to Mobile site
<?php } else { ?>
Switch to Full site
<?php } ?>
</div>
Related
I'm trying to get the select tag to show the titles of the posts that are in the DB so i can select them individually and up date them instead of updating all the titles with the same name.
So my problem is that i can't get it to work and maybe someone may be able to help me.
This is what i mean->https://imgur.com/a/ie1g4hF
if you want the full version you can get it from my github:
https://github.com/TwistedZebra/blog
That version up there does not contain the select tags but uses a text box to delete the post that is named but with a disadvantage of deleten every post named the same.
<?php
require 'config.php';
if (isset($_POST['submit'])) {
$updatetitle = $_POST['updatetitle'];
$title = $_POST['title'];
$content = $_POST['content'];
if (empty($title) || empty($content)) {
header('Location: update.php?=error');
exit();
} else {
$updatedcontent = $connection->prepare('UPDATE posts SET title = :title , content = :content WHERE title = :updatetitle');
$updatedcontent->execute(['title' => $title, 'content'=> $content, 'updatetitle' => $updatetitle]);
header('Location: update.php?=success');
}
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="public/css/main.css">
<title>Control panel</title>
</head>
<body>
<div class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="navbar-brand ">
<h2>BloggerWorld</h2>
</div>
<ul class="nav">
<li class="nav-item">
<a class="nav-link" href="public/index.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="public/posts.php">Posts</a>
</li>
<li class="nav-item">
<a class="nav-link" href="adminpanel.php">Admin Panel</a>
</li>
</ul>
</div>
<br><br><br><br><br><br><br>
<div class="container-fluid">
<div class="container">
<h1>Update post</h1>
<form method="post" action="update.php" >
<select name="delTitle" class="form-control">
<?php foreach ($updatedcontent as $update) { ?>
<option><?php echo $post['title']; ?></option>;
<?php } ?>
</select>
<br>
<input type="text" name="title" class="form-control" placeholder="New title" >
<br>
<textarea name="content" rows="5" cols="60" class="form-control" placeholder="Enter post"></textarea>
<br>
<br>
<button type="submit" name="submit" class="btn btn-success">Update post</button>
</form>
</div>
</div>
<script>
document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] +
':35729/livereload.js?snipver=1"></' + 'script>')
</script> enter code here
</body>
</html>
well I probably ran into a problem this morning and trying to figure out where I'm going wrong. The page was working fine without the PHP but as soon as I stuffed this page with statements from PHP (For displaying data in my website) I observed that my website was repeating with the number of records. Say, 5 records are to be displayed in the website then the website repeats 5 times. I'm using MySQL, PHPmyAdmin and HTML. Any help would be greatly appreciated and I hope I'm not missing out on something very usual. Before looking at the code I would recommend you to just go through the PHP part because before adding PHP, the site was functioning very normally!
Here's all you will need: My HTML code for the particular page:
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
session_start();
if (!(isset($_SESSION['state']) && $_SESSION['state'] != '')) {
header ("Location: ../login.php");
}
else
{
include_once ('E:/Softwares/wamp/www/connection.php');
$username = $_SESSION['username'];
$result = mysql_query("SELECT *from `movie_schedule`");
if(mysql_num_rows($result))
{while($row = mysql_fetch_array($result, MYSQL_BOTH))
{
?>
<!DOCTYPE html>
<html>
<head>
<title>The CineShed Cinemas</title>
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/bootstrap1.css" rel="stylesheet" type="text/css" media="all">
<!-- web-font -->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,300,700,800,400,600' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Poiret+One' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Merriweather:400,700italic,400italic,300,900,700,900italic,300italic' rel='stylesheet' type='text/css'>
<!-- web-font -->
<!-- js -->
<script src="js/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- js -->
<!-- start-smoth-scrolling -->
<script type="text/javascript" src="js/move-top.js"></script>
<script type="text/javascript" src="js/easing.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".scroll").click(function(event){
event.preventDefault();
$('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
});
});
</script>
<!-- start-smoth-scrolling -->
</head>
<body>
<!-- header -->
<div id="home" class="header">
<!-- container -->
<div class="container">
<div class="header-logo">
<h1>The CineShed<span> Cinemas<br>-------------------------------<br>You've logged in as ADMIN</span></h1>
</div>
<div class="top-nav">
<p><a class="Signup play-icon popup-with-zoom-anim" href="#small-dialog3"></a><span> Log Out</P>
</div>
<div class="clearfix"> </div>
<!-- banner Slider starts Here -->
<script src="js/responsiveslides.min.js"></script>
<script>
// You can also use "$(window).load(function() {"
$(function () {
// Slideshow 4
$("#slider4").responsiveSlides({
auto: true,
pager: true,
nav: false,
speed: 500,
namespace: "callbacks",
before: function () {
$('.events').append("<li>before event fired.</li>");
},
after: function () {
$('.events').append("<li>after event fired.</li>");
}
});
});
</script>
<!--//End-slider-script -->
<div id="top" class="callbacks_container">
<ul class="rslides" id="slider4">
<li>
<div class="header-info">
<p>BY<span> ZARYAB</span><span class="sub-text"> Ali</span></p>
<p>Experience the</p>
<p> third dimension!</p>
<div class="red">DOLBY DIGITAL 3-D</div>
<!--
<div class="button">View Here</div>
-->
</div>
</li>
<li>
<div class="header-info">
<p>BY<span> ZARYAB</span><span class="sub-text"> Ali</span></p>
<p>Premium Seating?</p>
<p> We've got this covered!</p>
<div class="red">TITAN XC</div>
</div>
</li>
<li>
<div class="header-info">
<p>BY<span> ZARYAB</span><span class="sub-text"> Ali</span></p>
<p>Enjoy the awesomeness</p>
<p> of explosive sound!</p>
<div class="red">WITH 7.1 AUDIO CHANNELS!</div>
</div>
</li>
<li>
<div class="header-info">
<p>BY<span> ZARYAB</span><span class="sub-text"> Ali</span></p>
<p>Activities to keep</p>
<p> your wee ones busy!</p>
<div class="red">KID'S CORNER</div>
</div>
</li>
<li>
<div class="header-info">
<p>BY<span> ZARYAB</span><span class="sub-text"> Ali</span></p>
<p>A mouth-watering</p>
<p> menu awaits you!</p>
<div class="red"># Arizona Grill</div>
</div>
</li>
</ul>
<div class="clearfix"> </div>
<!-- banner Slider Ends Here -->
</div>
</div>
<!-- container -->
</div>
<!-- header -->
<!-- sticky -->
<div class="sticky">
<!-- container -->
<div class="container">
<div class="top-header">
<div class="fixed-header">
<div class="sticky-logo">
<h1><a class="scroll" href="#home">The CineShed <span>Cinemas</a> </span></h1>
</div>
<div class="sticky-nav">
<ul>
<li><a class="scroll active" href="#banner">View Trailers</a></li>
<li><a class="scroll" href="#manage">Manage Show Times</a></li>
<li><a class="scroll" href="#offpur">View Purchases</a></li>
</ul>
</div>
<div class="clearfix"> </div>
</div>
</div>
</div>
<!-- container -->
</div>
<!-- sticky -->
<!-- script-for sticky-nav -->
<script>
$(document).ready(function() {
var navoffeset=$(".top-header").offset().top;
$(window).scroll(function(){
var scrollpos=$(window).scrollTop();
if(scrollpos >=navoffeset){
$(".top-header").addClass("fixed");
}else{
$(".top-header").removeClass("fixed");
}
});
});
</script>
<!-- /script-for sticky-nav -->
<!-- banner -->
<div id="banner" class="banner">
<a class="play-icon popup-with-zoom-anim" href="#small-dialog"><span> </span></a>
<!-- pop-up-box -->
<script type="text/javascript" src="js/modernizr.custom.min.js"></script>
<link href="css/popuo-box.css" rel="stylesheet" type="text/css" media="all" />
<script src="js/jquery.magnific-popup.js" type="text/javascript"></script>
<!--//pop-up-box-->
<div id="small-dialog" class="mfp-hide">
<iframe src="https://www.ytpak.com/?component=video&task=embed&id=R-XsppzuH-k&branding=no" scrolling="NO" frameborder="0" width="100%" height="315" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://www.ytpak.com/?component=video&task=embed&id=K-H35Mpj4uk&branding=no" scrolling="NO" frameborder="0" width="100%" height="315" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<iframe src="https://www.ytpak.com/?component=video&task=embed&id=K-H35Mpj4uk&branding=no" scrolling="NO" frameborder="0" width="100%" height="315" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
<div id="small-dialog3" class="mfp-hide">
<div class="login">
<h3>Login</h3>
<p>Enter your account details to login</p>
<input type="text" maxlength="20" value="EMAIL" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'EMAIL';}">
<input type="text" maxlength="10" value="PASSWORD" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'PASSWORD';}">
<input type="submit" value="Submit"/>
</div>
</div>
<div id="small-dialog2" class="mfp-hide">
<div class="signup">
<h3>Register</h3>
<h4>Please Enter Your Details</h4>
<input type="text" value="First Name" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'First Name';}" />
<input type="text" value="Second Name" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Second Name';}" />
<input type="text" class="email" value="Email" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email';}" />
<input type="text" class="password" value="Password" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Password';}"/>
<input type="text" class="email" value="Confirm password" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Confirm password';}" />
<input type="submit" value="Submit"/>
</div>
</div>
<script>
$(document).ready(function() {
$('.popup-with-zoom-anim').magnificPopup({
type: 'inline',
fixedContentPos: false,
fixedBgPos: true,
overflowY: 'auto',
closeBtnInside: true,
preloader: false,
midClick: true,
removalDelay: 300,
mainClass: 'my-mfp-zoom-in'
});
});
</script>
</div>
<!-- banner -->
<!-- container -->
<div id="manage" class="container">
<h3><br>Manage Show Times<br></h3>
<div class="col-md-7">
<div class="col-md-6">
<form method="post" action="savemovie.php">
<input type="text" class="text" value="Movie ID" name="field1" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Movie ID';}">
<input type="text" class="text" value="Movie Date" name="field2" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Movie Date';}">
<input type="text" class="text" value="Show Time" name="field3" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Show Time';}">
<input type="text" class="text" value="Movie Cost" name="field4" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Movie Cost';}">
<input type="text" class="text" value="Movie Name" name="field5" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Movie Name';}">
<input type="text" class="text" value="Tickets Availability" name="field6" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Tickets Availability';}">
<div class="clearfix"> </div>
<div class="submit-button">
<input type="submit" value="ADD MOVIE">
</form>
</div>
</div>
<div class="clearfix"> </div>
</div>
</div>
<!-- container -->
<?php
$result1 = mysql_query("SELECT *from `movie_schedule`");
if(mysql_num_rows($result1))
{while($row2 = mysql_fetch_array($result1, MYSQL_BOTH))
{
?>
<!-- content-events -->
<div id="event" class="content-event">
<!-- container -->
<div class="container">
<h3>Show Times</h3>
<div class="event-grids">
<div class="col-md-3 event-grid">
<div class="pic"> </div>
<ul>
<li class="hedding"><?php print($row2['Movie_ID']); ?> <?php print($row2['Movie_Name']); ?></li>
<li class="date"><?php print($row2['Movie_Date']); ?></li>
</ul>
<div class="clearfix"> </div>
</div>
<div class="col-md-4 event-grid small-text">
<p><br><?php print($row2['Show_Time']); ?></p>
</div>
<div class="col-md-2 event-grid large-text">
<p class="text"><?php print($row2['Movie_Cost']); ?></p>
</div>
<div class="col-md-3 event-grid text-button">
<ul>
<li class="num"><?php print($row2['Movie_ID']); ?></li>
<li class="button yellow">Remove</li>
</ul>
<?php
}}
?>
</div>
</div>
<!-- container -->
</div>
<!-- contact-events -->
<!-- content-events -->
<div id="offpur" class="content-event">
<!-- container -->
<div class="container">
<h3>View Offline Purchases</h3>
<div class="event-grids">
<div class="col-md-3 event-grid">
<div> </div>
<ul>
<li class="hedding">Offline Purchase ID</li>
<li class="date">(Serial Number)</li>
</ul>
<div class="clearfix"> </div>
</div>
<div class="col-md-4 event-grid small-text">
<p><br>Movie ID</p>
</div>
<div class="col-md-2 event-grid large-text">
<p class="text">Amount</p>
</div>
<div class="col-md-3 event-grid text-button">
<ul>
<li class="num">Quantity Of Tickets</li>
</ul>
</div>
<div class="clearfix"> </div>
</div>
<div class="event-grids">
<div class="col-md-3 event-grid">
<div> </div>
<ul>
<li class="hedding">111</li>
<li class="date"></li>
</ul>
<div class="clearfix"> </div>
</div>
<div class="col-md-4 event-grid small-text">
<p>01</p>
</div>
<div class="col-md-2 event-grid large-text">
<p class="text">2100 PKR</p>
</div>
<div class="col-md-3 event-grid text-button">
<ul>
<li class="num">3</li>
</ul>
</div>
<div class="clearfix"> </div>
</div>
<div class="event-grids">
<div class="col-md-3 event-grid">
<div> </div>
<ul>
<li class="hedding">112</li>
<li class="date"></li>
</ul>
<div class="clearfix"> </div>
</div>
<div class="col-md-4 event-grid small-text">
<p><br>03</p>
</div>
<div class="col-md-2 event-grid large-text">
<p class="text">1400 PKR</p>
</div>
<div class="col-md-3 event-grid text-button">
<ul>
<li class="num">2</li>
</ul>
</div>
<div class="clearfix"> </div>
</div>
<div class="event-grids">
<div class="col-md-3 event-grid">
<div> </div>
<ul>
<li class="hedding">115</li>
<li class="date"></li>
</ul>
<div class="clearfix"> </div>
</div>
<div class="col-md-4 event-grid small-text">
<p><br>02</p>
</div>
<div class="col-md-2 event-grid large-text">
<p class="text">3500 PKR</p>
</div>
<div class="col-md-3 event-grid text-button">
<ul>
<li class="num">5</li>
</ul>
</div>
<div class="clearfix"> </div>
</div>
<div class="event-grids">
<div class="col-md-3 event-grid">
<div> </div>
<ul>
<li class="hedding">124</li>
<li class="date"></li>
</ul>
<div class="clearfix"> </div>
</div>
<div class="col-md-4 event-grid small-text">
<p><br>02</p>
</div>
<div class="col-md-2 event-grid large-text">
<p class="text">2800 PKR</p>
</div>
<div class="col-md-3 event-grid text-button">
<ul>
<li class="num">4</li>
</ul>
</div>
<div class="clearfix"> </div>
</div>
</div>
<!-- container -->
</div>
<!-- contact-events -->
<!-- portfolio -->
<div class="portfolio">
<!-- container -->
<div class="container">
<h3>Gallery</h3>
<div class="gallery-images">
<div class="gallery-image">
<img src="images/3.jpg" alt="" />
<div>
<span> </span>
</div>
</div>
<div class="gallery-image">
<img src="images/4.jpg" alt="" />
<div>
<span> </span>
</div>
</div>
<div class="gallery-image right">
<img src="images/5.jpg" alt="" />
<div>
<span> </span>
</div>
</div>
<div class="gallery-image">
<img src="images/7.jpg" alt="" />
<div>
<span> </span>
</div>
</div>
<div class="gallery-image">
<img src="images/6.jpg" alt="" />
<div>
<span> </span>
</div>
</div>
<div class="gallery-image right">
<img src="images/8.jpg" alt="" />
<div>
<span> </span>
</div>
</div>
<div class="clearfix"> </div>
<div class="gallery-text">
</div>
</div>
</div>
<!-- container -->
</div>
<!-- portfolio -->
<!-- contact -->
<div id="contact" class="contact">
<!-- container -->
<div class="container">
<h3>Contact Us</h3>
<div class="col-md-7">
<div class="col-md-6">
<form>
<input type="text" class="text" value="Name" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Name';}">
<input type="text" class="text" value="Email" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email';}">
</form>
</div>
<div class="col-md-6">
<form>
<textarea value="Message:" onfocus="if(this.value == 'Message') this.value='';" onblur="if(this.value == '') this.value='Message';">Message</textarea>
</form>
</div>
<div class="clearfix"> </div>
<div class="submit-button">
<form>
<input type="submit" value="SEND">
</form>
</div>
</div>
<div class="col-md-5">
<ul>
<li> </li>
<li> </li>
<li> </li>
</ul>
</div>
<div class="clearfix"> </div>
</div>
<!-- container -->
</div>
<!-- contact -->
<div class="border-bottom"> </div>
<!-- footer -->
<div class="footer">
<div class="copyright">
<p>
Designed By : Zaryab Ali (07410)
</p>
</div>
</div>
<!-- footer -->
<script type="text/javascript">
$(document).ready(function() {
/*
var defaults = {
containerID: 'toTop', // fading element id
containerHoverID: 'toTopHover', // fading element hover id
scrollSpeed: 1200,
easingType: 'linear'
};
*/
$().UItoTop({ easingType: 'easeOutQuart' });
});
</script>
<span id="toTopHover" style="opacity: 1;"> </span>
<!-- content-Get-in-touch -->
<?php
}}}
?>
</body>
</html>
You are creating the HEAD and BODY of you page in the loop that returns results from your database.This loop should be further in your page, where you are displaying the actual results, and should show only those results.
Hi there I'm trying to get a user who comments and is logged in to their account for their 'Login Name' to display when they comment currenlty when a user wants to comment it asks for their name and their comment. Is it possible to display their name getting it from the session to display it? Thanks!
http://puu.sh/cByNU/697e58cdf6.jpg http://puu.sh/cByNU/697e58cdf6.jpg
On the image I'm logged in as 'Testing' is it possible to remove the field 'Name' and when they post a comment it will get their name where the search box is (testing).
Thanks!
My CODE:
<?php
session_start();
include "../includes/config.php";
include "function.php";
include ('../includes/header.php');
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Honda</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href='http://fonts.googleapis.com/css?family=Julius+Sans+One' rel='stylesheet' type='text/css'>
<link href="../css/style.css" rel="stylesheet" type="text/css" media="all" />
<!--start lightbox -->
<link rel="stylesheet" type="text/css" href="../css/jquery.lightbox.css">
<script src="../js/jquery.min.js"></script>
<script src="../js/jquery.lightbox.js"></script>
<script>
// Initiate Lightbox
$(function() {
$('.gallery1 a').lightbox();
});
</script>
</head>
<body>
<!--start header-->
<div class="h_bg">
<div class="wrap">
<div class="wrapper">
<div class="header">
<div class="logo">
<img src="../images/logo.png">
</div>
<div class="cssmenu">
<ul>
<li><span>Home</span></li>
<li><span>About</span></li>
<li class="active" class="has-sub"><span>Gallery</span>
</li>
<li class="last"><span>Contact</span></li>
<div class="clear"></div>
<form action="search.php" method="GET">
<div class="search">
<h2>search</h2>
<form>
<input type="text" name="query" placeholder="Enter Your search..." />
<input type="submit" value="">
</form>
</div>
</form>
<div class="search1">
<form action="" method="POST">
<br>
<h2>Welcome, <?=$_SESSION['sess_user'];?>!</h2><br><br>
<div class="pw">
<h3>Change details</h3>
</div>
<br><br>
<h2>Logout</h2>
</form>
</div>
</div>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<!-- start content -->
<div class="content_bg">
<div class="wrap">
<div class="wrapper">
<div class="main">
<div class="ser-main">
<h2 class="style">Gallery of honda</h2>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic1.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic2.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic3.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic4.jpg" alt="">
</div>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<div class="footer_bg">
<div class="wrap">
<div class="wrapper">
<div class="footer">
<div class="search69">
<?php
if(isset($_POST['submit'])
&& !empty($_POST['name'])
&& !empty($_POST['comment']) ){
$name=$_POST['name'];
$comment=$_POST['comment'];
$submit=$_POST['submit'];
$insert=mysql_query("INSERT INTO comment (name,comment) VALUES ('$name','$comment') ");
echo "<meta HTTP-EQUIV='REFRESH' content='0; url=service.php'>";
}
else
{
echo "";
}
?>
<form class="comments" action="service.php" method="POST">
<h2>Name: </h2><br><input type="text" name="name" required/><br><br>
<h2>Comment:</h2><textarea name="comment" rows="10" cols="50" required></textarea><br><br><br>
<input type="submit" name="submit" value="Comment">
</form>
<?php
$getquery=mysql_query("SELECT * FROM comment ORDER BY id DESC");
while($rows=mysql_fetch_assoc($getquery))
{
$id=$rows['id'];
$date=$rows['date'];
$name=$rows['name'];
$comment=$rows['comment'];
echo '<h2><hr size="1"/><br><font color="green">' . $name . '</font><h2><br/>' . '<br/>' . $comment . '<br/><br><font color="red">' . $date. '</font><br/>' . '<hr size="1"/>'
;}
?>
</div>
<div class="copy">
<p class="w3-link">2014 </p>
Privacy & Policy
</div>
<div class="f_nav">
<ul>
<li>Skype</li>
<li>Linked in</li>
<li>Twitter</li>
<li>Facebook</li>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
</body>
</html>
(ALL MY CODE ON THAT PAGE)
UPDATE:
The guys here will kill me, because now i am just edited your code, and not rewrite to mysqli or PDO, but as i saw, you stuck, so i've just updated, bacause i do not want to confuse with that too. I do some modifications, check my comments about that. (Moved the block of insertion to the top of file, add an error message, remove unnecesarry variables, rename the rows variable to row, etc...)
<?php
session_start();
include "../includes/config.php";
include "function.php";
include ('../includes/header.php');
//Set an empty errorMsg because later we will check it.
$errorMsg = '';
//If everything is set, or the SESSION["sess_user"] not empty.
//I moved this whole thing here, because if there are no output, we can
//redirect user from PHP, and do not need to use META REFREHS...
if (isset($_POST['submit']) && !empty($_POST['comment']) && (!empty($_POST["name"]) || !empty($_SESSION["sess_user"]))) {
if (!empty($_SESSION["sess_user"])) {
$name = $_SESSION["sess_user"];
} else {
$name = $_POST["name"];
}
//$comment = $_POST['comment']; //Use $_POST["comment"] directly
//$submit = $_POST['submit']; //Do not use it anywhere
$insert = mysql_query("INSERT INTO comment (name,comment) VALUES ('" . mysql_real_escape_string($name) . "','" . mysql_real_escape_string($_POST["comment"]) . "')");
Header("Location: service.php");
} else {
$errorMsg = "You need to fill all the fields.";
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Honda</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href='http://fonts.googleapis.com/css?family=Julius+Sans+One' rel='stylesheet' type='text/css'>
<link href="../css/style.css" rel="stylesheet" type="text/css" media="all" />
<!--start lightbox -->
<link rel="stylesheet" type="text/css" href="../css/jquery.lightbox.css">
<script src="../js/jquery.min.js"></script>
<script src="../js/jquery.lightbox.js"></script>
<script>
// Initiate Lightbox
$(function() {
$('.gallery1 a').lightbox();
});
</script>
</head>
<body>
<!--start header-->
<div class="h_bg">
<div class="wrap">
<div class="wrapper">
<div class="header">
<div class="logo">
<img src="../images/logo.png">
</div>
<div class="cssmenu">
<ul>
<li><span>Home</span></li>
<li><span>About</span></li>
<li class="active" class="has-sub"><span>Gallery</span>
</li>
<li class="last"><span>Contact</span></li>
<div class="clear"></div>
<form action="search.php" method="GET">
<div class="search">
<h2>search</h2>
<form>
<input type="text" name="query" placeholder="Enter Your search..." />
<input type="submit" value="">
</form>
</div>
</form>
<div class="search1">
<form action="" method="POST">
<br>
<h2>Welcome, <?= $_SESSION['sess_user']; ?>!</h2><br><br>
<div class="pw">
<h3>Change details</h3>
</div>
<br><br>
<h2>Logout</h2>
</form>
</div>
</div>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<!-- start content -->
<div class="content_bg">
<div class="wrap">
<div class="wrapper">
<div class="main">
<div class="ser-main">
<h2 class="style">Gallery of honda</h2>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic1.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic2.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic3.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic4.jpg" alt="">
</div>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<div class="footer_bg">
<div class="wrap">
<div class="wrapper">
<div class="footer">
<div class="search69">
<?php
//Added here the errorMsg
if (!empty($errorMsg)) {
?>
<div class="error"><?php echo $errorMsg; ?></div>
<?php
}
?>
<form class="comments" action="service.php" method="POST">
<?php
if (!empty($_SESSION['sess_user'])) {
//If user logged in, use the name of it
?>
<h2>Name: </h2><br><?php echo $_SESSION['sess_user']; ?>
<br><br>
<?php
} else {
//Else, ask it
?>
<h2>Name: </h2><br><input type="text" name="name" required/><br><br>
<?php
}
?>
<h2>Comment:</h2><textarea name="comment" rows="10" cols="50" required></textarea><br><br><br>
<input type="submit" name="submit" value="Comment">
</form>
<?php
$getquery = mysql_query("SELECT * FROM comment ORDER BY id DESC");
//This is one row, not rows
while ($row = mysql_fetch_assoc($getquery)) {
/*
* These are not necessary
$id = $rows['id'];
$date = $rows['date'];
$name = $rows['name'];
$comment = $rows['comment'];
*/
echo '<h2><hr size="1"/><br><font color="green">' . $row['name'] . '</font><h2><br/>' . '<br/>' . $row['comment'] . '<br/><br><font color="red">' . $row['date'] . '</font><br/>' . '<hr size="1"/>'
;
}
?>
</div>
<div class="copy">
<p class="w3-link">2014 </p>
Privacy & Policy
</div>
<div class="f_nav">
<ul>
<li>Skype</li>
<li>Linked in</li>
<li>Twitter</li>
<li>Facebook</li>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
</body>
</html>
NOTE: Do not use mysql functions since they are deprecated. use mysqli or PDO functions instead.
Acoid for sql injections, so escape your data!
If i got it well, you want the form to automatically gets the name of a logged user. You should:
<?php $username = isset($_SESSION['sess_user']) ? $_SESSION['sess_user'] : "";?>
To store the username or "" into $username, depending on whether user is authentified or not. Then in your input line within the form:
<h2>Name: </h2><br><input type="text" name="name" value="<?php echo $username; ?>" required/><br><br>
I am having trouble into finding the correct </vb:if> to to delete for the <vb:if condition="$show['member']"> condition. Sadly notepad++ couldn't locate the </vb:if> delete.My aim here is just to remove that if statement.
Here is the full code
<vb:if condition="$show['guest']">
<div class="guestwarn">
Hello Guest, if you reading this it means you have not yet registered. Please take a second to Click here to register and in a few simple steps, you will be able to enjoy all the features of our fine community. Register Now
</div>
</vb:if>
<vb:if condition="$show['member']">
<div id="pageWrapper"><div class="pageWrap">
<div id="topBar">
<div class="loginBox">
<div id="toplinks" class="toplinks">
<ul class="isuser">
<li>{vb:rawphrase log_out}</li>
<li>{vb:rawphrase user_control_panel}</li>
<li>{vb:rawphrase your_profile}</li>
<vb:if condition="$notifications_total">
<li class="popupmenu notifications" id="notifications">
<a class="popupctrl" href="usercp.php{vb:raw session.sessionurl_q}">{vb:rawphrase your_notifications}: <span class="notifications-number"><strong>{vb:raw notifications_total}</strong></span></a>
<ul class="popupbody popuphover">
{vb:raw notifications_menubits}
</ul>
</li>
<vb:else />
<li class="popupmenu nonotifications" id="nonotifications">
<a class="popupctrl" href="usercp.php{vb:raw session.sessionurl_q}">{vb:rawphrase your_notifications}</a>
<ul class="popupbody popuphover">
<li>{vb:rawphrase no_new_messages}</li>
<vb:if condition="$show['pmmainlink']"><li>{vb:rawphrase inbox}</li></vb:if>
</ul>
</li>
</vb:if>
<li class="welcomelink">{vb:rawphrase welcome_x_link_y, {vb:raw bbuserinfo.username}, {vb:link member, {vb:raw bbuserinfo}}}</li>
<vb:if condition="$vboptions['enablefacebookconnect']">
{vb:raw facebook_header}
</vb:if>
</ul>
{vb:raw template_hook.header_userinfo}
<vb:comment><p>{vb:rawphrase last_visited_x_at_y, {vb:raw pmbox.lastvisitdate}, {vb:raw pmbox.lastvisittime}}</p></vb:comment>
</div>
<vb:else />
<div class="loginLeft">
<!-- login form -->
<script type="text/javascript" src="clientscript/vbulletin_md5.js?v={vb:raw vboptions.simpleversion}"></script>
<form id="navbar_loginform" action="login.php?{vb:raw session.sessionurl}do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, {vb:raw show.nopasswordempty})">
<ul>
<li><div class="userBoxInput"><input type="text" class="loginInput<vb:if condition="!$username"> default-value</vb:if>" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" value="<vb:if condition="$username">{vb:raw username}<vb:else />{vb:rawphrase username}</vb:if>" /></div></li>
<li><div class="passBoxInput"><input type="password" class="loginInput" tabindex="102" name="vb_login_password" id="navbar_password" size="10" />
<input type="text" class="loginInput default-value" tabindex="102" name="vb_login_password_hint" id="navbar_password_hint" size="10" value="{vb:rawphrase password}" style="display:none;" /></div></li>
<li class="rememberMe"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" id="cb_cookieuser_navbar" class="cb_cookieuser_navbar" accesskey="c" tabindex="103" /> {vb:rawphrase remember_me}</label></li>
<li class="loginButton"><input type="image" src="{vb:stylevar imgdir_themedir}/loginButton.png" tabindex="104" value="{vb:rawphrase log_in}" title="{vb:rawphrase enter_username_to_login_or_register}" accesskey="s" /></li>
</ul>
<input type="hidden" name="s" value="{vb:raw session.sessionhash}" />
<input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
<input type="hidden" name="do" value="login" />
<input type="hidden" name="vb_login_md5password" />
<input type="hidden" name="vb_login_md5password_utf" />
</form>
<script type="text/javascript">
YAHOO.util.Dom.setStyle('navbar_password_hint', "display", "inline");
YAHOO.util.Dom.setStyle('navbar_password', "display", "none");
vB_XHTML_Ready.subscribe(function()
{
//
YAHOO.util.Event.on('navbar_username', "focus", navbar_username_focus);
YAHOO.util.Event.on('navbar_username', "blur", navbar_username_blur);
YAHOO.util.Event.on('navbar_password_hint', "focus", navbar_password_hint);
YAHOO.util.Event.on('navbar_password', "blur", navbar_password);
});
function navbar_username_focus(e)
{
//
var textbox = YAHOO.util.Event.getTarget(e);
if (textbox.value == '<vb:if condition="$username">{vb:raw username}<vb:else />{vb:rawphrase username}</vb:if>')
{
//
textbox.value='';
textbox.style.color='{vb:stylevar input_color}';
}
}
function navbar_username_blur(e)
{
//
var textbox = YAHOO.util.Event.getTarget(e);
if (textbox.value == '')
{
//
textbox.value='<vb:if condition="$username">{vb:raw username}<vb:else />{vb:rawphrase username}</vb:if>';
textbox.style.color='{vb:stylevar shade_color}';
}
}
function navbar_password_hint(e)
{
//
var textbox = YAHOO.util.Event.getTarget(e);
YAHOO.util.Dom.setStyle('navbar_password_hint', "display", "none");
YAHOO.util.Dom.setStyle('navbar_password', "display", "inline");
YAHOO.util.Dom.get('navbar_password').focus();
}
function navbar_password(e)
{
//
var textbox = YAHOO.util.Event.getTarget(e);
if (textbox.value == '')
{
YAHOO.util.Dom.setStyle('navbar_password_hint', "display", "inline");
YAHOO.util.Dom.setStyle('navbar_password', "display", "none");
}
}
</script>
<!-- / login form -->
</div>
<vb:if condition="$vboptions['enablefacebookconnect']">
<div class="loginLeft">
<ul>
{vb:raw facebook_header}
</ul>
</div>
</vb:if>
</vb:if>
</div>
<vb:if condition="$vbulletin->options['display_social_icons']==1">
<div class="socialBox">
<vb:if condition="$vbulletin->options['facebook_account']"><img src="{vb:stylevar imgdir_themedir}/iconFacebook.png" alt="Follow us on Facebook" /></vb:if>
<vb:if condition="$vbulletin->options['twitter_account']"><img src="{vb:stylevar imgdir_themedir}/iconTwitter.png" alt="Follow us on Twitter" /></vb:if>
<vb:if condition="$vbulletin->options['linkedin_account']"><img src="{vb:stylevar imgdir_themedir}/iconLinkedin.png" alt="Linked In" /></vb:if>
<vb:if condition="$vbulletin->options['flickr_account']"><img src="{vb:stylevar imgdir_themedir}/iconFlickr.png" alt="Flickr" /></vb:if>
<vb:if condition="$vbulletin->options['youtube_account']"><img src="{vb:stylevar imgdir_themedir}/iconYoutube.png" alt="Watch us on YouTube" /></vb:if>
<vb:if condition="$vbulletin->options['myspace_account']"><img src="{vb:stylevar imgdir_themedir}/iconMyspace.png" alt="My Space" /></vb:if>
<vb:if condition="$vbulletin->options['blogger_account']"><img src="{vb:stylevar imgdir_themedir}/iconBlogger.png" alt="Blogger" /></vb:if>
</div>
</vb:if>
</div>
<div class="above_body"> <!-- closing tag is in template navbar -->
<div id="header" class="floatcontainer doc_header">
<div id="headerBox">
<vb:if condition="$stylevar['titleimage']"><a name="top" href="{vb:link forumhome}" id="logo"><img src="{vb:stylevar titleimage}" alt="{vb:rawphrase x_powered_by_vbulletin, {vb:raw vboptions.bbtitle}}" /></a></vb:if>
</div>
So I'm trying to make a halfway decent login integration with MyBB, which upon success will display their avatar image in a certain area.
This is the if statement I'm using to both check the validity and display the avatar in an HTML img tag.
if (isset($mybb) && isset($mybb->user['avatar'])) {
if (substr($mybb->user['avatar'], 0, 4) = 'http') {
echo $mybb->user['avatar'];
} else {
echo('../../Forums/' . $mybb->user['avatar']);
}
}
I still don't understand what's wrong with this- I'm being thrown this up in my PHP error log:
[08-Mar-2014 23:08:46 UTC] PHP Fatal error: Can't use function return value in write context in /home/ponypwna/public_html/Login.php on line 26
Note that this PHP statement is on all one line- as displayed in the full code below:
<!DOCTYPE html>
<html>
<head>
<link href="./include/css/bootstrap.css" rel="stylesheet">
</head>
<body>
<?php
include("./include/nbar.php");
?>
<!-- Mane Area -->
<div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-2">
<br /><br /><br /><p />
<!--Login and Register Here BIG so in seperate file-->
<p>
<!--Login SUCCESS -->
<?php if($mybb->user['uid']){ ?>
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title"><span class="glyphicon glyphicon-thumbs-up"></span> Login Success</h3>
</div>
<div class="panel-body">
<div class="col-xs-6 col-md-3"><img src="<?php if (isset($mybb) && isset($mybb->user['avatar'])) { if (substr($mybb->user['avatar'], 0, 4) = 'http') { echo $mybb->user['avatar']; } else { echo('../../Forums/' . $mybb->user['avatar']); } } ?>" /></div>
You have successfully logged in as <?php echo $mybb->user['username']; ?>.
</div>
</div>
<?php } else { ?>
<!--Login DEFAULT -->
<?php if(isset($_GET['su'])){ ?>
<div style="display:none;">
<?php } else { ?>
<div class="panel panel-primary">
<?php } ?>
<div class="panel-heading">
<h3 class="panel-title"><span class="glyphicon glyphicon-th-large"></span> Login</h3>
</div>
<div class="panel-body">
<form action="../../Forums/member.php" class="ajaxform" method="post">
<div class="form-group">
<label for="exampleInputEmail1">Username:</label>
<input type="text" class="form-control" id="exampleInputEmail1" name="username" placeholder="Ex: LordNature" required>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password:</label>
<input type="password" class="form-control" id="exampleInputPassword1" name="password" placeholder="*******" required>
</div>
<input type='hidden' name='action' value='do_login'>
<input type='hidden' name='url' value='../../Login' />
<input type="submit" class="btn btn-primary" value="Login" name="submit" />
</form>
</div>
</div>
<?php } ?></p>
</div>
<div class="col-md-4">
<br /><br /><br /><p />
<b>
<div class="list-group">
<a class="list-group-item active">
<font size="4">TTT Rules</font>
</a>
<a class="list-group-item"><font size="2">1. Please obey the Staff.</a></font>
<a class="list-group-item"><font size="2">2. Do not RDM.</a></font>
<a class="list-group-item"><font size="2">3. Do not camp in T rooms for over 2 minutes.</a></font>
<a class="list-group-item"><font size="2">4. Do not harass or bully others.</a></font>
<a class="list-group-item"><font size="2">5. Do not be annoying.</a></font>
<a class="list-group-item"><font size="2">6. Do not propkill.</a></font>
<a class="list-group-item"><font size="2">7. Do not metagame.</a></font>
<a class="list-group-item"><font size="2">8. Do not hack or exploit.</a></font>
<a class="list-group-item"><font size="2">9. Do not micspam.</a></font>
<a class="list-group-item"><font size="2">10. Do not kill AFK players.</a></font>
</div></b></p>
</div>
</div>
<hr>
<?php include("./include/footer.php"); ?>
</hr>
</div> <!-- /container -->
</body>
</html>
I'm a novice to PHP, so please ignore my stupidity.
if (substr($mybb->user['avatar'], 0, 4) = 'http')
...tries to assign to the result of substr.
if (substr($mybb->user['avatar'], 0, 4) == 'http')
...is probably what you mean to do (note == (or ===) instead of =)
You can't use isset on anything else than variables, that's even in a big red box in the official documentation! This means you probably need to refactor your condition to something like
if (isset($mybb) && property_exists($mybb, "user") && array_key_exists("avatar", $mybb->user)) {