Jump to content

Mekaboo

Members
  • Posts

    51
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Mekaboo

  1. @niche Sounds like Heaven😍. Would love to experience but my skin is so sensitive that cant be around nature long or I breakout☹️. I decided instead of doing multi query I separated the 2...this means either users can post images or post comment but not together. Its been difficult trying to combine the 2.
  2. @dsonesuk Here is my code..can you show me where to edit this so it can work: <?php $servername = "db5004526329.hosting-data.io"; $username = "dbu1026002"; $password = "meka%1981"; $database = "dbs3781610"; // Create connection $conn = new mysqli($servername, $username, $password,$database); // Check connection if (mysqli_connect_error()) { die("Database connection failed: " . mysqli_connect_error()); } echo "Connected successfully"; // define variables and set to empty values $name = $email = $gender = $comment = $website = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $comment = test_input($_POST["commentid"]); } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> Here is my while loop which is already connected to another to another. Tried to do a multi query and that didnt work. <?php require_once "db.php"; $sql = "SELECT imageId FROM output_images ORDER BY imageId DESC"; $result = mysqli_query($conn, $sql); // Loop thru comments and display all of them while($row = mysqli_fetch_array($result)) { printf("%s (%s)\n", $row["username"], $row["comment"],$row["imageId"]); ?>
  3. Hey😊 Ive added this to my site: https://www.w3schools.com/php/php_form_complete.asp and edited it to look like this: <?php // define variables and set to empty values $nameErr = $emailErr = $genderErr = $websiteErr = ""; $name = $email = $gender = $comment = $website = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["comment"])) { $comment = ""; } else { $comment = test_input($_POST["comment"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> It works great but trying to connect it to DB tables because when I test post the comments don't change. Want to store and receive so words differ per post: Comment DB Id commentid comment Thank ya🧡
  4. @niche Connect sql to proper table within DB
  5. Hey😊 Trying to use this within my code: https://www.w3schools.com/php/func_mysqli_multi_query.asp I want text to be placed within this table Comment (Id, CommentId, Comment) so every time a form is submitted new words are shown. Form: <form name="frmImage" enctype="multipart/form-data" action="" method="post" class="frmImageUpload"> <label>Upload Image File:</label><br/> <input name="userImage" type="file" class="inputFile" /><br> <label>Words:</label><br/> <input type="text" id="commentid" name="commentid"> <br><br> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> <input type="submit" value="Submit" name="submit"> </form> DB Connect(want to place extra sql in here): <?php require_once "db.php"; $sql = "SELECT imageId FROM output_images ORDER BY imageId DESC"; $result = mysqli_query($conn, $sql); // Loop thru comments and display all of them while($row = mysqli_fetch_array($result)) { printf("%s (%s)\n", $row["username"], $row["commentid"],$row["imageId"]); ?> Result code: <div class="row"> <div class="card h-100"> <h5 class="card-content"><?php echo $username;?> </h5> <p class="card-content"><?php echo $commentid;?> </p> <div class="card-footer"> <div class="card-footer"> </div> </div> </div> </div> </div> <div class="row"> <div class="card h-100"> <div class="card-header"> <h5 class="card-content"><?php echo $username;?> </h5> <p class="alert-content"><?php echo $commentid;?> </p></div> <img src="imageView.php?image_id=<?php echo $row["imageId"]; ?>" class="card-img-top" alt="..."> <div class="card-footer"> </div> Thank ya❤️
  6. Hey ☺️ 1. Form works but as far as output its image not text(comment). The echo I have in place seems not to work. Goal is to have users add an image and if they want give a description to the image all together...like a social media post. 2. Also like a social media site would like add a comment/reply section. When I try to attach it doesn't work. Could I use a simple form with a text area and echo..if so how do I attach it to the card so it will work? 3. With the loop the comment responses repeat themselves. How do I edit the loop so that a user can add a different comment(whether is solo or attached to pic) each time? Here is my code: ``` <form name="frmImage" enctype="multipart/form-data" action="" method="post" class="frmImageUpload"> <label>Upload Image File:</label><br/> <input name="userImage" type="file" class="inputFile" /> <label>Words:</label><br/> <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea> <br><br> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> <input type="submit" value="Submit" name="submit"> </form> </div> </div> </div> </div> <br> <br> <br> <br> <div class="row row-cols-1 row-cols-md-2 g-4"> <?php require_once "db.php"; $sql = "SELECT imageId FROM output_images ORDER BY imageId DESC"; $result = mysqli_query($conn, $sql); // Loop thru comments and display all of them while($row = mysqli_fetch_array($result)) { printf("%s (%s)\n", $row["username"], $row["comment"],$row["imageId"]); ?> <div class="row"> <a href="pro.php"> <div class="alert alert-secondary" role="alert"> <h5 class="card-content"><?php echo $username;?> </h5> <p class="alert-content"><?php echo $comment;?> </p> </div> </div> </div> </div> <div class="row"> <a href="pro.php"> <div class="card"> <h5 class="card-content"><?php echo $username;?> </h5> <p class="alert-content"><?php echo $comment;?> </p> <img src="imageView.php?image_id=<?php echo $row["imageId"]; ?>" class="card-img-top" alt="..."> </div> </a> </div> ``` Thank ya❤️
  7. @niche Accept this virtual hug🤗❤️ THANK YA SO VERY MUCH...IT WORKED!!!
  8. Hey☺️ Implemented a script and it works fine but want to tweak it so only one image is displayed after upload. As of now image is displayed after upload but also images previously uploaded (like a gallery). Goal is to have a singular profile image instead of a profile image gallery. Here is my code: upload.php ``` <?php // Include the database configuration file require_once 'dbConfig.php'; // If file upload form is submitted $status = $statusMsg = ''; if(isset($_POST["submit"])){ $status = 'error'; if(!empty($_FILES["image"]["name"])) { // Get file info $fileName = basename($_FILES["image"]["name"]); $fileType = pathinfo($fileName, PATHINFO_EXTENSION); // Allow certain file formats $allowTypes = array('jpg','png','jpeg','gif'); if(in_array($fileType, $allowTypes)){ $image = $_FILES['image']['tmp_name']; $imgContent = addslashes(file_get_contents($image)); // Insert image content into database $insert = $db->query("INSERT into img (image, uploaded) VALUES ('$imgContent', NOW())"); if($insert){ $status = 'success'; $statusMsg = "File uploaded successfully."; }else{ $statusMsg = "File upload failed, please try again."; } }else{ $statusMsg = 'Sorry, only JPG, JPEG, PNG, & GIF files are allowed to upload.'; } }else{ $statusMsg = 'Please select an image file to upload.'; } } // Display status message //echo $statusMsg; ?> ``` view.php ``` <?php // Include the database configuration file require_once 'dbConfig.php'; // Get image data from database $result = $db->query("SELECT image FROM img ORDER BY uploaded DESC"); ?> <div class="container"> <?php if($result->num_rows > 0){ ?> <div class="w3-container"> <?php while($row = $result->fetch_assoc()){ ?> <img src="data:image/jpg;charset=utf8;base64,<?php echo base64_encode($row['image']); ?>" /> <?php } ?> </div> <?php }else{ ?> <p class="status error">Image(s) not found...</p> <?php } ?> </div> ``` Thank ya ❤️
  9. @niche😊 I uploaded this script and implemented it: https://www.codexworld.com/store-retrieve-image-from-database-mysql-php/#google_vignette Right now it displays as a gallery but will tweak it to show as one image per upload. This makes things easy for me!! Thank ya💙
  10. Thank ya so very much for the help @niche😊
  11. Hey☺️ Would like to place this code within a grid to make it look more like a photo gallery: ``` <?php require_once "db.php"; $sql = "SELECT imageId FROM output_images ORDER BY imageId DESC"; $result = mysqli_query($conn, $sql); while($row = mysqli_fetch_array($result)) { ?> <div class="container"> <img src="imageView.php?image_id=<?php echo $row["imageId"]; ?>" /><br/> </div> ``` Right now the images look like a regular column..would prefer they be shown horizontal/vertical rather than just vertical. Thank ya💙
  12. Hey☺️ I would like to add a profile image upload on one page and have it displayed onto another within php. Having a hard time making this happen..do anyone have any suggestions? Thank ya💙
  13. Mekaboo

    Form output issue

    Hey😊 Having issue with "Comment" output showing. Everythig else works. Here is my code: ``` <form name="frmImage" enctype="multipart/form-data" action="" method="post" class="frmImageUpload"> <label>Upload Image File:</label><br/> <input name="userImage" type="file" class="inputFile" /> <label>Title/Content:</label><br/> <input type="text" name="comment"><br> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> <input type="submit" value="Submit" name="submit"> </form> <?php require_once "db.php"; $sql = "SELECT imageId FROM output_images ORDER BY imageId DESC"; $result = mysqli_query($conn, $sql); // Loop thru comments and display all of them while($row = mysqli_fetch_array($result)) { printf("%s (%s)\n", $row["username"], $row["comment"],$row["imageId"]); ?> <div class="row"> <a href="pro.php"> <div class="card"> <h5 class="card-content"><?php echo $username;?> </h5> <p><?php echo $_POST["comment"]; ?></p><br> <img src="imageView.php?image_id=<?php echo $row["imageId"]; ?>" class="card-img-top" alt="..."> </div> </a> ``` Thank ya 💜
  14. Mekaboo

    Echo a file upload

    Hey 😊 https://www.w3schools.com/php/php_file_upload.asp How do echo the image uploaded from this form so it will be displayed on the client side? Want to use this to create a simple profile pic for my sites users. I have a BLOB table within my DB that I can connect it to. Thank ya💜
  15. Sorry for the late repsonse...was feeling a tad under the weather. Thank ya so very much will make changes😊❤️
  16. Sorry about that @Ingolme [code] <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script type="text/javascript" src="js/jquery-3.2.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ windowOnScroll(); }); function windowOnScroll() { $(window).on("scroll", function(e){ if ($(window).scrollTop() == $(document).height() - $(window).height()){ if($(".post-item").length < $("#total_count").val()) { var lastId = $(".post-item:last").attr("id"); //getMoreData(lastId); } } }); } function getMoreData(lastId) { $(window).off("scroll"); $.ajax({ url: 'getMoreData.php?lastId=' + lastId, type: "get", beforeSend: function () { $('.ajax-loader').show(); }, success: function (data) { setTimeout(function() { $('.ajax-loader').hide(); $("#post-list").append(data); windowOnScroll(); }, 1000); } }); } </script> [/code]
  17. Hey all!! Uncaught ReferenceError: jQuery is not defined jQuery 2 I added the most recent JQuery(standalone and CDN) and still getting this error. How do I get rid of this please? Thank ya☺️
  18. Hey all!!! Working on creating social media timeline post system like FB. Have what I want in place but unsure of how to connect. End result is user to add what they want within the dropdown menus and the output would show within the card and people can like and comment. Also results will show on dashboard as well as profile page. I have PHP on the back end just need help on front. Here is my code: <div id="main"> <ul class="nav justify-content-center"> <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-pencil-alt"></i> </span> </a> <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-video"></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> </div> </li> </ul> </div> <div class="card hovercard" style="width:400px"> <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> <div class="comment-form-container"> <form id="frm-comment"> <div class="input-row"> <input type="hidden" name="comment_id" id="commentId" placeholder="Name" /> <input class="input-field" type="text" name="name" id="name" placeholder="Name" /> </div> <div class="input-row"> <textarea class="input-field" type="text" name="comment" id="comment" placeholder="Add a Comment"> </textarea> </div> <div> <input type="button" class="btn-submit" id="submitButton" value="Publish" /> </div> </form> </div> <div id="output"></div> Also attached how page looks online Thank ya
  19. Thank ya so very much @Ingolme!!! Wasn't getting any issue signs just a blank page. Will add your suggestion to my page as well as look into the guides you sent❤️
  20. Hello to all!! Im having an issue getting edit profile results to show up on my profile page. Here are my codes: proedit.php <div id="main"> <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> </div> proupdate.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 'pro.php'; ?>" class="upload-preview" /> <?php } } } pro.php <div id="main"> <div class="page-content"><?php include 'proupdate.php';?></div> </div> Appreciate the help☺️
  21. Hello! Can anyone recommend a simple user profile that comes with edit profile and avatar upload that uses php? I want to add one to my website? Thank ya for the help!! 💗💗, Mekaboo
  22. Thank ya kindly for responding❤️Im actually building a site using Codeigniter (PHP) which I enjoy doing, I wanted to add the profile card because I like the simpleness that it had. I couldn't find examples of how to offer an edit page for it and that is why I was seeking advice. Im taking my time and slowly learning no question about it 😊
  23. Hello! Im interested in adding the Bootstrap profile card to my site but was curious on how to create an edit page for this. I want to include avatar upload and input tags that would be used in an advanced search engine I will add to the site. Here is the link to what I what I want to use: https://www.w3schools.com/howto/howto_css_profile_card.asp Thank you for your help, Mekaboo
  24. Hello all! Im Timeka a 38 y.o. self taught coder from Washington, DC USA. In the 4 years of teaching myself Ive created sites for me and a few clients. Right now putting together a PHP member based site for someone
×
×
  • Create New...