Deleting an if condition - php

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>

Related

getting error Cannot modify header information - headers already [duplicate]

This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 2 years ago.
I am creating a project on the school management system using PHP and I am stuck as it's giving me an error: Cannot modify header information - headers already sent.
If the user forgot to fill any field and click on the submit button,the server should return a message like fill this field but instead it's giving this error and I don't know why.
this is the error I am getting
this is my form
This is my home page
<?php
session_start();
require_once 'header.php';
if(!isset($_SESSION['name']))
{
die("Access Denied");
}
if(isset($_POST['logout']))
{
header('Location: logout.php');
return;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css"
integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght#400;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght#300;400;500&display=swap" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js#2.8.0"></script>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="../management/dashboard/css/admin.css">
<link rel="stylesheet" href="../management/student/css/addstudent.css">
<link rel="stylesheet" href="../management/student/css/allstudent.css">
<link rel="stylesheet" href="../management/student/css/studentdetail.css">
</head>
<body>
<header>
<nav>
<div class="logo">
<div class="img">
<img src="./images/logo3.png" alt="">
</div>
</div>
<ul class="nav-links">
<li id="n-1">
<div class="admin">
<p>Konark Shivam</p>
<i class="fas fa-user-circle"></i>
</div>
</li>
<li id="n-2">
<i class="fas fa-envelope"></i>
</li>
<li id="n-3">
<i class="fas fa-bell"></i>
</li>
<li id="n-4">
<i class="fas fa-sign-out-alt"></i>
</li>
</ul>
<div class="burger" id="burger">
<i class="fas fa-bars"></i>
</div>
</nav>
</header>
<!-- for logout -->
<section>
<div class="logout-box" id="logout-box">
<div class="logout-content">
<p>Do you want to logout</p>
<form method="post">
<div class="logout-button">
<input type="submit" name="logout" value="Logout">
<input type="submit" name="cancel" value="Cancel" id="logout-cancel" onclick="return false">
</div>
</form>
</div>
</div>
</section>
<menu>
<div class="left-menu" id="left-menu">
<ul>
<li class="menu-items" id="menu-item-1">
Dashboard
<span class="arrow">></span>
</li >
<div class="drop-menu" id="drop-menu-1">
<ul>
<li class="drop-items">
<div class="name"></div>
<a id="d-i-admin" href="home.php?page=dashboard/admin">> Admin</a>
</li>
<li class="drop-items">
<div class="name"></div>
> Teacher
</li>
<li class="drop-items">
<div class="name"></div>
> Students
</li>
<li class="drop-items">
<div class="name"></div>
> Parents
</li>
</ul>
</div>
<li class="menu-items" id="menu-item-2">
<span>Student</span>
<span class="arrow">></span>
</li>
<div class="drop-menu" id="drop-menu-2">
<ul>
<li class="drop-items">
<div class="name"></div>
> All Students
</li>
<li class="drop-items">
<div class="name"></div>
> Student Details
</li>
<li class="drop-items">
<div class="name"></div>
> Admission Form
</li>
<li class="drop-items">
<div class="name"></div>
> Student Promotion
</li>
</ul>
</div>
<li class="menu-items" id="menu-item3">
<span>Teacher</span>
<span class="arrow">></span>
</li>
<div class="drop-menu" id="drop-menu-3">
<ul>
<li class="drop-items">
<div class="name"></div>
> Admin
</li>
<li class="drop-items">
<div class="name"></div>
> Teacher
</li>
<li class="drop-items">
<div class="name"></div>
> Students
</li>
<li class="drop-items">
<div class="name"></div>
> Parents
</li>
</ul>
</div>
<li class="menu-items">
<span>Parents</span>
<span class="arrow">></span>
</li>
<li class="menu-items">
<span>Library</span>
<span class="arrow">></span>
</li>
<li class="menu-items">
<span>Subjects</span>
<span class="arrow">></span>
</li>
<li class="menu-items">
<span>Class Routines</span>
<span class="arrow">></span>
</li>
<li class="menu-items">
<span>Attendence</span>
<span class="arrow">></span>
</li>
<li class="menu-items">
<span>Exams</span>
<span class="arrow">></span>
</li>
<li class="menu-items">
<span>Transport</span>
<span class="arrow">></span>
</li>
<li class="menu-items">
<span>Hostel</span>
<span class="arrow">></span>
</li>
<li class="menu-items">
<span>Notice</span>
<span class="arrow">></span>
</li>
<li class="menu-items">
<span>Message</span>
<span class="arrow">></span>
</li>
<li class="menu-items">
<span>Accounts</span>
<span class="arrow">></span>
</li>
</ul>
</div>
</menu>
<main>
<div class="presentation">
<div class="my-container" id="container">
<?php
if(isset($_GET['page']))
{
$page=$_GET['page'];
include_once $page.'.php';
}
else{
include_once 'dashboard/admin.php';
}
?>
</div>
</div>
</main>
<script src="script.js"></script>
</body>
</html>
this is my addstudent page
<?php
ob_start();
if(!isset($_SESSION['name']))
{
die("Access Denied");
}
require_once 'pdo.php';
if(isset($_POST['submit']))
{
if(isset($_POST['f_name']) && isset($_POST['l_name']) && isset($_POST['gender']) && isset($_POST['dob']) && isset($_POST['blood'])
&& isset($_POST['religion']) && isset($_POST['email']) && isset($_POST['address']) && isset($_POST['phone']) )
{
if(strlen($_POST['f_name'])<1)
{
$_SESSION['error']='Please enter first name';
header('Location:home.php?page=student/addstudent');
return;
}
if(strlen($_POST['l_name'])<1)
{
$_SESSION['error']='Please enter last name';
header('Location:addstudent.php');
return;
}
if(strlen($_POST['gender'])<1)
{
$_SESSION['error']='Please enter gender';
header('Location:addstudent.php');
return;
}
if(strlen($_POST['dob'])<1)
{
$_SESSION['error']='Please select date';
header('Location:addstudent.php');
return;
}
if(strlen($_POST['blood'])<1)
{
$_SESSION['error']='Please enter blood group';
header('Location:addstudent.php');
return;
}
if(strlen($_POST['religion'])<1)
{
$_SESSION['error']='Please enter religion';
header('Location:addstudent.php');
return;
}
if(strlen($_POST['email'])<1)
{
$_SESSION['error']='Please enter email';
header('Location:addstudent.php');
return;
}
else if(!strpos($_POST['email'],"#")>0)
{
$_SESSION['error']='Please enter valid email';
header('Location:addstudent.php');
return;
}
if(strlen($_POST['address'])<1)
{
$_SESSION['error']='Please Address';
header('Location:addstudent.php');
return;
}
if(is_numeric($_POST['phone'])!=1)
{
$_SESSION['error']='Please enter valid phone no';
header('Location:addstudent.php');
return;
}
else
{
$stmpt=$pdo->prepare('INSERT INTO student_detail (f_name ,l_name ,gender, dob, blood_grp, religion, email, phone, address)
VALUES ( :fn , :ln , :sx , :dob , :bld , :re , :em , :phno , :add )');
$stmpt->execute(array(
':fn'=>$_POST['f_name'],
':ln'=>$_POST['l_name'],
':sx'=>$_POST['gender'],
':dob'=>$_POST['dob'],
':bld'=>$_POST['blood'],
':re'=>$_POST['religion'],
':em'=>$_POST['email'],
':phno'=>$_POST['phone'],
':add'=>$_POST['address']
));
$_SESSION['success']='Profile added';
header("Location: addstudent.php");
return;
}
}
}
ob_end_flush();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="../student/css/addstudent.css">
</head>
<body>
<div class="container-student-3">
<div class="page-info">
<h3>Student Form</h3>
<p>Home>Student Admit form</p>
</div>
<div class="server-message">
<?php
if(isset($_SESSION['error']))
{
echo '<p style="color:red";>'.$_SESSION['error'].'</p>';
unset($_SESSION['error']);
}
if(isset($_SESSION['success']))
{
echo '<p style="color:green";>'.$_SESSION['success'].'</p>';
unset($_SESSION['success']);
}
?>
</div>
<div class="student-form-wrap">
<div class="student-form-content">
<h3>Add New Student</h3>
<form method="post">
<div class="form-inputs">
<div class="col-xl-3 col-lg-6 col-12 form-group">
<label>First Name *</label>
<input type="text" placeholder="First Name" name="f_name" class="form-control">
</div>
<div class="col-xl-3 col-lg-6 col-12 form-group">
<label>Last Name *</label>
<input type="text" placeholder="Last Name" name="l_name" class="form-control">
</div>
<div class="col-xl-3 col-lg-6 col-12 form-group">
<label>Gender *</label>
<input type="text" placeholder="Gender" name="gender" class="form-control">
</div>
<div class="col-xl-3 col-lg-6 col-12 form-group">
<label>Date Of Birth *</label>
<input type="date" placeholder="Date of Birth" name="dob" class="form-control">
</div>
<div class="col-xl-3 col-lg-6 col-12 form-group">
<label>Blood Group *</label>
<input type="text" placeholder="Blood Group" name="blood" class="form-control">
</div>
<div class="col-xl-3 col-lg-6 col-12 form-group">
<label>Religion *</label>
<input type="text" placeholder="Religion" name="religion" class="form-control">
</div>
<div class="col-xl-3 col-lg-6 col-12 form-group">
<label>E-Mail *</label>
<input type="text" placeholder="E-male" name="email" class="form-control">
</div>
<div class="col-xl-3 col-lg-6 col-12 form-group">
<label>Address *</label>
<input type="text" placeholder="Address" name="address" class="form-control">
</div>
<div class="col-xl-3 col-lg-6 col-12 form-group">
<label>Phone *</label>
<input type="text" placeholder="Phone No" name="phone" class="form-control">
</div>
<div class="col-12 form-group mg-t-8">
<input type="submit" value="submit" name="submit">
<input type="reset" value="Reset" id="reset">
</div>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
This error is displayed when the "header" method is called more than once in an execution scope.
Let's see there, in your code there are several "if" conditions, without the "else if" treatment and somehow a "header" may be being executed more than once.
I would recommend doing the form treatments in a "Controller" or in another file, if you prefer. But as the top friend commented, you can test by replacing "return" with "exit".
Remember that "header" must be called before any real output is sent, either by normal HTML tags, blank lines in a file, or by PHP.

Google captcha's size is weird

I put google's recaptcha in my site and it looks really weird when I open it, here's a picture:
my form works and all i just need the recaptcha to prevent bots from spamming or idk what. Thanks!
EDIT: better picture:
Here's my html and php code:
<?php
if (isset($_POST['g-recaptcha-response'])){
var_dump($_POST)
$ip = $_SERVER['REMOTE_ADDR'];
$captcha= $_POST['g-recaptcha-response'];
$secret = 'XXXXXXXXXX';
$respo = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secret&response=$captcha&remoteip=$ip");
if (isset($data->success) AND $data->success==true) {
} else {
}
}
?>
<html>
<head>
<title>Register</title>
<link rel="stylesheet" type="text/css" href="faggot.css">
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body style="background: url('../t2.png');height: 1700px;"> <!-- body -->
<h1 id="h1">Register</h1>
<form action="register.php" method="post" name="form1" style="background: url('../t1.png');">
<div>
<ul class="ull" id="nameull">
<br>
<br>
<br>
<br>
<div class="div">
<li class="margtop"><h2 class="tooltip" >First name<span class="red">*</span></h2></li>
<li class="margtop"><input id="fnamee" class="bax" type="text" name="fname" required="yes" pattern="^[a-z1-9]+"></li>
</div>
</ul>
<ul class="ull" style="display: inline-block;" id="lname">
<div>
<li class="margtop"><h2 class="tooltip" id="lnaam">Last name<span class="red">* </span></h2></li>
<li class="margtop"><input class="bax" type="text" name="lname" required="yes"></li>
</div>
</ul>
<br>
<br>
<br>
<br>
<br>
<br>
<ul>
</ul>
<ul class="ull" id="pwull">
<li class="margtop"><h2 class="tooltip" style="margin-right: 30px;">Password<span class="red">*</span></h2><input id="pwinput" class="bax" type="password" name="pw" required="yes"><span class="tp" id="pwinc">Password is encrypted!</span></li>
</ul>
<ul class="ull" id="usrull">
<div class="div" id="div1">
<li>
<h2 class="tooltip">Username<span class="red">*</span></h2>
<input style="margin-left: 40px;margin-top: 100px;width: 200px;" class="bax" type="text" name="uname" required="yes"><span class="tp" id="op">Only use lowercase letters!</span>
</li>
</div>
</ul>
<ul class="ull" id="emailull">
<div class="div">
<li class="margtop"> <h2 class="tooltip" id="emel">Email<span class="red">*</span></h2><input style="margin-left: 40px;margin-top: 100px;width: 300px;" class="bax" type="email" name="email" required="yes"><span class="tp" id="oep">Only one email per account!</span></li>
</div>
</ul>
<ul class="ull" style="margin-left: 500px;margin-top: 100px;display: inline-block;width: 130%;">
<li><div style="" class="g-recaptcha" data-sitekey="XXXXXXXXXXXXXX"></div></li>
</ul>
<ul>
<div class="div">
<li>
<input class="bax" id="sabmitbat" type="submit" value="submit" name="submit1">
</li>
</div>
</ul>
</table>
</form>
<script type="text/javascript" src="jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="buttonbg.js"></script>
</body>
</html>

Unable to connect phpMyAdmin database to my website

I am having trouble connecting a database i have created in phpMyAdmin to my web page using PHP. I am pretty sure my code is correct in both the html and php files and my DB and table names are correct, but when i try to use the registration form, it does nothing. I am using jQuery mobile, so have tried it with and without the data-ajax="false" attribute to no avail. What am i missing here? Thanks for any answers :) I have included the relevant html and php code below, it is the register form in the register page I am trying to connect to the DB.
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1; minimum-scale=1;">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<link href="/projects/ibill_v3/css/mainstyles.css" rel="StyleSheet"/>
<link href="/projects/ibill_v3/css/register.css" rel="StyleSheet"/>
<link href="/projects/ibill_v3/css/login.css" rel="StyleSheet"/>
<link href="/projects/ibill_v3/css/home.css" rel="StyleSheet"/>
<link href="/projects/ibill_v3/css/record_session.css" rel="StyleSheet"/>
<link href="/projects/ibill_v3/css/viewsessions.css" rel="StyleSheet"/>
<link href="/projects/ibill_v3/css/email.css" rel="StyleSheet"/>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script src="script.js"></script>
<script type='text/javascript' src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<script type='text/javascript'>
$(document).on('pageinit', function(){
$('#registerForm').validate({ // initialize the plugin
// rules & options
});
});
</script>
<script type='text/javascript'>
$(document).on('pageinit', function(){
$('.loginform').validate({ // initialize the plugin
// rules & options
});
});
</script>
</head>
<body>
<!--********************************REGISTER PAGE**********************************************-->
<!--****************************************************************************************-->
<!--********************************HEADER**********************************************-->
<div data-role="page" id="register">
<div data-role="header" data-id="foo1" data-position="fixed">
<div class='cssmenu'>
<ul>
<li class='active'><a href='#home'>Home</a></li>
<li><a href='#sessionrecord'>Record a Session</a></li>
<li><a href='#viewsessions'>View Sessions</a></li>
<li><a href='#email'>E-mail an Invoice</a></li>
</ul>
</div>
</div>
<!--********************************HEADER**********************************************-->
<!--********************************MAIN**********************************************-->
<div data-role="main" class="ui-content">
<img class="mainlogo" src="/projects/ibill_v3/img/ibill logo.png" alt="iBill Logo" width="250" height="190">
<section class="registerform">
<h1>The iBill Invoicing App for Activity Instructors</h1>
<p>Register below</p>
<form data-ajax="false" method="POST" action="register.php" >
<ul>
<li>
<label for="username">Username</label>
<input type="text" name="username" id="username" class="required" minlength="5" placeholder="enter username (min-5 characters)">
</li>
<li>
<label for="firstname">Firstname</label>
<input type="text" name="firstname" id="firstname" class="required" minlength="5" placeholder="enter firstname">
</li>
<li>
<label for="username">Surname</label>
<input type="text" name="surname" id="surname" class="required" minlength="5" placeholder="enter surname">
</li>
<li>
<label for="email">Email</label>
<input type="email" name="email" id="email" class="required email" placeholder="yourname#email.com">
</li>
<li>
<label for="password">Password</label>
<input type="password" name="password" id="password" class="required" minlength="6" placeholder="enter password">
</li>
<li>
<label for="confirmpassword">Confirm Password</label>
<input type="password" name="confirmpassword" id="confirmpassword" class="required" minlength="6" placeholder="re-enter password">
</li>
<div id="registerbutton">
<input type="submit" value="Register">
</div>
</ul>
</form>
</section>
</div>
<!--********************************MAIN**********************************************-->
<!--********************************FOOTER**********************************************-->
<div data-role="footer">
<footer class="footer">
<p>awilliams©</p>
</footer>
</div>
</div>
<!--********************************REGISTER PAGE**********************************************-->
<!--****************************************************************************************-->
<!--********************************LOGIN PAGE**********************************************-->
<!--****************************************************************************************-->
<!--********************************HEADER**********************************************-->
<div data-role="page" id="login">
<div data-role="header" data-id="foo1" data-position="fixed">
<div class='cssmenu'>
<ul>
<li class='active'><a href='#home'>Home</a></li>
<li><a href='#sessionrecord'>Record a Session</a></li>
<li><a href='#viewsessions'>View Sessions</a></li>
<li><a href='#email'>E-mail an Invoice</a></li>
</ul>
</div>
</div>
<!--********************************HEADER**********************************************-->
<!--********************************MAIN**********************************************-->
<div data-role="main" class="ui-content">
<img class="mainlogo" src="/projects/ibill_v3/img/ibill logo.png" alt="iBill Logo" width="250" height="190">
<section class="loginform">
<form action="form.php" method="post">
<ul>
<li><label for="usermail">Email</label>
<input type="email" name="usermail" placeholder="yourname#email.com" class="required"></li>
<li><label for="password">Password</label>
<input type="password" name="password" placeholder="enter password" minlength="6"></li>
<li>
<div id="loginbutton">
<input type="submit" value="Login"></li>
</div>
<div id="registerbutton">
<input type="submit" value="Register"></li>
</div>
</ul>
</form>
</section>
</div>
<!--********************************MAIN**********************************************-->
<!--********************************FOOTER**********************************************-->
<div data-role="footer">
<footer class="footer">
<p>awilliams©</p>
</footer>
</div>
</div>
<!--********************************LOGIN PAGE**********************************************-->
<!--****************************************************************************************-->
<!--********************************HOME PAGE**********************************************-->
<!--***************************************************************************************-->
<!--********************************HEADER**********************************************-->
<div data-role="page" id="home">
<div data-role="header" data-id="foo1" data-position="fixed">
<div class='cssmenu'>
<ul>
<li class='active'><a href='#home'>Home</a></li>
<li><a href='#sessionrecord'>Record a Session</a></li>
<li><a href='#viewsessions'>View Sessions</a></li>
<li><a href='#email'>E-mail an Invoice</a></li>
</ul>
</div>
</div><!-- /header -->
<!--********************************HEADER**********************************************-->
<!--********************************MAIN**********************************************-->
<div data-role="main" class="ui-content">
<img class="mainlogo" src="/projects/ibill_v3/img/ibill logo.png" alt="iBill Logo" width="250" height="190">
<section class="maincontent">
<h1>The iBill Invoicing App for Activity Instructors</h1>
<p>iBill is a cross-platform app that allows you track and manage activity sessions on the go.</p>
<br>
<p>Record an activity session to get started!</p>
<div style="text-align:center">
Record a Session
</div>
</section>
</div>
<!--********************************MAIN**********************************************-->
<!--********************************FOOTER**********************************************-->
<div data-role="footer">
<footer class="footer">
<p>awilliams©</p>
</footer>
</div>
</div>
<!--********************************FOOTER**********************************************-->
<!--********************************HOME PAGE**********************************************-->
<!--***************************************************************************************-->
<!--********************************RECORD SESSION PAGE************************************-->
<!--***************************************************************************************-->
<!--********************************HEADER**********************************************-->
<div data-role="page" id="sessionrecord">
<div data-role="header" data-id="foo1" data-position="fixed">
<div class='cssmenu'>
<ul>
<li class='active'><a href='#home'>Home</a></li>
<li><a href='#sessionrecord'>Record a Session</a></li>
<li><a href='#viewsessions'>View Sessions</a></li>
<li><a href='#email'>E-mail an Invoice</a></li>
</ul>
</div>
</div><!-- /header -->
<!--********************************HEADER**********************************************-->
<!--********************************MAIN**********************************************-->
<div data-role="main" class="ui-content">
<img class="mainlogo" src="/projects/ibill_v3/img/ibill logo.png" alt="iBill Logo" width="250" height="190">
<section class="maincontent">
<h1>Record a session using the form below</h1>
<form method="post" action="" id="sessionRecord">
<fieldset>
<select name="typeofactivity" id="typeofactivity" data-native-menu="false">
<option>Type of Session</option>
<option value="surf">Surf</option>
<option value="coast">Coasteer</option>
<option value="bodyboard">Bodyboard</option>
<option value="climbing">Cornish Challenge</option>
</select>
</fieldset>
<fieldset>
<select name="employer" id="employer" data-native-menu="false">
<option>Employer</option>
<option value="nac">Newquay Activity Centre</option>
<option value="coastline">Coastline Coasteer</option>
</select>
</fieldset>
<form method="post" action="PHP HERE!">
<label for="datetime">Date and Time of Session</label>
<input type="datetime-local" data-clear-btn="false" name="datetime" id="datetime" value="">
</form>
<form method="post" action="PHP HERE!">
<label for="amount">Amount (GBP)</label>
<input type="number" data-clear-btn="true" name="amount" id="amount" value="">
</form>
<div id="submitbutton">
<input type="submit" value="Submit">
</div>
</form>
</section>
</div>
<!--********************************MAIN**********************************************-->
<!--********************************FOOTER**********************************************-->
<div data-role="footer">
<footer class="footer">
<p>awilliams©</p>
</footer>
</div>
</div>
<!--********************************FOOTER**********************************************-->
<!--********************************RECORD SESSION PAGE************************************-->
<!--***************************************************************************************-->
<!--********************************VIEW SESSIONS PAGE************************************-->
<!--***************************************************************************************-->
<!--********************************HEADER**********************************************-->
<div data-role="page" id="viewsessions">
<div data-role="header" data-id="foo1" data-position="fixed">
<div class='cssmenu'>
<ul>
<li class='active'><a href='#home'>Home</a></li>
<li><a href='#sessionrecord'>Record a Session</a></li>
<li><a href='#viewsessions'>View Sessions</a></li>
<li><a href='#email'>E-mail an Invoice</a></li>
</ul>
</div>
</div><!-- /header -->
<!--********************************HEADER**********************************************-->
<!--********************************MAIN**********************************************-->
<div data-role="main" class="ui-content">
<img class="mainlogo" src="/projects/ibill_v3/img/ibill logo.png" alt="iBill Logo" width="250" height="190">
<section class="maincontent">
<!--MAIN CONTENT GOES HERE-->
</section>
</div>
<!--********************************MAIN**********************************************-->
<!--********************************FOOTER**********************************************-->
<div data-role="footer">
<footer class="footer">
<p>awilliams©</p>
</footer>
</div>
</div>
<!--********************************FOOTER**********************************************-->
<!--********************************VIEW SESSIONS PAGE************************************-->
<!--***************************************************************************************-->
<!--********************************EMAIL AN INVOICE PAGE************************************-->
<!--***************************************************************************************-->
<!--********************************HEADER**********************************************-->
<div data-role="page" id="email">
<div data-role="header" data-id="foo1" data-position="fixed">
<div class='cssmenu'>
<ul>
<li class='active'><a href='#home'>Home</a></li>
<li><a href='#sessionrecord'>Record a Session</a></li>
<li><a href='#viewsessions'>View Sessions</a></li>
<li><a href='#email'>E-mail an Invoice</a></li>
</ul>
</div>
</div><!-- /header -->
<!--********************************HEADER**********************************************-->
<!--********************************MAIN**********************************************-->
<div data-role="main" class="ui-content">
<img class="mainlogo" src="/projects/ibill_v3/img/ibill logo.png" alt="iBill Logo" width="250" height="190">
<section class="maincontent">
<!--MAIN CONTENT GOES HERE-->
</section>
</div>
<!--********************************MAIN**********************************************-->
<!--********************************FOOTER**********************************************-->
<div data-role="footer">
<footer class="footer">
<p>awilliams©</p>
</footer>
</div>
</div>
<!--********************************FOOTER**********************************************-->
<!--********************************EMAIL AN INVOICE PAGE************************************-->
<!--***************************************************************************************-->
</body>
<?php
$servername = "localhost";
$username = "root";
$password = "cornwall";
$con=mysqli_connect('localhost','root','cornwall','ibill');
// This code creates a connec'tion to the MySQL database in PHPMyAdmin named 'ibill':
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// The connection is then checked, if it fails, an echo is sent back to the page stating a connection error.
$username = $_POST['username'];
$firstname = $_POST['firstname'];
$surname = $_POST['surname'];
$emailaddress = $_POST['emailaddress'];
$password = $_POST['password'];
$confirmpassword = $_POST['confirmpassword'];
//These are the different PHP variables that store my posted data.
$register="INSERT INTO user_details (username, firstname, surname, emailaddress, password,) VALUES ('$username', '$firstname', '$surname', '$emailaddress', '$password')";
echo $register;
$result=mysqli_query($con, $register);
//This is the query that will be sent to the MySQL server.
header('Location: http://localhost/projects/ibill_v3/html/main.html#login');
exit();
//This directs the user to the relevant page after successful registration.
?>
First of all, read this article about SQL injection: How can I prevent SQL injection in PHP?.
There is an error in you SQL query. In your PHP file, replace this line:
$result=mysqli_query($con, $register);
with this:
if(mysqli_query($con,$register) === FALSE){
echo mysqli_error($con);
}
To display errors in PHP code, add these lines:
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
Ref: How do I get PHP errors to display?

Website repeating in a loop after PHP is applied for data retrieval

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.

If else statement displays as two strings: [closed]

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>

Categories