Hey all!!!
Have 2 issues that fall under the same issue, instead of creating 2 topic pages back to back I thought it would be better include both here-
1. Retrieving content to be placed on Bootstrap style card:
<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
// Check if file already exists
if (file_exists($target_file)) {
echo "Sorry, file already exists.";
$uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
?>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<form action="upload.php" method="post" enctype="multipart/form-data">
<textarea rows="4" cols="50" name="comment" form="usrform">Share thoughts</textarea>
Upload Image:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>
<button type="submit" form="nameform" value="Submit">Submit</button>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span style="font-size: 48px; color: #C0C0C0;">
<i class="fas fa-camera"></i>
</span>
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<form action="upload.php" method="post" enctype="multipart/form-data">
<div class="col-lg-10">
<input type="text" name="page_url" class="form-control" id="input_url" placeholder="Page embed URL" value="<?php echo !empty($userData['_url'])?$userData['url']:''; ?>">
<input type="submit" class="btn btn-primary" name="proSubmit">
</div>
</form>
<--This booststrap card section will contain output of the forms
<div class="card hovercard">
<div class="card-body info">
<div class="title">
<a href="#"><?php echo $record['uname']; ?></a>
</div>
<div class="desc"> <a target="_blank"
href="<?php echo $record['file']; ?>"><?php echo $record['text']; ?></a></div>
<div
class="desc"><?php echo $record['url']; ?></div>
<div
</div>
</a>
</div>
</div>
2. Retrieving content to be placed on profile page:
<āUpdate section
<?php
session_start();
include "connect.php"; if(isset($_POST['edit']))
{ $id=$_SESSION['id'];
$uname=$_POST['uname'];
$bio= $_POST['bio']; $select= "select * from users where id='$id'";
$sql = mysqli_query($conn,$select);
$row = mysqli_fetch_assoc($sql); $res= $row['id'];
if($res === $id)
{
$update = "update users set uname='$uname',bio='$bio' where id='$id'";
$sql2=mysqli_query($conn,$update);if($sql2)
{
/*Successful*/
header('location:pro.php');
}
else
{
/*sorry your profile is not update*/
header('location:proedit.php');
}
}
else
{
/*sorry your id is not match*/
header('location:proedit.php');
} }?>
<?php
if(is_array($_FILES)) {
if(is_uploaded_file($_FILES['userImage']['tmp_name'])) {
$sourcePath = $_FILES['userImage']['tmp_name'];
$targetPath = "images/".$_FILES['userImage']['name'];
if(move_uploaded_file($sourcePath,$targetPath)) {
?>
<img class="image-preview" src="<?php echo $targetPath; ?>" class="upload-preview" />
<?php
}
}
}
?>
<--Edit profile section
<form id="uploadForm" action="proupdate.php" method="post">
<div id="targetLayer">No Image</div>
<div id="uploadFormLayer">
<input name="userImage" type="file" class="inputFile" /><br/>
<input type="submit" value="Submit" class="btnSubmit" />
<form action="proupdate.php" method="post">
uname: <input type="text" name="uname"><br>
bio: <input type="text" id="name" name="name" required
minlength="4" maxlength="8" size="10"><br>
<input type="submit" name="edit">
</form>
<--Section to display final results on profile page
<div class="page-content"><?php include 'proupdate.php';?></div>
Greatly appreciate any helpā¦thank ya so very much