Jump to content

Mudsaf

Members
  • Content Count

    462
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Mudsaf

  1. So basically i have this code below on test file which works perfectly. header('Content-Type:'.'image/jpeg'); header('Content-Length: ' . filesize('E:/xampp/uploads/gallery/files/mursa_00d0ad79e535628240a4462948bf31dc.jpg')); readfile('E:/xampp/uploads/gallery/files/mursa_00d0ad79e535628240a4462948bf31dc.jpg'); But when i try to implement it on my OOP file, i assume the Content-Type gets changed automatically to html/text? Any ideas what might cause this? <?php /* Grab image file outside of webroot directory */ if (session_status() == PHP_SESSION_NONE) { session_start(); } class
  2. Yo, back with OOP related question. So if i have database connection with OOP style (example below) class MyDB { protected $con; private $db_host = "x"; //Database host private $db_user = "x"; //Database username private $db_pass = "x"; //Database user password private $db_name = "x"; //Database name public function connect() { $this->con = new mysqli($this->db_host, $this->db_user, $this->db_pass, $this->db_name); if ($this->con->connect_error) { die("Connection error, please try again later."); } else { return $this->con; } } } Is there way
  3. Got any tips for including files with OOP system? At the moment i can do like this. include_once "inc/ps.db_con.php"; include_once "inc/script.myinformation.php"; But i assume i should do ps.db_con.php call inside script.myinformation.php instead, since it always requires it. (Like below) include_once "inc/ps.db_con.php"; class MyInformation extends ConnectDB { This works if i'm in index.php file, but if i want to go subfolder it stops working. I could use "/" path, but i've always seen it as inconvenient way. Example below. include_once "/myproject/inc/ps.db_con.php"; class
  4. Encountered another problem, i edited my code alot and not sure how to access the data properly. var_dump($object->fetchUD("testuser")); This returns all data of the user, but lets say i need to access the testuser email, tried below. //var_dump($object->fetchUD("testuser")->email); Basically my class has protected properties predefined (like below) class AccountInformation extends ConnectDB { protected $username; Then i try to run public function with variable ($un), which is the username from fetchUD "testuser". public function fetchUD($un) { and at the
  5. Thanks for the help, very much appreciated! Yes i have lived here all my life 😃
  6. So currently learning a bit OOP by myself. Made this script with little knowledge i have about OOP. I tried changing public function __construct() to private/secure, but it gave me error and struggled to find real solutions how to do it as secured or private. <?php session_start(); class AccountInformation { public function __construct() { //Fetch account information, prevent premission for start if (isset($_SESSION['username'])) { if (!isset($con)) { include "inc/con.php"; } if ($res_fai = $con->prepare("SELECT firstname FROM tb_accounts WHERE username = ?
  7. Have you checked if this returns the unid() value? echo "line 106 &nbsp" . $test . "<br/>"; Just double check if everything goes through. Simplified your code for testing and worked for me. <?php function Send_mail($to){ return uniqid(); } $test = Send_mail("1"); if (isset($_POST['code']) && !empty($_POST['code'])){ $code = htmlspecialchars ($_POST['code']); } // I don't get echo good, because $test is empty. if (!empty($code)){ if ($code == $test){ echo "good"; } else{ echo "bad"; echo "<br>"; echo "line 149 &nbsp" . $co
  8. Mudsaf

    coding php send form

    And here you are using HTML <br> tags. More about making styles @: https://www.w3schools.com/css/default.asp
  9. Mudsaf

    coding php send form

    Heres example below, if you didn't understand the above one. <html> <head> <style> h2 { font-size:28px; } p { font-size:20px; } </style> </head> <body> <?php //Comment //So you echo out HTML code with tags (example below) echo "<h2>This is heading 2</h2>"; //Heading 2 --- h2 tags echo "<p>Text inside paragraph</p>"; //Paragraph tags echo "No HTML whatsoever"; //plain text ?> </body> </html>
  10. Yea, just like that & when they have selected the files, automatically upload.
  11. Hello, i'm trying to create file upload box which is activated by both, file drag & drop and onclick. Currently drag & drop works fine for me, but i have no idea how to implement the feature for the click with automatically uploading the image when file area is changed. Heres my code so far <script> $(function() { var dropzone = document.getElementById('upload_area'); var upload = function(files) { var formData = new FormData(), xhr = new XMLHttpRequest(), x; for (x = 0; x < files.length; x++) { formData.append('file[]', files[x]); } xhr.onl
  12. Hello, i'm currently facing problem where i have 2 tables like this. I have no clue how to make this happen, would appreciate any help example links for guide or solutions. //First ------- id | name | stuff 1 - Test - bla //Example values 2 - Test2 - Bla2 ------- //Second ------- id | related | rating 1 - 2 - 5 //Example values 2 - 2 - 1 3 - 2 - 2 So i'm trying to do SQL query where i can select * data from first table, and join on second table with AVG(rating) where related (second table) = id(first table).
  13. Hello, i'm wondering why my JavaScript / jQuery code doesn't work. $(function() {var i=0;$("#preimgarea").prepend("<center>");bg_imglist.forEach(function(entry) {$("#preimgarea").append("<img style='someCSS' class='setBG' id='" + i + "' src='" + entry[0] + "'>");i++;if (i == bg_imglist.length) {$("#preimgarea").append("</center>");}}); }); Basically the code pastes <center></center> then the forEach data.
  14. if (!file_exists("img/" . $_GET['remove'])) {echo "<script>console.log('Prelog');$(function() { $('#message_area').html('The file you try to remove does not exist.').fadeIn(500, function() { setTimeout(function () { console.log('Log works'); window.open('?manage=true', '_self'); }, 2000); });});</script>";} Fixed, forgot there is small script on footer.php that messed up my code. Feel like idiot now T_T
  15. No errors or notifications, added console.log("3"); before $(function() { }); and it displays.
  16. Hello, i'm wondering what could be the reason that my jQuery wont execute while echoing, but manual execution on browser console works. Code in PHP (This code will still open the window on manage=true, no errors on console) echo "<script>$(function() { $('#message_area').html('The file you try to remove does not exist.').fadeIn(500, function() { setTimeout(function () { window.open('?manage=true', '_self'); <!-- This executes, this comment is not on the code --> }, 2000); });});</script>"; Message area html below. <div id="message_area"><strong>Note</s
  17. Thanks alot, its working now (on local server).
  18. Hello, i'm wondering how my contact form requires 2 form submits until it actually submits the data. (Fill it with fake data example blaablaa@bla.com & such on to see) Preview: http://mudsaf.info/contact.php
  19. 403 forbidden should be fixed now. <a data-lightbox="d3-progress" href="http://mudsaf.info/admin/files/public/20140902_203326-4b0250793549726d5c1ea3906726ebfe-bounty_chest.jpg">Diablo 3 Progress #1</a> http://lokeshdhakar.com/projects/lightbox2/ <-- I'm using this.
  20. Do you have any idea how to fix the lightbox. It just expands the page at bottom without displaying the picture. http://mudsaf.info/ (2nd latest topic)
  21. Wondering if the problem can be that i use jQuery 2.x.x and lightbox uses 1.11.0
  22. http://mudsaf.info/ At mainpage you can see the error via inspect element.
×
×
  • Create New...