What is wrong with my php and html code? - php

<?php
include ("db.php");
session_start();
$user = $_SESSION["user"];
if (isset($_POST["submit"])) {
$target_dir = "pics/";
$target_file = $target_dir . basename($_FILES["img"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
//check if there was an error
if ($uploadOk == 0) {
echo "The file couldnt be upload, please try again";
} else {
if (move_uploaded_file($_FILES["img"]["tmp_name"], $target_file)) {
echo "The file has been uploaded";
} else {
echo "Sorry there was a error";
}
}
$img = $_FILES['img']['name'];
$title = $_POST["cardname"];
$info = $_POST["description"];
$insta = $_POST["insta"];
$snap = $_POST["snap"];
$code = $_POST["code"];
$bg = $_POST["bg"];
$discord = $_POST["discord"];
$sql = "SELECT * FROM cards WHERE code = '".$code."'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "Please pick a new id, that one is already taken";
} else {
$sql = "INSERT INTO cards (title, user, link, code, image, description, likes, snap, insta, yt, bg, discord)
VALUES ('$title', '$user', '$link', '$code', '$img', '$info', '0', '$snap', '$insta', '$user', '$bg', '$discord')";
if ($conn->query($sql) === TRUE) {
echo "New card created!";
} else {
echo "There was an error";
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="main.css">
<title>Personal cards for your social media or business | SocialCard</title>
</head>
<body>
<style>
.white {
color: white !important;
}
</style>
<div class="jumbotron">
<div class="container text-center">
<h1 class="big">Cards</h1><br>
<?php
$sql3 = "SELECT * FROM cards WHERE user = '$user'";
$result3 = $conn->query($sql3);
if($result3->num_rows > 0) {
//output cards
while($row = $result3->fetch_assoc()) {
?>
<div class="col-sm-4">
<div class="card">
<div class="card-img-top">
<img alt="" src="pics/<?php echo $img; ?>">
</div>
</div>
</div>
</div>
<?php
}
}
?>
<br>
<?php echo $_SESSION["user"]; ?>
<hr>
<div class="card">
<div class="card-body text-center">
<h4>Card Name:</h4>
<form action="" enctype="multipart/form-data" method="post">
<br>
<input type="text" name="cardname">
<br>
<br>
<h4>Profile Image:</h4>
<input type="file" name="img">
<br>
<br>
<h4>Short info:</h4>
<input type="text" name="description">
<br>
<br>
<h4>Instagram link:</h4>
<br>
<input type="text" name="insta">
<br>
<br>
<h4>Snapchat link:</h4>
<br>
<input type="text" name="snap">
<br>
<br>
<h4>Discord Tag:</h4>
<br>
<input type="text" name="discord">
<br>
<br>
<h4>Background Color:</h4>
<br>
<input type="text" name="bg" placeholder="#hexcode">
<br>
<br>
<h4>Unique Id:</h4>
<br>
<input type="text" placeholder="Create One :), remember it" name="code" required>
<br>
<br>
<button type="submit" name="submit" class="btn btn-lg btn-primary">Create Card</button>
<p>To get to your card go to: social-card.pw/view.php?code=youruniqueid</p>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="card bg-dark">
<div class="card-content white">
<h1 class="text-center font1">Purchase Premium</h1>
<p class="text-center">Nothing here yet</p>
<script data-cfasync='false' type='text/javascript' src='//p258030.clksite.com/adServe/banners?tid=258030_546328_0&type=footer&size=37'></script>
</div>
</div>
</div>
</body>
</html>
This is my current php and html code, I must of made a small error because I everytime I go to view it the only thing that shows on my screen is the jumbotron at the top with the test "card" inside it, please help me! I'm sure its just a small error that I cant find out the answer to.
Im assuming its the php code, if anyone can help that would be great.

Assuming that your query is actually retrieving the cards, the display isn't fetching the image from the returned result...
while($row = $result3->fetch_assoc()) {
?>
<div class="col-sm-4">
<div class="card">
<div class="card-img-top">
<img alt="" src="pics/<?php echo $img; ?>">
</div>
</div>
</div>
</div>
<?php
}
Using $img for the image isn't using the data from $row.
You should have something like...
echo $row['image'];
I'm also unsure if there is an extra </div> in the loop, you may need to move the last </div> outside the loop, but check this with the generated source.

Place the session_start() at the first line of page, i.e.:
session_start();
include ("db.php");
session_start(); must be started before any other line or operation.
<div class="jumbotron">
<div class="container text-center">
<h1 class="big">Cards</h1><br>
<?php
$sql3 = "SELECT * FROM cards WHERE user = '$user'";
$result3 = $conn->query($sql3);
if($result3->num_rows > 0) {
//output cards
while($row = $result3->fetch_assoc()) {
?>
<div class="col-sm-4">
<div class="card">
<div class="card-img-top">
<img alt="" src="pics/<?php echo $row['image']; ?>">
</div>
</div>
</div>
<?php
}
}
?>
Check all closing div

Related

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

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

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

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

i am trying to learn php and following a tutorial from youtube $_SESSION is driving me crazy ..i tried everything to make it work

i have declared a session_start() function in the start of both the pages but still the variable is not passing on to the session variable please help
this is where i have included my login.php
<?php
include("template/header.php");
include("template/content.php");
include("template/footer.php");
include("login.php");
?>
this my login.php file where i have passed $email variable to SESSION
<?php
session_start();
include("includes/connection.php");
if(isset($_POST['login'])){
$email= mysqli_real_escape_string($con,$_POST['email']);
$pass= mysqli_real_escape_string($con,$_POST['pass']);
$select_user = "select * from users where user_email= '$email' AND
user_pass='$pass' AND status='verified'";
$query = mysqli_query($con,$select_user);
$check_user= mysqli_num_rows($query);
if($check_user===1){
$_SESSION['usermail']=$email;
echo "<script>window.open('home.php','_self')</script>";
} else {
echo "<script>alert('incorrect details try again')</script>";
}
}
?>
and this is where i have tried to access the session variable but it says undefined:usermail but i dont understand i am giving the session_start() at the beginning and have checked that $email is successfully getting its value from the database then why this is not working
<?php
session_start();
include("includes/connection.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Welcome User!</title>
<link rel="stylesheet" href="styles/home_style.css" media="all"/>
</head>
<body>
<!--container starts-->
<div class="container">
<!--header wrapper starts here-->
<div id="head_wrap">
<!--header starts-->
<div id="header">
<ul id="menu">
<li>Home</li>
<li>Members</li>
<strong>Topics:</strong>
<?php
$get_topics = "select * from topics";
$run_topics= mysqli_query($con,$get_topics);
while($row=mysqli_fetch_array($run_topics)){
$topic_id = $row['topic_id'];
$topic_title = $row['topic_name'];
echo "<li><a href='topic.php?
topic=$topic_id'>$topic_title</a></li>";
}
?>
</ul>
<form method="get" action="results.php" id="form1">
<input type="text" name="user_query" placeholder="search a
topic"/>
<input type="submit" name="search" value="search"/>
</form>
</div><!--header ends-->
</div><!--head wrap ends-->
<!--content area starts-->
<div class="content">
<!--user timeline starts here-->
<div id="user_timeline">
<div id="user_details">
<?php
$user=$_SESSION['usermail'];
var_dump($_SESSION);
$get_user="select * from users where user_email='$user'";
$run_user= mysqli_query($con,$get_user);
$row=mysqli_fetch_array($run_user);
$user_id= $row['user_id'];
$user_name= $row['user_name'];
$user_country= $row['user_country'];
$user_image= $row['user_image'];
$register_date= $row['user_reg_date'];
$last_login= $row['user_last_login'];
$user_posts="select * from posts where user_id='$user_id'";
$run_posts = mysqli_query($con,$user_posts);
$posts =mysqli_num_rows($run_posts);
//getting the number of unread messages
$sel_msg = "select * from messages where receiver='$user_id' AND
status='unread' ORDER by 1 DESC";
$run_msg = mysqli_query($con,$sel_msg);
$count_msg = mysqli_num_rows($run_msg);
echo "
<center>
<img src='users/default.png' width='200' height='200'?>
</center>
<dev id='user_mention'>
<p><strong>Country:</strong>$user_country</p>
<p><strong>Last Login:</strong>$last_login</p>
<p><strong>Member Since:</strong>$register_date</p>
<p><a href='my_messages.php?inbox&u_id=$user_id'>Messages
($count_msg)</a></p>
<p><a href='edit_profile.php?u_id=$user_id'>Edit my account</a>
</p>
<p><a href='logout.php'>Logout</a></p>
</div>
";
?>
</div><!--user details ends here-->
</div><!--user timeline ends here-->
</div><!--content area ends-->
</div><!--container ends-->
</body>
</html>

How to avoid uploading of videos dynamically upon "refreshing" the page in browser?

Here I can upload videos successfully into database and videos are saving in appropriate folder named "uploaded". As I mentioned in question, once after uploading the video, if I refresh the browser the previously uploaded video is going saving in my database. Another question is, if I click on the video(displayed name in myvideo.php), video is not going to display instead I am getting "Object Not Found" error. I request you people to give me solutions to solve these problems. Below I am posting my code:
myvideo.php:
<div class="content">
<div class="card">
<div class="header" id="stand-fix" style="border-bottom: 1px solid #E1E1E1;">
<?php
if(isset($_POST['submit']))
{
// $conn = mysqli_connect("localhost", "root", "", "videos") or die(mysqli_error());
$name = (isset($_FILES['file']['name']) ? $_FILES['file']['name'] : '');
$temp = (isset($_FILES['file']['tmp_name']) ? $_FILES['file']['tmp_name'] : '');
move_uploaded_file($temp, "uploaded/".$name);
$url = "http://192.168.0.20/PHP/video%20upload%20and%20playback/uploaded/$name";
mysqli_query($database, "INSERT INTO video VALUE ('','$name','$url')");
}
?>
<form action="myvideo.php" method="post" enctype="multipart/form-data">
<div class="row">
<div class="col-md-7">
<h4 class="title">My Videos</h4>
</div>
<div class="col-md-3">
<input type="file" name="file" class="btn btn-primary" style="font-size: 15px;"><br />
</div>
<div class="col-md-2">
<input type="submit" name="submit" class="btn btn-primary pull-right" style="font-size: 15px;" value="Upload">
</div>
</div>
</form>
<?php
if(isset($_POST['submit']))
{
echo '<script language="javascript">';
echo 'alert("Your video has been successfully uploaded.")';
echo '</script>';
}
?>
<hr width="50%">
</div>
<div class="content" style="height: 30em; direction: ltr; overflow: auto;">
<div class="row" style="margin-left:4em;" style="direction: rtl;">
<?php
$database = mysqli_connect("localhost", "root", "", "videos") or die(mysqli_error());
$query = mysqli_query($database, "SELECT * FROM video");
while($row=mysqli_fetch_assoc($query))
{
$id = $row['id'];
$name = $row['name'];
$url = $row['url'];
echo "<p style='margin:0.5em;'><a href='watch.php?id=$id' style='color:red;'>$name</a></p><br />";
}
?>
</div>
</div>
</div>
</div>
watch.php
<?php
$conn = mysqli_connect("localhost", "root", "", "videos") or die(mysqli_error());
if(isset($_GET['id']))
{
$id = $_GET['id'];
$query = mysqli_query($conn, "SELECT * FROM video WHERE id='$id'");
while($row=mysqli_fetch_assoc($query))
{
$name = $row['name'];
$url = $row['url'];
}
echo "You are watching ".$name."<br />";
echo "<embed src='$url' width='400' height='400'></embed>";
}
else
{
echo "Error!";
}
?>
Thank You,
To avoid resubmitting the data upon page refresh. Simply redirect/refresh your page after submitting.
echo "alert('Your video has been successfully uploaded.')";
echo "window.location.href=window.location";
As Per Question on SO itself :
Please add ob_start(); in first line of php file itself.
To avoid resubmission of data/files upon page refresh, we simply need to redirect our page after submission.
Print '<script>alert("Your video has been successfully uploaded.");</script>';
Print '<script>window.location.assign("dashboard.php");</script>';
And this worked well for me. Thank you so much for your valuable time you spent on my post and for your beautiful solutions.

Can't get login feature to work

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

Categories