Redirect issue PHP [duplicate] - php

This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 2 years ago.
I got an image gallery crud script and decided to make the edit image page an edit profile page. My issue is what I added doesn't redirect back to profile page. Here is my code :
<?php
// Start session
session_start();
// Include and initialize DB class
require_once 'DB.class.php';
$db = new DB();
// Fetch the users data
$images = $db->getRows('images');
// Get session data
$sessData = !empty($_SESSION['sessData'])?$_SESSION['sessData']:'';
// Get status message from session
if(!empty($sessData['status']['msg'])){
$statusMsg = $sessData['status']['msg'];
$statusMsgType = $sessData['status']['type'];
unset($_SESSION['sessData']['status']);
}
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>SWARZIE</title>
<meta charset="utf-8">
<!-- Bootstrap library -->
<link rel="stylesheet" href="bootstrap/bootstrap.min.css">
<!-- Stylesheet file -->
<link rel="stylesheet" type="text/css" href="css/style.css">
<style>
.form {
width: 300px;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="container">
<h1>Image Gallery</h1>
<hr>
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#">Swarzie</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<> <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<"></a>
</li>
<li class="nav-item">
<></a>
</li>
<li class="nav-item">
<></a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-secondary my-2 my-sm-0" type="submit">Search</button>
</form>
<form class="form-inline my-2 my-lg-0">
Profile
</form>
<form class="form-inline my-2 my-lg-0">
Logout
</form>
</div>
</nav>
<?php //from ww w .j a va2 s .c om
if ( isset( $_POST["submitButton"] ) ) {
// (deal with the submitted fields here)
header( "Location: profile.php" );
exit;
} else {
displayForm();
}
function displayForm() {
?>
<!DOCTYPE html5>
<html>
<body>
<form action="profile.php">
<label for="img">Select image:</label>
<input type="file" id="img" name="img" accept="image/*">
<input type="submit">
</form>
<form action="profile.php" method="post">
<label for="firstName">First name</label>
<input type="text" name="firstName" id="firstName" value="" />
<label for="lastName">Last name</label>
<input type="text" name="lastName" id="lastName" value="" />
<textarea rows="2" cols="30" name="comment" form="usrform">
About</textarea>
<input type="submit" name="submitButton" id="submitButton" value= "Send Details" />
</form>
</body>
</html>
<?php
}
?>
<!-- Display status message -->
<?php if(!empty($statusMsg)){ ?>
<div class="col-xs-12">
<div class="alert alert-<?php echo $statusMsgType; ?>"><?php echo $statusMsg; ?></div>
</div>
<?php } ?>
<div class="row">
<div class="col-md-12 head">
<h5>Images</h5>
<!-- Add link -->
<div class="float-right">
<i class="plus"></i> New Image
</div>
</div>
<!-- List the images -->
<table class="table table-striped table-bordered">
<thead class="thead-dark">
<tr>
<th width="5%"></th>
<th width="12%">Image</th>
<th width="45%">Title</th>
<th width="17%">Created</th>
<th width="8%">Status</th>
<th width="13%">Action</th>
</tr>
</thead>
<tbody>
<?php
if(!empty($images)){
foreach($images as $row){
$statusLink = ($row['status'] == 1)?'postAction.php?action_type=block&id='.$row['id']:'postAction.php?action_type=unblock&id='.$row['id'];
$statusTooltip = ($row['status'] == 1)?'Click to Inactive':'Click to Active';
?>
<tr>
<td><?php echo '#'.$row['id']; ?></td>
<td><img src="<?php echo 'uploads/images/'.$row['file_name']; ?>" alt="" /></td>
<td><?php echo $row['title']; ?></td>
<td><?php echo $row['created']; ?></td>
<td><span class="badge <?php echo ($row['status'] == 1)?'badge-success':'badge-danger'; ?>"><?php echo ($row['status'] == 1)?'Active':'Inactive'; ?></span></td>
<td>
edit
delete
</td>
</tr>
<?php } }else{ ?>
<tr><td colspan="6">No image(s) found...</td></tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</body>
</html>
End result would have the form action(name, text area and profile upload)content to show up above the gallery crud on the profile.php file. How do I do this?
Thank you :)

Header function should be called before any output is made.
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. see more info in PHP.net
As you are calling header("Location...") after part of your html has been outputed, it will not work.
You should try moving the logic with the header(...) to the top of the file.

When you redirect to another page you should have to carry the value of $_POST with your page, otherwise you will get null of it. You can carry with session.
You can do it just before the statement where you redirect to another page, like
$_SESSION['post_data']=$_POST;
header('Location:profile.php'); exit;
Now you have posted data in the session.

Related

How do i get the ID of a product so i can display each product in Bootstrap Modal

I have a set of products in pagination in products.php , and i when i click "Details" button, i want a modal to popup and show each product Specification that i have in products_details.php.
Page Example : https://i.imgur.com/rrcXCGp.jpg
My code right now only show the 5th ID of each page.
If i am at page 1, it will show A05 of that page when i click details.
If i am at page 2, it will show A10 of that page when i click details.
Below is my products.php
<?php
include_once 'products_crud.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Paw Empire : Products</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<?php include_once 'nav_bar.php'; ?>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
<div class="page-header">
<h2>Create New Product</h2>
</div>
<form action="products.php" method="post" class="form-horizontal">
<div class="form-group">
<label for="productid" class="col-sm-3 control-label">ID</label>
<div class="col-sm-9">
<input name="pid" type="text" class="form-control" id="productid" placeholder="Product ID" value="<?php if(isset($_GET['edit'])) echo $editrow['fld_product_num']; ?>" required>
</div>
</div>
<div class="form-group">
<label for="productname" class="col-sm-3 control-label">Name</label>
<div class="col-sm-9">
<input name="name" type="text" class="form-control" id="productname" placeholder="Product Name" value="<?php if(isset($_GET['edit'])) echo $editrow['fld_product_name']; ?>" required>
</div>
</div>
<div class="form-group">
<label for="productprice" class="col-sm-3 control-label">Price (RM)</label>
<div class="col-sm-9">
<input name="price" type="number" class="form-control" id="productprice" placeholder="Product Price" value="<?php if(isset($_GET['edit'])) echo $editrow['fld_product_price']; ?>" min="0.0" step="0.01" required>
</div>
</div>
<div class="form-group">
<label for="productq" class="col-sm-3 control-label">Quantity</label>
<div class="col-sm-9">
<input name="quantity" type="number" class="form-control" id="productq" placeholder="Product Quantity" value="<?php if(isset($_GET['edit'])) echo $editrow['fld_product_quantity']; ?>" min="0" required>
</div>
</div>
<div class="form-group">
<label for="producttype" class="col-sm-3 control-label">Type</label>
<div class="col-sm-9">
<select name="type" class="form-control" id="producttype" required>
<option value="">Please select</option>
<option value="Cat" <?php if(isset($_GET['edit'])) if($editrow['fld_product_type']=="Cat") echo "selected"; ?>>Cat</option>
<option value="Cat Food" <?php if(isset($_GET['edit'])) if($editrow['fld_product_type']=="Cat Food") echo "selected"; ?>>Cat Food</option>
<option value="Cat Toys" <?php if(isset($_GET['edit'])) if($editrow['fld_product_type']=="Cat Toys") echo "selected"; ?>>Cat Toys</option>
</select>
</div>
</div>
<div class="form-group">
<label for="supplier" class="col-sm-3 control-label">Supplier</label>
<div class="col-sm-9">
<select name="supplier" class="form-control" id="supplier" required>
<option value="">Please select</option>
<option value="My Pets Library" <?php if(isset($_GET['edit'])) if($editrow['fld_product_supplier']=="My Pets Library") echo "selected"; ?>>My Pets Library</option>
<option value="Pet Lovers Centre" <?php if(isset($_GET['edit'])) if($editrow['fld_product_supplier']=="Pet Lovers Centre") echo "selected"; ?>>Pet Lovers Centre</option>
<option value="Pet Smart" <?php if(isset($_GET['edit'])) if($editrow['fld_product_supplier']=="Pet Smart") echo "selected"; ?>>Pet Smart</option>
</select>
</div>
</div>
<div class="form-group">
<label for="productshipping" class="col-sm-3 control-label">Shipping Price (RM)</label>
<div class="col-sm-9">
<input name="shipping" type="number" class="form-control" id="productshipping" placeholder="Shipping Price" value="<?php if(isset($_GET['edit'])) echo $editrow['fld_product_price']; ?>" min="0.0" step="0.01" required>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<?php if (isset($_GET['edit'])) { ?>
<input type="hidden" name="oldpid" value="<?php echo $editrow['fld_product_num']; ?>">
<button class="btn btn-default" type="submit" name="update"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Update</button>
<?php } else { ?>
<button class="btn btn-default" type="submit" name="create"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Create</button>
<?php } ?>
<button class="btn btn-default" type="reset"><span class="glyphicon glyphicon-erase" aria-hidden="true"></span> Clear</button>
</div>
</div>
</form>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2">
<div class="page-header">
<h2>Products List</h2>
</div>
<table class="table table-striped table-bordered">
<tr>
<th>Product ID</th>
<th>Name</th>
<th>Price (RM)</th>
<th>Quantity</th>
<th>Type</th>
<th>Supplier</th>
<th>Shipping Price (RM)</th>
<th></th>
</tr>
<?php
// Read
$per_page = 5;
if (isset($_GET["page"]))
$page = $_GET["page"];
else
$page = 1;
$start_from = ($page-1) * $per_page;
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("select * from tbl_products_a180834_pt2 LIMIT $start_from, $per_page");
$stmt->execute();
$result = $stmt->fetchAll();
}
catch(PDOException $e){
echo "Error: " . $e->getMessage();
}
foreach($result as $readrow) {
?>
<tr>
<td><?php echo $readrow['fld_product_num']; ?></td>
<td><?php echo $readrow['fld_product_name']; ?></td>
<td><?php echo $readrow['fld_product_price']; ?></td>
<td><?php echo $readrow['fld_product_quantity']; ?></td>
<td><?php echo $readrow['fld_product_type']; ?></td>
<td><?php echo $readrow['fld_product_supplier']; ?></td>
<td><?php echo $readrow['fld_product_shipping']; ?></td>
<td>
<button type="button" class="btn btn-warning btn-xs" data-toggle="myModal" data-target="#exampleModal">Details</button>
Edit
Delete
</td>
</tr>
<?php } ?>
</table>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2">
<nav>
<ul class="pagination">
<?php
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM tbl_products_a180834_pt2");
$stmt->execute();
$result = $stmt->fetchAll();
$total_records = count($result);
}
catch(PDOException $e){
echo "Error: " . $e->getMessage();
}
$total_pages = ceil($total_records / $per_page);
?>
<?php if ($page==1) { ?>
<li class="disabled"><span aria-hidden="true">«</span></li>
<?php } else { ?>
<li><span aria-hidden="true">«</span></li>
<?php
}
for ($i=1; $i<=$total_pages; $i++)
if ($i == $page)
echo "<li class=\"active\">$i</li>";
else
echo "<li>$i</li>";
?>
<?php if ($page==$total_pages) { ?>
<li class="disabled"><span aria-hidden="true">»</span></li>
<?php } else { ?>
<li><span aria-hidden="true">»</span></li>
<?php } ?>
</ul>
</nav>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Paw Empire : Product Details</h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script>
$('.btn-xs').on('click',function(){
$('.modal-body').load('products_details.php?pid=<?php echo $readrow['fld_product_num']; ?>',function(){
$('#myModal').modal({show:true});
});
});
</script>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
And below is my products_details.php
<?php
include_once 'database.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Paw Empire : Products Details</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<?php include_once 'nav_bar.php'; ?>
<?php
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM tbl_products_a180834_pt2 WHERE fld_product_num = :pid");
$stmt->bindParam(':pid', $pid, PDO::PARAM_STR);
$pid = $_GET['pid'];
$stmt->execute();
$readrow = $stmt->fetch(PDO::FETCH_ASSOC);
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
?>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 col-sm-5 col-sm-offset-1 col-md-4 col-md-offset-2 well well-sm text-center">
<?php if ($readrow['fld_product_image'] == "" ) {
echo "No image";
}
else { ?>
<img src="products/<?php echo $readrow['fld_product_image'] ?>" class="img-responsive">
<?php } ?>
</div>
<div class="col-xs-12 col-sm-5 col-md-4">
<div class="panel panel-default">
<div class="panel-heading"><strong>Product Details</strong></div>
<div class="panel-body">
Below are specifications of the product.
</div>
<table class="table">
<tr>
<td class="col-xs-4 col-sm-4 col-md-4"><strong>Product ID</strong></td>
<td><?php echo $readrow['fld_product_num'] ?></td>
</tr>
<tr>
<td><strong>Name</strong></td>
<td><?php echo $readrow['fld_product_name'] ?></td>
</tr>
<tr>
<td><strong>Price (RM)</strong></td>
<td>RM <?php echo $readrow['fld_product_price'] ?></td>
</tr>
<tr>
<td><strong>Quantity</strong></td>
<td><?php echo $readrow['fld_product_quantity'] ?></td>
</tr>
<tr>
<td><strong>Type</strong></td>
<td><?php echo $readrow['fld_product_type'] ?></td>
</tr>
<tr>
<td><strong>Supplier</strong></td>
<td><?php echo $readrow['fld_product_supplier'] ?></td>
</tr>
<tr>
<td><strong>Shipping Price (RM)</strong></td>
<td><?php echo $readrow['fld_product_shipping'] ?></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
You can put the block for modal inside the loop. In the modal content, you can show any content. Check the following code. (Updated)
<?php
// include_once 'products_crud.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Paw Empire : Products</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2">
<div class="page-header">
<h2>Products List</h2>
</div>
<table class="table table-striped table-bordered">
<tr>
<th>Product ID</th>
<th>Name</th>
<th>Price (RM)</th>
<th>Quantity</th>
<th>Type</th>
<th>Supplier</th>
<th>Shipping Price (RM)</th>
<th></th>
</tr>
<?php
$result = array(
array('fld_product_num' => '12345', 'fld_product_name' => 'P One','fld_product_price' => '1000'),
array('fld_product_num' => '123456', 'fld_product_name' => 'P Two','fld_product_price' => '2000')
);
foreach($result as $readrow) {
?>
<tr>
<td><?php echo $readrow['fld_product_num']; ?></td>
<td><?php echo $readrow['fld_product_name']; ?></td>
<td><?php echo $readrow['fld_product_price']; ?></td>
<td>
<button type="button" class="btn btn-warning btn-xs" data-toggle="modal" data-target="#exampleModal<?php echo $readrow['fld_product_num']; ?>">Details</button>
<div class="modal fade" id="exampleModal<?php echo $readrow['fld_product_num']; ?>" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Paw Empire : Product Details</h4>
</div>
<div class="modal-body">
<?php echo $readrow['fld_product_name']; ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" datadismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</td>
</tr>
<?php } ?>
</table>
</div>
</div>
</body>
</html>

How to Get Back in the page with unique id

I am having a problem getting back to my page with a unique id after processing a data
this first part of the code is redirecting into the page getting the unique id of the folder
<img src="<?= $row['folderimage'];?>" onerror="this.src='images/folder.png'" class="card-img-top" height="160" >
<div class="card-img">
<h6 style="text-align: center;"><?= $row['foldername'];?></h6>
this is the folder.php with unique id
<?php
require'config.php';
session_start();
if(isset($_GET['fldid'])){
$folder_id=$_GET['fldid'];
$sql="SELECT * FROM file_folder WHERE id='$folder_id'";
$result=mysqli_query($conn,$sql);
$row=mysqli_fetch_array($result);
$folder_name=$row['foldername'];
}
?>
<!DOCTYPE html>
<html>
<head>
<title>BSU</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="file.css">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" ><!-- FOR FONT AWESOME ICON-->
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"><!-- for css bootsrap 4 -->
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body class="bdy">
<div class="container-fluid">
<div class="row">
<div class="col-lg-3">
<hr>
<ul class="list-group">
<li class="list-group-item">
<div class="form-check">
<button class="btn btn-primary btn-lg btn-block" onclick="openFormfld()">Add Folde with Link</button>
</div>
</li>
<!-- para mag pop up ang add file form-->
<div class="form-popup" id="myFolderForm">
<form action="process.php" method="POST" enctype="multipart/form-data" class="form-container">
<!-- para ma notify if success or may error sa pag add ng file-->
<div style="display:<?php if(isset($_SESSION['showFilerror'])){echo $_SESSION['showFilerror'];}else { echo'none'; } unset($_SESSION['showFilerror']); ?>"
class="alert alert-danger alert-dismissible text-center mt-3">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong><?php if(isset($_SESSION['filemess'])){echo $_SESSION['filemess'];} unset($_SESSION['showFilerror']); ?></strong>
</div>
<!-- end of notif -->
<input type="hidden" name="folderid" value="<?= $folder_id; ?>">
<label for="folder"><b>Folder</b></label>
<input type="text" placeholder="Enter Folder Name" name="fldname"required>
<label for="link"><b>Link</b></label>
<input type="text" placeholder="Enter Link" name="link" required>
<label for="image"><b>Image For Folder</b></label>
<input type="file" name="image">
<button style="margin-top: 15px;" type="submit" name="folderlinkbtn" class="btn btnsub">Save</button>
Close
</form>
</div>
</ul>
</div>
<!-- para ma display ang folders -->
<div class="col-lg-9">
<!-- para ma notify pag successfull pag update-->
<div style="display:<?php if(isset($_SESSION['showAlert'])){echo $_SESSION['showAlert'];}else { echo'none'; } unset($_SESSION['showAlert']); ?>"
class="alert alert-success alert-dismissible text-center mt-3">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong><?php if(isset($_SESSION['message'])){echo $_SESSION['message'];} unset($_SESSION['showAlert']); ?></strong>
</div>
<!-- para ma notify pag hinde successfull pag update-->
<div style="display:<?php if(isset($_SESSION['showError'])){echo $_SESSION['showError'];}else { echo'none'; } unset($_SESSION['showError']); ?>"
class="alert alert-danger alert-dismissible text-center mt-3">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong><?php if(isset($_SESSION['error'])){echo $_SESSION['error'];} unset($_SESSION['showError']); ?></strong>
</div>
<!-- end of notif -->
<h5 class="text-center" id="textChange"><?= $folder_name; ?> Folder</h5>
<hr>
<div class="row" id="result">
<?php
$sql="SELECT * FROM folder_link WHERE folder_id='$folder_id'";
$result=$conn->query($sql);
while($row=$result->fetch_assoc()){
?>
<div class="col-md-3 mb-2">
<div class="card-deck">
<div style="background-color:#f3f4ed " class="card border-secondary">
<div class="btn-group">
<button style="float: right;" class="btn btn-success dropdown-toggle" id="showhidereply" data-toggle="dropdown" aria-haspopup="true" data-id="<?= $row['id'];?>"></button>
<div class="dropdown-menu" id="replycomment-<?= $row['id'];?>">
<a class="dropdown-item refold" data-id="<?= $row['id'];?>" >Rename Folder</a>
<a class="dropdown-item chgimg" data-id="<?= $row['id'];?>" >Change Folder Picture</a>
Delete Folder
</div>
</div>
<img src="<?= $row['folder_image'];?>" onerror="this.src='images/folder.png'" class="card-img-top" height="160" >
<div class="card-img">
<h6 style="text-align: center;"><?= $row['folder_name'];?></h6>
<!-- para sa update folder name pop up-->
<div class="pop-up" id="upd-<?= $row['id'];?>">
<div class="popup-content">
<form action="process.php" method="POST">
<p style="text-align: center;">Rename Folder</p>
<input type="hidden" name="idd" value="<?= $row['id'];?>">
<input class="newfold" type="text" name="updatefolder" placeholder="Enter New Folder Name" required>
Close
<button type="submit" name="updatebtnfld" class="btn popbtn">Update</button>
</form>
</div>
</div>
<!-- end sa update folder name pop up-->
<!-- para mapalitan ang image folder pop up-->
<div class="pop-up" id="img-<?= $row['id'];?>">
<div class="popup-content">
<form action="process.php" method="POST" enctype="multipart/form-data">
<p style="text-align: center;">Change Folder Iamge</p>
<input type="hidden" name="idd" value="<?= $row['id'];?>">
<input type="file" name="image" required>
Close
<button type="submit" name="updimgfld" class="btn popbtn">Update</button>
</form>
</div>
</div>
<!-- end sa update link pop up-->
</div>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
<!-- end sa folders display-->
</div>
</div>
this code below is my problem I don't what should I add in header to get me back in the page with unique id
if(isset($_POST['folderlinkbtn'])){
$fldid = $_POST['folderid'];
$fol = $_POST['fldname'];
$lin = $_POST['link'];
$image='images/'.$_FILES['image']['name'];
$target_dir="images/";
$target_file=$target_dir.basename($_FILES['image']['name']);
move_uploaded_file($_FILES['image']['tmp_name'],$target_file);
$sql="SELECT folder_id FROM folder_link WHERE folder_name ='$fol' LIMIT 1";
$check_query =mysqli_query($conn,$sql);
$count_folder = mysqli_num_rows($check_query);
if($count_folder>0){
$_SESSION['showFilerror']= 'block';
$_SESSION['filemess']="Sorry Folder Name Already Exist";
header('location:folder.php');}
else{
$sql ="INSERT INTO folder_link (folder_id,folder_links,folder_name,folder_image)VALUES('$fldid','$lin','$fol','$target_file')";
$run_query=mysqli_query($conn,$sql);
if($run_query){
$_SESSION['showAlert']= 'block';
$_SESSION['message']="Add File Successful";
header('location:folder.php');
}
else{
$_SESSION['showFilerror']= 'block';
$_SESSION['filemess']="ERROR</strong>";
header('location:folder.php');
}
}
}
if the processing requires redirecting to another page then include the unique ID in the url using GET method then include it in header function on php
I already fix the problem thanks in giving me an idea i just put
header( "Location: folder.php?fldid={$fldid}" );

How to initiate if else statement inside a td tag

In my database, I have a table column that has a filepath for images. The filepath's name is photo Some of my rows don't have a filepath. Inside my while loop forshowing the table, I would like to add a condition that if there is no filepath, it would prompt the text "User did not upload a photo yet." and when it has filepath, I can show the filepath and link it with a target blank.
This is my php file for it.
<?php require_once 'process.php';
session_start();
$role = $_SESSION['sess_userrole'];
$name = $_SESSION['sess_name'];
if(!isset($_SESSION['sess_username']) && $role!="admin"){
header('Location: index.php?err=2');
}
?>
<html>
<head>
<title>User Accounts</title>
<link rel="icon" href="isalonlogo.png">
<link rel="stylesheet" href="css2/bootstrap.min.css">
<script src="css/jquery-3.3.1.slim.min.js"></script>
<script src="css/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="css/bootstrap.min.js"></script>
</head>
<body>
<?php
if (isset($_SESSION['message'])):?>
<div class="alert alert-<?=$_SESSION['msg_type']?>">
<?php
echo $_SESSION['message'];
unset ($_SESSION['message']);?>
</div>
<?php endif ?>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<span class="navbar-brand" href=""><?php echo " " . "$name"?>, here are the Stylist user lists.</span>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li>User Lists</li>
<li><?php echo $_SESSION['sess_username'];?></li>
<li>Logout</li>
</ul>
</div>
</div>
</div>
<br> <br> <br>
<div class="container">
<?php
$mysqli = new mysqli("localhost","id7508046_root","123123123as","id7508046_isalon") or die(mysqli_error($mysqli));
$result = $mysqli->query("SELECT * FROM stylist ") or die($mysqli->error);
?>
<div class="row justify-content-center" width="80%">
<table class="table">
<thead>
<tr>
<th>UserName</th>
<th>Name</th>
<th>Image</th>
<th colspan="2">Action</th>
</tr>
</thead>
<?php
while($row = $result->fetch_assoc()): ?>
<tr>
<td><?php echo $row['username'] ?></td>
<td><?php echo $row['name'] ?></td>
// THIS PART HERE IS THE PROBLEM
<td><?php if(strcmp($row['photo'],"") == 0): {echo 'Ola';
}else:
{echo '<img src="'.$row['photo'].'">';
}
endif;
?></td>
<td>
<a href="userlist.php?edit=<?php echo $row['stylist_id']; ?>"
class="btn btn-info">Edit</a>
<a href="process.php?delete=<?php echo $row['stylist_id']; ?>"
class="btn btn-danger">Delete</a>
</td>
</tr>
<?php endwhile; ?>
</table>
</div>
<?php
function pre_r($array){
echo '<pre>';
print_r($array);
echo '</pre>';
}
?>
<br>
<br>
<div class="container justify-content-center">
<h5 class=" justify-content-center">Admin <?php echo $name;?>, create or edit an account here.</h5>
<form action="process.php" method="POST">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div class="form-group">
<label>UserName</label>
<input type="text" name="username" class="form-control" value="<?php echo $username;?>" placeholder="Enter new user Username" required>
</div>
<div class="form-group">
<label>Password</label>
<input type="text" name="password" class="form-control" value="<?php echo $password;?>" placeholder="Enter new user Password" required>
</div>
<div class="form-group">
<?php
if($update == TRUE): ?>
<button type="submit" class="btn btn-primary" name="update">Update</button>
<input type="button" class="btn btn-primary" name="reset" value="Reset" onclick="window.location.href='stylistUserlist.php'">
<?php
else: ?>
<button type="submit" class="btn btn-primary" name="save">Save</button>
<input type="button" class="btn btn-primary" name="reset" value="Reset" onclick="window.location.href='stylistUserlist.php'">
<?php
endif; ?>
</div>
</form>
</div>
</div>
</body>
Try
<td>
<?php if(!empty(trim($row['photo']))): ?>
<img src="<?php echo $row['photo'];?>"/>
<?php else: ?>
User did not upload a photo yet
<?php endif; ?>
</td>
Use below code for TD as you currently added same code in if and else both instead of using if else you can use the ternary operator.
<td>
<?php $photo = (isset($row['photo'])) ? $row['photo'] : "";
echo ($photo) ? "'. <img src=".$photo."> .'" : ""; ?>
</td>

The footer of my website's homepage isn't coming

I have been trying to make a website. It is an online shopping website.
This is my code-
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Books And Beyond</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Bootstrap styles open source -->
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" crossorigin="anonymus">
<!-- Customize styles -->
<link href="style.css" rel="stylesheet"/>
<!-- font awesome styles open source -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" crossorigin="anonymus">
<!-- Favicons -->
<link rel="shortcut icon" href="/favicon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style
type="text/css">
<!--
body {
background-image: url(assets/img/background.jpg);
}
-->
</style></head>
<body>
<!--
Upper Header Section
-->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="topNav">
<div class="container">
<div class="alignR">
<?php if (isset($_SESSION['email'])) { echo $_SESSION['email']; } else { ?>
<ul class="nav pull-right">
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#"><span class="icon-lock"></span> Login <b class="caret"></b></a>
<div class="dropdown-menu">
<form class="form-horizontal loginFrm" action="checkuser.php" method="post">
<div class="control-group">
<input name="email" type="text" class="span2" id="email" placeholder="Email">
</div>
<div class="control-group">
<input name="password" type="password" class="span2" id="password" placeholder="Password">
</div>
<div class="control-group">
<label class="checkbox">
<input type="checkbox"> Remember me
</label>
<button name="login" type="submit" class="shopBtn btn-block">Sign in</button>
</div>
</form>
</div>
</li>
</ul>
<?php } ?>
<?php if (isset($_SESSION['email'])) { ?>
Logout
<?php } else { ?>
<span class="icon-edit"></span> Register
<?php }?>
</div>
</div>
</div>
</div>
<!--
Lower Header Section
-->
<div class="container">
<div id="gototop"> </div>
<header id="header">
<div class="row">
<div class="span4">
<h1>
<a class="logo" href="index.php"><span>Books And Beyond</span>
<img src="assets/img/logo1.jpg" alt="" width="218" height="94"> </a> </h1>
</div>
</div>
</header>
<!--
Navigation Bar Section
-->
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<div class="nav-collapse">
<ul class="nav">
<li class="active">Home</li>
<li class="">About</li>
<li class="">Bargain Books</li>
<li class="">New Releases</li>
<li class="">Bestsellers</li>
<li class="">Contact Us</li>
</ul>
<ul class="nav pull-right">
</ul>
</div>
</div>
</div>
</div>
<div class="row">
<div class="span12">
<img src="assets/img/banner.jpg"/>
<hr class="soften"/>
</div>
</div>
<!--Body Section
-->
<div class="row">
<div id="sidebar" class="span3">
<div class="well well-small">
<h3> Category </h3>
<ul class="nav nav-list">
<li><span class="icon-chevron-right"></span>Fiction</li>
<li><span class="icon-chevron-right"></span>Non-Fiction</li>
<li><span class="icon-chevron-right"></span>Young Adult</li>
<li><span class="icon-chevron-right"></span>Children's</li>
<li><span class="icon-chevron-right"></span>Travel</li>
<li><span class="icon-chevron-right"></span>Education</li>
<li style="border:0"> </li>
</ul>
</div>
<!--<div class="well well-small alert alert-warning cntr">
<h2>50% Discount</h2>
<p>
only valid for online order. <br><br><a class="defaultBtn" href="#">Click here </a>
</p>
</div>-->
<!-- <div class="well well-small" ><img src="assets/img/paypal.jpg" alt="payment method paypal"></div>-->
<!--<a class="shopBtn btn-block" href="#">Upcoming products <br><small>Click to view</small></a>-->
<ul class="nav nav-list promowrapper">
<?php
/* require_once('dbconnect.php'); */
$result = mysql_query("SELECT * from product WHERE brand='accessories'");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
$price=$row["productprice"];
$productimage=$row["productimage"];
?>
<li>
<div class="thumbnail">
<img width="200" height="80" src="getImage.php?intproductid=<?php print $intproductid;?>" />
<div class="caption">
<table width="250" border="0">
<tr>
<td align="left" valign="middle"><form action="product_detail.php" method="post" name="form2" id="form2">
<label>
<input type="hidden" name="intproductid2" value="<?php echo $intproductid; ?>" />
<input name="Submit2" type="submit" class="shopBtn" value="View" />
</label>
</form></td>
<td align="right" valign="middle"><h4> <span class="pull-right"><?php echo $price; ?>.00</span></h4></td>
</tr>
</table>
</div>
</div>
</li>
<li style="border:0"> </li>
<?php } ?>
</ul>
</div>
<div class="span9">
<!--
New Products
-->
<div class="well well-small">
<h3>New Products </h3>
<hr class="soften"/>
<div class="row-fluid">
<div id="newProductcar" class="carousel slide">
<div class="">
<div class="item active">
<ul class="thumbnails">
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='bousni' LIMIT 1");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
//$productimage=$row["productimage"];
?>
<li class="span3">
<div class="thumbnail">
<img width="200" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
</div>
</li>
<?php } ?>
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='hela couture' LIMIT 1");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
//$productimage=$row["productimage"];
?>
<li class="span3">
<div class="thumbnail">
<img width="200" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
</div>
</li>
<?php } ?>
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='zey' LIMIT 1");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
//$productimage=$row["productimage"];
?>
<li class="span3">
<div class="thumbnail">
<img width="200" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
</div>
</li>
<?php } ?>
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='AL-JUMAIRA' LIMIT 1");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
//$productimage=$row["productimage"];
?>
<li class="span3">
<div class="thumbnail">
<img width="200" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
</div>
</li>
<?php } ?>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="well well-small">
<div class="span8">
<div class="row-fluid">
<h3>Features Products </h3>
<hr class="soften"/>
<ul class="thumbnails">
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='roza' LIMIT 3");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
$productname=$row["productname"];
$brand=$row["brand"];
$price=$row["productprice"];
$productimage=$row["productimage"];
?>
<li class="span4">
<div class="thumbnail">
<img width="250" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
<div class="caption cntr">
<p style="color:#990033"><?php echo $productname; ?></p>
<p><?php echo $brand; ?></p>
<p><strong>SAR <?php echo $price; ?>.00</strong></p>
<div class="btn-group">
<form id="form2" name="form2" method="post" action="product_detail.php">
<label>
<input type="hidden" name="intproductid2" value="<?php echo $intproductid; ?>" />
<input name="Submit2" type="submit" class="shopBtn" value="View" />
<input name="Submit2" type="submit" class="defaultBtn" value="Add to cart" />
</label>
</form>
</div>
<br class="clr">
</div>
</div>
</li>
<?php } ?>
</ul>
<hr class="soften"/>
<ul class="thumbnails">
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='haya' LIMIT 3");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
$productname=$row["productname"];
$brand=$row["brand"];
$price=$row["productprice"];
$productimage=$row["productimage"];
?>
<li class="span4">
<div class="thumbnail">
<img width="250" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
<div class="caption cntr">
<p style="color:#990033"><?php echo $productname; ?></p>
<p><?php echo $brand; ?></p>
<p><strong>SAR <?php echo $price; ?>.00</strong></p>
<div class="btn-group">
<form id="form2" name="form2" method="post" action="product_detail.php">
<label>
<input type="hidden" name="intproductid2" value="<?php echo $intproductid; ?>" />
<input name="Submit2" type="submit" class="shopBtn" value="View" />
<input name="Submit2" type="submit" class="defaultBtn" value="Add to cart" />
</label>
</form>
</div>
<br class="clr">
</div>
</div>
</li>
<?php } ?>
</ul>
</div>
</div>
<div class="row">
</div>
</div>
</div></div></div>
<!--
Footer
-->
<footer class="footer" style="float: bottom;">
<div class="row-fluid">
<div class="span3">
<h5>ORDER SUPPORT</h5>
Store pickup<br>
Return and Refund<br>
</div>
<div class="span3">
<h5>PRODUCT SUPPORT</h5>
FAQs<br>
Inquiry<br>
</div>
<div class="span3">
<h5>COOPORATIVE INFO</h5>
Terms and Condition <br>
Contact us<br>
</div>
<div class="span3">
<h5>GET CONNECTED</h5>
About us <br>
Create Account<br>
</div>
</div>
</footer>
</div><!-- /container -->
<div class="copyright">
<div class="container">
<p class="pull-right"> </p>
<span>Copyright 2019, Fatimatuz Johura - s201403034- Jeddah (Ladies Branch);<br> Books And Beyond</span>
</div>
</div>
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/jquery.easing-1.3.min.js"></script>
<script src="assets/js/jquery.scrollTo-1.4.3.1-min.js"></script>
<script src="assets/js/shop.js"></script>
</body>
</html>
The 'New Products' and the footer section is not coming and I cant figure out why. I dont have a webhost yet so I am using localhost for now. I have tried editing the code but whatever I do, it does not seem to work. If anyone can help, I would really appreciate it. Thank you.
On line 152 (new products is on line ~ 185[ish])
/* require_once('dbconnect.php'); */
$result = mysql_query("SELECT * from product WHERE brand='accessories'");
As I said in the comments you use this require_once('dbconnect.php'); multiple times when it should be only once at the top of your file.
The above code is the first occurrence I could find, and as it's commented out, that query is going to bomb out on you. Execution happens top to bottom and the first uncommitted occurrence of that is line 196[ish], which is way to late for that first query.
Also as I said in the comments
Try turning on Error reporting - error_reporting(-1); and ini_set('display_errors', '1'); put those right after the <?php tag
You can save yourself, and us a lot of time that way.
So in Summery,
Remove all of these require_once('dbconnect.php'); and then add just one after the opening <?php tag.
PS you can easily test this, by just commenting that first query out, or by uncommenting that first require_once.

Can't use function return value in write context

So I'm trying to make a halfway decent login integration with MyBB, which upon success will display their avatar image in a certain area.
This is the if statement I'm using to both check the validity and display the avatar in an HTML img tag.
if (isset($mybb) && isset($mybb->user['avatar'])) {
if (substr($mybb->user['avatar'], 0, 4) = 'http') {
echo $mybb->user['avatar'];
} else {
echo('../../Forums/' . $mybb->user['avatar']);
}
}
I still don't understand what's wrong with this- I'm being thrown this up in my PHP error log:
[08-Mar-2014 23:08:46 UTC] PHP Fatal error: Can't use function return value in write context in /home/ponypwna/public_html/Login.php on line 26
Note that this PHP statement is on all one line- as displayed in the full code below:
<!DOCTYPE html>
<html>
<head>
<link href="./include/css/bootstrap.css" rel="stylesheet">
</head>
<body>
<?php
include("./include/nbar.php");
?>
<!-- Mane Area -->
<div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-2">
<br /><br /><br /><p />
<!--Login and Register Here BIG so in seperate file-->
<p>
<!--Login SUCCESS -->
<?php if($mybb->user['uid']){ ?>
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title"><span class="glyphicon glyphicon-thumbs-up"></span> Login Success</h3>
</div>
<div class="panel-body">
<div class="col-xs-6 col-md-3"><img src="<?php if (isset($mybb) && isset($mybb->user['avatar'])) { if (substr($mybb->user['avatar'], 0, 4) = 'http') { echo $mybb->user['avatar']; } else { echo('../../Forums/' . $mybb->user['avatar']); } } ?>" /></div>
You have successfully logged in as <?php echo $mybb->user['username']; ?>.
</div>
</div>
<?php } else { ?>
<!--Login DEFAULT -->
<?php if(isset($_GET['su'])){ ?>
<div style="display:none;">
<?php } else { ?>
<div class="panel panel-primary">
<?php } ?>
<div class="panel-heading">
<h3 class="panel-title"><span class="glyphicon glyphicon-th-large"></span> Login</h3>
</div>
<div class="panel-body">
<form action="../../Forums/member.php" class="ajaxform" method="post">
<div class="form-group">
<label for="exampleInputEmail1">Username:</label>
<input type="text" class="form-control" id="exampleInputEmail1" name="username" placeholder="Ex: LordNature" required>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password:</label>
<input type="password" class="form-control" id="exampleInputPassword1" name="password" placeholder="*******" required>
</div>
<input type='hidden' name='action' value='do_login'>
<input type='hidden' name='url' value='../../Login' />
<input type="submit" class="btn btn-primary" value="Login" name="submit" />
</form>
</div>
</div>
<?php } ?></p>
</div>
<div class="col-md-4">
<br /><br /><br /><p />
<b>
<div class="list-group">
<a class="list-group-item active">
<font size="4">TTT Rules</font>
</a>
<a class="list-group-item"><font size="2">1. Please obey the Staff.</a></font>
<a class="list-group-item"><font size="2">2. Do not RDM.</a></font>
<a class="list-group-item"><font size="2">3. Do not camp in T rooms for over 2 minutes.</a></font>
<a class="list-group-item"><font size="2">4. Do not harass or bully others.</a></font>
<a class="list-group-item"><font size="2">5. Do not be annoying.</a></font>
<a class="list-group-item"><font size="2">6. Do not propkill.</a></font>
<a class="list-group-item"><font size="2">7. Do not metagame.</a></font>
<a class="list-group-item"><font size="2">8. Do not hack or exploit.</a></font>
<a class="list-group-item"><font size="2">9. Do not micspam.</a></font>
<a class="list-group-item"><font size="2">10. Do not kill AFK players.</a></font>
</div></b></p>
</div>
</div>
<hr>
<?php include("./include/footer.php"); ?>
</hr>
</div> <!-- /container -->
</body>
</html>
I'm a novice to PHP, so please ignore my stupidity.
if (substr($mybb->user['avatar'], 0, 4) = 'http')
...tries to assign to the result of substr.
if (substr($mybb->user['avatar'], 0, 4) == 'http')
...is probably what you mean to do (note == (or ===) instead of =)
You can't use isset on anything else than variables, that's even in a big red box in the official documentation! This means you probably need to refactor your condition to something like
if (isset($mybb) && property_exists($mybb, "user") && array_key_exists("avatar", $mybb->user)) {

Categories