Jump to content

Search the Community

Showing results for tags 'php'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH


  • Community Calendar




Website URL








Found 843 results

  1. Update The PHP Tutorial To Use PHP 7 And It's Features
  2. BACKGROUND: I have created a PHP routine that gathers data from a MySQL database. The data that it gathers depends on the value of an HTTP request that uses the $_GET superglobal as its transfer mechanism. The routine further organizes the retrieved information into a nested array such that each element of the array corresponds to a different table row, and each element of each nested array corresponds to a subset of the table fields. Once the nested array has been completed the json_encode() function converts the array into a JSON string and readies it for transport. The PHP <?php if(isset($_GET['podType']) { define('_HOST_NAME','...'); define('_DATABASE_NAME','...'); define('_DATABASE_USER_NAME','...'); define('_DATABASE_PASSWORD','...'); $mysqli_obj = new MySQLi(_HOST_NAME,_DATABASE_USER_NAME,_DATABASE_PASSWORD,_DATABASE_NAME); if($mysqli_obj->connect_errno) { die("ERROR : -> ".$mysqli_obj->connect_error); } $tbl_name = 'rss2_podcast_item'; $podcast_items = []; $result_obj = $mysqli_obj->query("SELECT * FROM " . $tbl_name); while($row = $result_obj->fetch_assoc()) { foreach($row as $key => $value) { $item_arr[$key] = $value; } $items[] = $item_arr; } //Creates a nested array whose subarrays consist of the four indicated elements. foreach ($items as $sub_arr => $element) { $podcast_item[] = $element['podcast_no_item']; $podcast_item[] = $element['item_title']; $podcast_item[] = $element['item_description']; $podcast_item[] = $element['item_pubdate']; $podcast_items[] = $podcast_item; $podcast_item = []; } echo json_encode($podcast_items, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_NUMERIC_CHECK); } ?> The Javascript <script> $(document).ready(function() { $('li.podDex').each(function(){ var podType = $(this).attr('id'); //Causes the weight of the font to change when the mouse passes over the text. $('#'+podType).mouseover(function() { $(this).css({"cursor": "pointer", "font-weight":"800"}); }) .mouseout(function() { $(this).css("font-weight", "normal"); }); //Causes the weight of the font to change, displays the hidden text to appear in the #main <div> element, and brings about a change in color. $('#'+podType).mouseover(function() { $(this).css({"cursor": "pointer", "font-weight":"800"}); }) .click(function() { $.getJSON({ url: "../exp1/ajax_data.php", data: podType, success: function(json_data){ var data_array = $.parseJSON(json_data); alert(data_array[0]['podcast_no_item']); } }); }) .mouseup(function() { $(this).css({"color": "#fadb9d","font-weight": "normal"}); $('body, html').animate({scrollTop: $('#main').offset().top},800); }); }); }); </script> The HTML <ul> <li id='linear' class='podDex'>Linear Analysis</li> <li id='clausal' class='podDex'>Clausal Analysis</li> <li id='inversion' class='podDex'>Socratic Inversion</li> <li id='chronology' class='podDex'>Chronology</li> </ul> The Console Error Message is You are welcome to try it yourself. Please go to Grammar Captive and click on any of the four designated <li> elements. QUESTION: What might be causing the $.getJSON() call to fail? NOTE: A similar, but not identical, result occurs on my local test server.
  3. Path to Downloading Attachment

    Hello, I have a problem with my code.. I cant do download attachments, when I click in attachment "image.jpg", the link appears this way "www.site.com/image.jpg" but the link doesn't existed, and go to automatically to my home page without download the file.. $id = $_POST['id']; $pdo = new PDO("sqlite:mydb.db"); $email = $pdo->query("SELECT * FROM `myemails` WHERE `id`='$myid'")->fetch(PDO::FETCH_ASSOC); $email_body = base64_decode($email['message']); $letter_html = ""; $op_getKey = preg_match_all("/boundary=\"(.*)\"/", $email_body, $getKey); $has_attachment = preg_match_all("/multipart\/mixed/", $email_body, $attachment); if ($op_getKey) { if ($has_attachment) { $mailParts = explode("--" . $getKey[1][1], $email_body); $attachParts = explode("--" . $getKey[1][0], $email_body); $get_attach_name=preg_match_all("/filename=\"(.*?)\"/", $attachParts[2], $attach_name); $get_attach_type=preg_match_all("/Content-Type: (.*?);/", $attachParts[2], $attach_type); $pure_code = explode("\n\n",$attachParts[2]); $pure_code = str_replace("\r","",$pure_code[1]); $pure_code = str_replace("\n","",$pure_code); }else{ $mailParts = explode("--" . $getKey[1][0], $email_body); } Can you give me some help implementing this code in my code? $savedir = __DIR__ . '/attachment/'; $myemail = $email->search('ALL'); if ($myemail ) { rsort($myemail ); foreach ($myemail as $my2email) { foreach ($my2email->getAttachments() as $attachment) { $savepath = $savedir . $attachment->getFilename(); file_put_contents($savepath, $attachment); } } } So that it is possible, whenever you receive an email, that the file go to the "attachment" folder and can download the image or file .. When I click in attachment and I just wanted that's possible to download the image, pdf, txt, zip, rar, etc.. once they are saved in the attachment folder. I already called the attachment of these two forms, but nothing.. PHP Code: <a target="_blank" href="https://site.com/<?=$attach_name[1][0]?>" data-target="<?=$id?>"><?=$attach_name[1][0]?></a> <a target="_blank" href="data:<?=$attach_type[1][0]?>;base64,<?=$pure_code?>"> <?=$attach_name[1][0]?> </a> I don't know if u understand my problem. Best Regards
  4. Hello folks, I want to hide a text inside a image(users given image using file upload). Thanks in advance
  5. Read Multiple Rows Sequentially

    QUESTION ONE: What is it called when you traverse an entire table in equal multiples of records? (I ask this question, because I have been fraught with frustration in my google searches.) QUESTION TWO: Do you know a routine that I can copy and modify? (This would greatly simply my search.) BACKGROUND: Surely there must be a standard routine for performing the following procedure: 1) Use PHP to read and display the first ten records of a MySQL table. 2) Read and display the next ten records of the same data table. 3) Either return to the previously read ten records and display these or continue on to the following ten unread records and display them. 5) When you have reached the end of the table display only the remaining records. GOAL: Ultimately I would like to read and display 10 records in a list format. At the bottom of the list I would place two buttons. One that displays the previously 10 records and one that displays the next ten unread records. WHAT I HAVE ACHIEVED SO FAR: <?php $col_name = 'item_pubdate'; $result_obj = $mysqli_obj->query("SELECT * FROM rss2_podcast_item ORDER BY '$col_name' LIMIT 0, 10"); while($row=$result_obj->fetch_array()) { ?> <div class='table_row podcast_item'> <div class='flex_item num_div'><?php echo $row['podcast_no_item'] . '&nbsp'; ?></div> <div class='flex_item date_div'><?php echo $row['item_pubdate']; ?></div> <div class='flex_item title_div'><?php echo $row['item_title']; ?></div> </div><!-- end div.table_row --> <div class='table_row discover_div'> <div class='flex-item'>Discover more ...</div> </div><!-- end div.table_row --> <div class='table_row'> <div class='flex-item details_div'> <?php echo $row['item_description']; ?> </div><!-- end div.table_row --> </div><!-- end div.table_row --> <?php } ?> With a little additional CSS and Javascript I have been able to achieve the following display. Clicking on the phrase "Discover more ..." reveals the hidden detail obtained from $row['item_description]. No. Publication Date|Time Podcast Title 60 2017-06-19 17:26:41 Title Ten Discover more ... 59 2017-06-18 09:50:37 Title Nine Discover more ... . . . 51 2017-09-24 11:00:17 Title One Discover more ... DESIRE: If I can only achieve the above stated goal, I can likely figure out a way to get AJAX to allow users to select podcast items by the week, month, year, and later category. But, this is already much too far into the future. For the moment, I would simply like to achieve my above stated goal. Any ideas? Roddy
  6. Please consider the following two sets of code. Are they not identical in their functionality? BACKGROUND: I am troubled by the following set of code, for it intertwines PHP and HTML in a way that, for me, is neither intuitive, nor reasonable based on my limited knowledge of how PHP and HTML work. This said, it appears to work. <?php if(isset($_GET['edit'])) { ?> <button type="submit" name="update">update</button> <?php } else { ?> <button type="submit" name="save">save</button> <?php } ?> ANALYSIS: Had I written the code I would have felt compelled to enter the <button> elements as part of PHP echo statements. QUESTION: Is this proper coding technique? Roddy
  7. From PHP to JavaScript with Node.js

    Hi! I'm Vincent from Matters. I am transitioning from PHP to JavaScript. I wanted to give back to the community so I wrote an article about it: https://blog.matters.tech/migrating-from-php-to-javascript-with-node-js-155534498b58 I hope it will be useful to some! Feedback warmly welcome https://twitter.com/cold_lestat
  8. The CodexWorld DB Class

    <?php /* * DB Class * This class is used for database related (connect, insert, update, and delete) operations * @author CodexWorld.com * @url http://www.codexworld.com * @license http://www.codexworld.com/license */ class DB{ private $dbHost = "..."; private $dbUsername = "..."; private $dbPassword = "..."; private $dbName = "..."; public function __construct(){ if(!$this->db){ // Connect to the database $conn = new mysqli($this->dbHost, $this->dbUsername, $this->dbPassword, $this->dbName); if($conn->connect_error){ die("Failed to connect with MySQL: " . $conn->connect_error); }else{ $this->db = $conn; } } } /* * Returns rows from the database based on the conditions * @param string name of the table * @param array select, where, order_by, limit and return_type conditions */ public function getRows($table,$conditions = array()){ $sql = 'SELECT '; $sql .= array_key_exists("select",$conditions)?$conditions['select']:'*'; $sql .= ' FROM '.$table; if(array_key_exists("where",$conditions)){ $sql .= ' WHERE '; $i = 0; foreach($conditions['where'] as $key => $value){ $pre = ($i > 0)?' AND ':''; $sql .= $pre.$key." = '".$value."'"; $i++; } } if(array_key_exists("order_by",$conditions)){ $sql .= ' ORDER BY '.$conditions['order_by']; } if(array_key_exists("start",$conditions) && array_key_exists("limit",$conditions)){ $sql .= ' LIMIT '.$conditions['start'].','.$conditions['limit']; }elseif(!array_key_exists("start",$conditions) && array_key_exists("limit",$conditions)){ $sql .= ' LIMIT '.$conditions['limit']; } $result = $this->db->query($sql); if(array_key_exists("return_type",$conditions) && $conditions['return_type'] != 'all'){ switch($conditions['return_type']){ case 'count': $data = $result->num_rows; break; case 'single': $data = $result->fetch_assoc(); break; default: $data = ''; } }else{ if($result->num_rows > 0){ while($row = $result->fetch_assoc()){ $data[] = $row; } } } return !empty($data)?$data:false; } } $test = new DB(); if ($test instanceof DB) { echo 'Instantiated'; } else { echo 'Uninstantiated. Include failed.'; } $conditions = []; $tbl_name = 'rss2_podcast_item'; $test->getRows($tbl_name, $conditions); function getRows($mysqli_obj, $table,$conditions = array()){ $sql = 'SELECT '; $sql .= array_key_exists("select",$conditions)?$conditions['select']:'*'; $sql .= ' FROM '.$table; if(array_key_exists("where",$conditions)){ $sql .= ' WHERE '; $i = 0; foreach($conditions['where'] as $key => $value){ $pre = ($i > 0)?' AND ':''; $sql .= $pre.$key." = '".$value."'"; $i++; } } if(array_key_exists("order_by",$conditions)){ $sql .= ' ORDER BY '.$conditions['order_by']; } if(array_key_exists("start",$conditions) && array_key_exists("limit",$conditions)){ $sql .= ' LIMIT '.$conditions['start'].','.$conditions['limit']; }elseif(!array_key_exists("start",$conditions) && array_key_exists("limit",$conditions)){ $sql .= ' LIMIT '.$conditions['limit']; } $result = $mysqli_obj->query($sql); if(array_key_exists("return_type",$conditions) && $conditions['return_type'] != 'all'){ switch($conditions['return_type']){ case 'count': $data = $result->num_rows; break; case 'single': $data = $result->fetch_assoc(); break; default: $data = ''; } }else{ if($result->num_rows > 0){ while($row = $result->fetch_assoc()){ $data[] = $row; } } } return !empty($data)?$data:false; } ?> <?php $tbl_name = 'rss2_podcast_item'; $conditions = []; print_r(getRows($mysqli_obj,$tbl_name,$conditions)); ?> Please find above two sets of code and a quoted error message from the first set. The first set of code is a portion of a PHP class called DB. The second set of code is extracted from the first and modified in order to test the integrity of the function. At the bottom of each block of code is included the code necessary to call the getRows() method/function. Whereas the method of the class fails, the extracted function does not. In both cases the same database and table are accessed with success. I am suspicious of the way in which the class is constructed. I have tried several modifications, but none of them appear to work. Roddy
  9. BACKGROUND: Please go to the following webpage and note four different ways to fill the center section. 1) The center section is loads with the rest of the page as the content of <div id='main'> 2) The center is replaced with hidden content already on the page using jQuery's html( ) function. (Click in the navigation panel on the phrase "Form, Use, and Meaning'.) 3) The center is replaced with a portion of content from another page using jQuery's load( ) function. (Click in the navigation panel on the phrase "Words, Phrases, and Clauses".) 4) The center will be replaced with its original content, but without having to reload the page. The principle is the same as in Item 2, but the link mechanism is different. (Click on the host's image.) DILEMMA: I want to fill the same section with an HTML-formatted template filled with information from a data base that opens simultaneously with the page. CONSTRAINTS: 1) The host page for the content -- namely, podcasts_dev_copy.php is structurally complete. Any changes that I make to it should be minor. 2) The content of the middle section must be filled invisibly before the host page opens, or it must fill simultaneously with the host page. RESOURCES: 1) I have developed a PHP page that takes information sent to it from a 3rd party HTTP request, downloads data from a database that is based on the request, and opens to the host page with a portion of the processed information using a $_SESSION superglobal and the PHP header( ) function and location property. (This page has not been posted.) 2) A template engine that generates the replacement content from the same $_SESSION superglobal Have you got any ideas? Roddy

    QUESTION: What does it mean when the value of the QUERY_STRING looks like the following without end? &width=1920&height=1200&width=1920&height=1200&... Roddy
  11. How to auto create a new page based on inputs

    My school asked me for a website where they can post their pictures on. Pictures from camp/city trips etc. I said that I never build a website before, but I would like to try it. So I googled and googled, then almost a week later I have this (code is below the text) I still have one problem: I have a login page which can be accessed by the teachers, I have a upload button and a name field, so every time when they have new pictures they can upload them and choose a name. But there isn't happening anything with the data. Is it possible that it automatically creates a page based on a tamplate with the before indicated input? I read something about get and post, but I have no idea how I could use that. I also read something about MySQL, but I have absolutely no idea how I could use something like that. So my question: How can I automatically create a new page, based on the input from another page. This is the website: http://thorbeckefotos.tk/ In the top right corner is a small login button, if you press the botton, you go to the login page (username: user password: password) if you continu you see the page that can be accessed by the teachers. Tamplate code: <!DOCTYPE html> <html> <head> <title>Thorbecke foto's</title> </head> <link rel="icon" href="images/logos/thorbecke.png"> <body link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF"> <img src="images/Banner.png"> <a href="https://twitter.com/ThorbeckeSG"> <img src="images/logos/twitter.png" style="position:absolute; top: 5px; right: 153px;"></a> <a style="position:absolute; top: 12px; right: 20px;" href="https://twitter.com/ThorbeckeSG">Thorbecke Twitter</a> <a href="http://www.thorbecke-zwolle.nl"> <img src="images/logos/thorbecke.png" style="position:absolute; top: 37px; right: 163px"></a> <a style="position:absolute; top: 42px; right: 40px;" href="https://www.thorbecke-zwolle.nl">Thorbecke Site</a> <a href="https://www.youtube.com/channel/UCcGO0gpLrWdWMxmycPjh7Bg"> <img src="images/logos/youtube.png" style="position:absolute; top: 70px; right: 153px"></a> <a style="position:absolute; top: 72px; right: 5px;" href="https://www.youtube.com/channel/UCcGO0gpLrWdWMxmycPjh7Bg">Thorbecke YouYube</a> <a href="contact/index.php"> <img src="images/logos/contact.png" style="position:absolute; top: 92px; right: 153px"></a> <a style="position:absolute; top: 100px; right: 92px;" href="../contact/index.php">Contact</a> <br> <br> <br> </body> <link href='style.css' rel='stylesheet'> <ul> <li><a href="../index.htm">Home</a></li> <li><a>2017/18</a> <ul> <li><a href="Examenreis_Berlijn.htm">Examenreis Berlijn</a></li> <li><a href="Examenreis_Londen.htm">Examenreis Londen</a></li> <li><a href="Examenreis_Parijs.htm">Examenreis Parijs</a></li> <li><a href="Disco.htm">Disco klas 1</a></li> <li><a href="Biodag.htm">Biodag 3M</a></li> <li><a href="Introductie.htm">Introductie klas 3/4M</a></li> </ul> </li> <li><a>2016/17</a> <ul> <li><a href="../2016,17/Werkweek.htm">Werkweek</a></li> <li><a href="../2016,17/Grote_Avond.htm">Grote Avond</a></li> <li><a href="../2016,17/Skiereis.htm">Skireis</a></li> <li><a href="../2016,17/Diploma_uitreiking_Atheneum.htm">Diploma uitreiking Atheneum</a></li> <li><a href="../2016,17/Diploma_uitreiking_Havo.htm">Diploma uitreiking Havo</a></li> <li><a href="../2016,17/Diploma_uitreiking_Mavo.htm">Diploma uitreiking Mavo</a></li> <li><a href="../2016,17/Galaklas2.htm">Gala klas 2</a></li> <li><a href="../2016,17/Examenreizen.htm">Examenreizen</a></li> <li><a href="../2016,17/Brugklasdisco.htm">Brugklasdisco</a></li> <li><a href="../2016,17/Introductie.htm">Introductie klas 1M/H/A 3M 4A</a></li> <li><a href="../2016,17/Open_Dag.htm">Open Dag</a></li> </ul> </li> <li><a>2015/16</a> <ul> <li><a href="../2015,16/Diploma_uitreiking_Atheneum.htm">Diploma uitreiking Atheneum</a></li> <li><a href="../2015,16/Diploma_uitreiking_Havo.htm">Diploma uitreiking Havo</a></li> <li><a href="../2015,16/Diploma_uitreiking_Mavo.htm">Diploma uitreiking Mavo</a></li> <li><a href="../2015,16/Ijsverkoop_onioth.htm">Ijsverkoop Onioth</a></li> <li><a href="../2015,16/Onioth_kamp.htm">Onioth kamp</a></li> <li><a href="../2015,16/Werkweek.htm">Werkweek</a></li> <li><a href="../2015,16/Talendorp.htm">Talendorp</a></li> <li><a href="../2015,16/Skiereis.htm">Skireis</a></li> <li><a href="../2015,16/Going_Global.htm">Going Global</a></li> <li><a href="../2015,16/Open_Dag.htm">Open Dag</a></li> </ul> </li> <li><a>2014/15</a> <ul> <li><a href="../2014,15/kerstdinner.htm">Kerstdinner 4/5H</a></li> <li><a href="../2014,15/Munster.htm">Münster</a></li> <li><a href="../2014,15/Gala_klas_2.htm">Gala klas 2</a></li> <li><a href="../2014,15/Grote_Avond.htm">Grote Avond</a></li> <li><a href="../2014,15/Lisabon.htm">Lissabon</a></li> <li><a href="../2014,15/Londen.html">Londen</a></li> <li><a href="../2014,15/parijs.htm">Parijs</a></li> <li><a href="../2014,15/Barcelona.htm">Barcelona</a></li> <li><a href="../2014,15/Auditie_Grote_Avond.htm">Auditie Grote Avond</a></li> <li><a href="../2014,15/Stadshangenrun.htm">Stadshagenrun</a></li> </ul> </li> </ul> <br> <br> <br> <br> <center> <h1>Disco klas 1 2017/18</h1> <img src="images/Disco/breed001.jpg"> <img src="images/Disco/breed002.jpg"> <img src="images/Disco/breed003.jpg"> <img src="images/Disco/breed004.jpg"> <img src="images/Disco/breed005.jpg"> <img src="images/Disco/breed006.jpg"> <img src="images/Disco/breed007.jpg"> <img src="images/Disco/breed008.jpg"> <img src="images/Disco/breed009.jpg"> <img src="images/Disco/breed010.jpg"> <img src="images/Disco/breed011.jpg"> <img src="images/Disco/breed012.jpg"> <img src="images/Disco/breed013.jpg"> <img src="images/Disco/breed014.jpg"> <img src="images/Disco/breed015.jpg"> </center> <footer><h2><a font color="white" href="*download_url*">Download</h2></font></a> <h5>Gemaakt door Martijn Schuman</h5> <h5> Copyright 2017 All rights reserved. </h5> </footer> </html> Upload page code: <?php // Start the session ob_start(); session_start(); // Check to see if actually logged in. If not, redirect to login page if (!isset($_SESSION['loggedIn']) || $_SESSION['loggedIn'] == false) { header("Location: index.php"); } ?> <html> <head> <title>Thorbecke fotos upload</title> </head> <link rel="icon" href="images/logos/thorbecke.png"> <link href='style.css' rel='stylesheet'> <body> <img src="images/Banner.png"> </body> <form method="post" action="logout.php"> <input type="submit" value="Logout"><br> </form> <h2>Op deze pagina kan u een nieuwe activiteit aanmaken en foto's uploaden.</h2> <label for="activiteit">Activiteit:</label><br/> <input type="activiteit" placeholder="Activiteit"><br/> <br> <form action="upload.php" method="post" enctype="multipart/form-data"> <input type="file" name="files[]" multiple> <input type="submit" value="Upload"> </form> </html>
  12. Hello everyone I want to make a login page and I want to connect it with loptop or mobile fingerprint scanner and people can login with their fingerprint. Can anyone help me what should I do?
  13. University exam exercise

    Hi!! The day after tomorrow I've a HTML exam... Would you mind help me with this exercise?? I couldn't find the way to do it looking to the tutorials.. but if there is, and I missed it, let me now!! Create a HTML index.html containing a form: - with 2 text boxes to insert the name and the lastname; - a Submit button which sends the datas inserted by the user to a script php named namecontrol.php. Create a PHP page which has to visualize the datas sent from the form, as a list.
  14. Hello, I have a variable ($post) that contains posted content from database. Now I want to select the first paragraph and insert a code after it (Ads precisely ). Here is my code <?php include "../modules/gfuncs.php"; $topicId=(int)$_GET['id']; #check if topic exists $q=$conn->query("SELECT * FROM topics WHERE id='$topicId'") or die( $conn->error ); if(mysqli_num_rows($q)==0){ header("location: $thisDomain/notfound"); exit; } #check for post $c4p=$conn->query("SELECT * FROM posts WHERE topicid=$topicId") or die($conn->error); if(mysqli_num_rows($c4p)==0){ $delpost=$conn->query("DELETE FROM topics WHERE id=$topicId") or die($conn->error); header("location:$thisDomain/notfound"); exit; } #new comment $notify=""; $err=""; if(isset($_POST['post']) and isLoggedIn()){ $msg=$_POST['msg']; $fid=(int)$_POST['fid']; $thisdate=time(); $error=array(); #if user uploads attachment if($_FILES['attach']['size']>0){ $thumb=$_FILES['attach']; $thumbtmp=$thumb['tmp_name']; $thumbname=$thumb['name']; $thumbsize=$thumb['size']; $targetDir="thumbs/$thumbname"; $ext=pathinfo($targetDir, PATHINFO_EXTENSION); $allowed=array("jpg","gif","png"); if(!in_array($ext, $allowed)){ $error[]="Invalid thumbnail format"; } elseif($thumbsize > 2097152){ $error[]="Thumbnail size exceeded limit"; } } if(!$msg or empty($msg)){ $error[]="Please enter a comment"; } elseif( strlen($msg)<3){ $error[]="Comment too short"; } if(count($error)==0){ $newAttachName=""; if($_FILES['attach']['size']>0){ $newAttachName=encrypt(time()*rand(), 15).".jpg"; @move_uploaded_file($thumbtmp, "thumbs/$newAttachName"); } $save=$conn->query("INSERT INTO posts SET topicid=$topicId, forumid=$fid, poster='$curUser', postdate=$thisdate, post='$msg', attachment='$newAttachName'") or die($conn->error); $notify='<div class="successHolder">Comment Successfully Added!</div>'; } else { $err=implode(",<br>", $error); $notify='<div class="errorHolder">'.$err.'</div>'; } } $load=mysqli_fetch_object($q); $forumid=$load->forumid; $subject=_read($load->subject); $subjext=$load->subject; $poster=$load->poster; $views=$load->views; #update views $newviews=$views+1; $updviews=$conn->query("UPDATE topics SET views=$newviews WHERE id=$topicId") or die($conn->error); $postdate=$load->postdate; $postdate=date("d, M Y.", $postdate); $lastposter=$load->lastposter; $lastpostdate=$load->lastpostdate; $locked=$load->locked; $attachment=$load->attachment; #load forum info $fq=$conn->query("SELECT * FROM forums WHERE forumid=$forumid") or die($conn->error); $ft=mysqli_fetch_object($fq); $forumName=$ft->forumname; $forumUrl="$thisDomain/forum/$forumid/".urlize($forumName); #count posts $postCount=$conn->query("SELECT * FROM posts WHERE topicid=$topicId") or die( $conn->error); $totalPosts=mysqli_num_rows($postCount); #pagination $limit=13; $pagination= new paging; $pagination->totalResults($totalPosts); $pagination->rows_per_page($limit); $page=@$_GET['page']; $pagination->page($page); $pagination->thisPage("$thisDomain/forum/$forumid/topic/$topicId/".urlize($subjext)); $paging=$pagination->paging(); $paging.="<span class=\"tp\">Page ".$pagination->currentPage()." of ".$pagination->totalPages()."</span>"; $anotif=""; $adminMenu=""; if($isAdmin){ if(isset($_POST['adminAct'])){ $time=time(); $act=$_POST['admin_act']; if($act=="tag_topic"){ $qt=$conn->query("SELECT * FROM updates WHERE media='topic' AND media_id='$topicId'") or die($conn->error); if(mysqli_num_rows($qt)==0){ $qaa=$conn->query("INSERT INTO updates SET media='topic', media_id=$topicId, updatetime=$time") or die($conn->error); $anotif='<div class="successHolder">Topic successfully tagged to homepage</div>'; } else { $anotif='<div class="errorHolder">Topic is already in updates</div>'; } } elseif($act="untag_topic"){ $qaa=$conn->query("DELETE FROM updates WHERE media='topic' AND media_id=$topicId") or die($conn->error); $anotif='<div class="successHolder">Topic successfully removed from updates</div>'; } elseif($act=="del_topic"){ $qaa=$conn->query("DELETE FROM topics WHERE id=$topicId") or die($conn->error); $delPost=$conn->query("DELETE FROM posts WHERE topicid=$topicId") or die($conn->error); $delFromUpdates=$conn->query("DELETE FROM updates WHERE media='topic' AND media_id=$topicId") or die($conn->error); header("location:$thisDomain/forum"); exit; } elseif($act=="edit_topic"){ header("location:$thisDomain/forum/topiceditor"); exit; } } $adminMenu="<div class=\"ContentX\"><form method=\"post\" action=\"\">"; #TAGGING: check if topic is tagged or not $qt=$conn->query("SELECT * FROM updates WHERE media='topic' AND media_id='$topicId'") or die($conn->error); if(mysqli_num_rows($qt)==0){ $adminMenu.=" <input type=\"radio\" name=\"admin_act\" value=\"tag_topic\"> Tag Topic"; } else { $adminMenu.=" <input type=\"radio\" name=\"admin_act\" value=\"untag_topic\"> Untag Topic"; } $adminMenu.=" <input type=\"radio\" name=\"admin_act\" value=\"del_topic\"> Delete Topic"; $adminMenu.=" <input type=\"radio\" name=\"admin_act\" value=\"edit_topic\"> Edit Topic <button type=\"submit\" name=\"adminAct\" class=\"w3-btn\">Submit</button></form></div>"; } #resend query to initiate paging $postQ=$conn->query("SELECT * FROM posts WHERE topicid=$topicId ORDER BY id ASC LIMIT $pagination->offset,$pagination->rows_per_page") or die($conn->error); #load all posts $contents=""; $postMenu=""; while($loadp=mysqli_fetch_object($postQ)){ $postid=$loadp->id; $poster=$loadp->poster; $postdate=$loadp->postdate; $postAttach=$loadp->attachment; $post=""; if($postAttach){ $post='[img]'.$thisDomain.'/forum/thumbs/'.$postAttach.'[/img]'; } $post.=$loadp->post; $post=_bbcode(_read($post)); #get user info $usr=new userinfo; $usr->user($poster); $posterDP=$usr->get_info("dp"); $posterCity=$usr->get_info("city"); $posterState=$usr->get_info("state"); $postdate=date("g:ia, jS M Y.", $postdate); if($isAdmin){ $postMenu="\n<br>[<a href=\"$thisDomain/forum/editpost/$postid\">Edit Post</a>] / [<a href=\"$thisDomain/forum/delpost/$postid\">Delete Post</a>]"; } $contents.=<<<eof <div class="aPost"> <table class="info"> <tr> <td width="75"> <img src="$thisDomain/user/dps/$posterDP" height="70" width="70" id="infoDP"> </td> <td> <a href="$thisDomain/profile/$poster"><span class="fa fa-user"></span> $poster</a>. $posterCity, $posterState<br> <span class="fa fa-pencil"></span> $postdate </tr> </table> <div class="msgBody"> $post </div>$postMenu </div> eof; } $pageTitle=$subject; include "../header.php"; ?>
  15. Encoding PHP code

    Hello guys I need a software or a site that is free or cheap not like Zend guard and stuff it is about 600$ but I need something free or till 50$. I want to encode my PHP codes in a good way and it will be hard to encode it actually 99% of people should could't decode it. Thanks
  16. BACKGROUND: Ever since I realized that the $_SESSION superglobal was the future of my podcast page (two-three days ago) I have been diligently exploring the PHP SESSION extension. It is amazing what I discovered. In particular, I am impressed by the tenacity of a user created session and the associated $_SESSION superglobal. Indeed, using the session_write_close( ) function one can not only close a browser window, quit one's browser, open the same page in a new browser, but one can also reboot one's machine, and still, the values of the session variables contained in the $_SESSION superglobal associated with the user_created session are in tact. QUESTION: To where does the session_write_close( ) function write such that it is forever saved, and how does one purge that location short of destroying the entire file, if the location's contents are not unique to the session whose data it is storing?
  17. Hi, I'm new to PHP and WEB site construction. I have input data in a MySQL database and I want to produce some stickers with some data elements with a Dymo LabelWriter 450. Is it possible? and if it is, is there someone can tell me where I can find some program example to see how to proceed. Thanks in advance! Richard G.
  18. Subir archivo en la misma página

    Estoy subiendo un archivo csv en una página llamada procesar, el problema es que me hace un POST y me envía a otra página y me muestra el resultado de ¡La importación del archivo se subió satisfactoriamente!, pero yo necesito que eso me lo muestre en la misma página. Éste es el código que tengo. <script type="text/javascript" > $(function(){ $("#btnEnviar").click(function(){ $("#cuerpoPagina").load('procesar.php',$("#frmAsignar").serialize()); }) }); function subirArchivoExcel() { if (document.frmSubirArchivo.excel.value == "") { alert("¡Error!. ¡Debe subir un archivo!"); document.frmSubirArchivo.excel.focus(); return false; } document.frmSubirArchivo.action="procesar.php"; document.frmSubirArchivo.submit(); } </script> <?php echo '<form name="frmSubirArchivo" action"procesar.php" method="post" enctype="multipart/form-data"> <table border="1" id="TablaFormularioOpaco"> <tr> <td aling="center" id="TituloTablaVerde">Archivo excel</td> </tr> <tr> <td><input type="file" name="excel" /> </td> </tr> <tr> <td><input type="button" name="btnEnviar" id="btnEnviar" value="Subir Archivo" onclick="subirArchivoExcel();" ></td> </tr> </form>'; Ahora acá es el resto del código: include 'Conexion.php'; if (isset($_FILES['excel']) && !empty($_FILES['excel']) && substr($_FILES['excel']['name'],-3)=="csv") { $fecha = date('Y-m-d'); $hora = time("HH:MM:SS"); $carpeta = "Ejemplo"; $carpeta = ""; $excel = $fecha."-".$hora."-".$_FILES['excel']['name']; move_uploaded_file($_FILES['excel']['tmp_name'], "$carpeta$excel"); //echo "$carpeta$excel"; //print_r($_FILES); $contador = 0; $row = 1; $fp = fopen("$carpeta$excel", "r"); $meses = array( 'ENERO' => '01', 'FEBRERO' => '02', 'MARZO' => '03', 'ABRIL' => '04', 'MAYO' => '05', 'JUNIO' => '06', 'JULIO' => '07', 'AGOSTO' => '08', 'SEPTIEMBRE' => '09', 'OCTUBRE' => '10', 'NOVIEMBRE' => '11', 'DICIEMBRE' => '12'); //echo $dias; //fgetcsv. obtiene los valores que estan en el csv y los extrae while ($data = fgetcsv($fp, 1000, ";")) { //Si la línea es igual a 5 no guardamos porque serian los títulos de la hoja de excel if ($row >= 7) { //print_r("<pre>Row: ".$row); //print_r($data); //print_r("</pre>"); // TEXTO: jueves, 01 de junio de 2017 21:38 $laFecha = explode(",", $data[1]); if(count($laFecha) == 2) { $fecArchivo = explode(" ", $laFecha[1]); //print_r($fecArchivo); $anno = $fecArchivo[5]; $mes = $meses[strtoupper($fecArchivo[3])]; $dia = $fecArchivo[1]; $hora = $fecArchivo[6]; $fechaReal = $anno."-".$mes."-".$dia; //echo $fechaReal; //echo $contador." - "; $sql_guardar = 'INSERT INTO registros ( Dia, Hora, Tipo_Acceso, Puerta, Tipo, Tarjeta, Nombres, Apellidos, Documento, Empresa)'; $sql_guardar .= 'VALUES( "'.$fechaReal.'", "'.$hora.'", "'.$data[2].'", "'.$data[3].'", "'.$data[6].'", "'.$data[7].'", "'.$data[8].'", "'.$data[9].'", "'.$data[10].'", "'.$data[12].'")'; $contador++; //echo "7: ->".$data[7]."<- 10:->".$data[10]."<-"; if ($data[7] != '') { //echo $sql_guardar; //print_r("<pre>"); // print_r($sql_guardar); //print_r("</pre>"); mysql_query($sql_guardar) or die(mysql_error()); if (!$sql_guardar) { echo '<div>¡Hubo un problema al momento de importar el archivo! <br>¡Por favor vuelva a intentarlo!</div>'; exit; } } } } $row++; } fclose($fp); echo '<div>¡La importación del archivo se subió satisfactoriamente!</div>'; exit; } ?>
  19. Unusual Code - A PHP Shortcut?

    <?=++$a?> <?=++$b?> <?=$private_id?> <?=session_id()?> I found this on the internet amongst some other code, and it appears to work. Unfortunately, I do not quite understand it. Is <?= a shorthand for <?php echo ... ;
  20. Load Page with Filler Update

    THE TASK: Receive an HTTP query from an external source. Use the information from the query to obtain information from a data base Insert the information from the database into a filler page. Load the filler into the host page in such away that both appear simultaneously. DILEMMA: I can perform all of these tasks individually, but I am at a loss as to how to move from Step 3 to Step 4. DISCUSSION: I am accustomed to loading a filler into a page that is already opened. And, I am accustomed to loading a page with information queried from a database. Although I am pretty sure that I can call a page and load it with a filler whose content is determined by the HTTP query (Steps 1 and 4). What I have not done and feel awkward about is filling the filler page with information from the database query before displaying both the page and the filler together. QUESTION: Any suggestions? Roddy
  21. Structuring the PHP site

    Hello there all, I want to learn"How can i structure groups within a website? (groups like i mean-- admin ,moderators, helpers,users, etc-etc) ? " in context of PHP ... this site has the groups like this as i said, please someone provide me some concepts and ideas how i can implement this ?
  22. Missing XML Formatting

    BACKGROUND: I have recently created the content of an automatically generated podcast using a PHP Class that I found on a webpage found https://www.phpclasses.org/package/2957-PHP-Generate-RSS-2-0-feeds.html. Unfortunately, when I attempt to display the generated feed all that is displayed are the values of the input variables, or alternatively nothing (see (below)depending on the method of display. In short, the desired formatting -- the reason that I downloaded the PHP Class -- is missing. The page that creates the above result is a text file with a .php extension and a header( ) function. $rss_feed->encoding = 'UTF-8'; $rss_feed->version = '2.0'; $rss_feed->createFeed($rss_channel); header('Content-Type: text/xml; $rss_channel = the object that combines the formatting with the values of the input variables and their respective objects. The Class is relatively straight-forward and easily customized, but for two lines that I do not understand and could well be preventing the display of the XML code, if not properly configured. Interestingly, whether they are commented out or left in tact, they have no affect on what is displayed. $selfUrl = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on' ? 'http://' : 'https://'); $selfUrl .= $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; When I run the .php file the following message appears at the top of the completed page. Still nothing below the message appears. Also, I do not know the source of this message. it does not appear to come from the .php document. Now, I have not constructed a style-sheet for the Feed page, but I hardly see how this could stop the feed from appearingl Please advise.
  23. check if facebook user exists

    Can someone give any suggestion how to check if a facebook address is valid when send by form input? I created a function checking the url address with get_headers at status code 302. This doesn't work when a facebook username doesn't exist, because it still gives true. How to solve this problem?
  24. $text = "i am a student of oxford university, and i love to tell everyone how much i have enjoyed my four years in school. the whole environment was really welcoming" . Actually, we have a database table called "text_word". So, i want a script that will search through the above text and check if any of those words from the above text does not exist in the "text_word" table, such word should be replaced by asterisks and store the replaced word into a separate column called "unmatched_word" in the same "text_word" table. let's assume the word "welcoming" was not existing in my database what i want to achieve is this. the text is parsed through the program INPUT: "i am a student of oxford university, and i love to tell everyone how much i have enjoyed my four years in school. the whole environment was really welcoming" . OUTPUT: "i am a student of oxford university, and i love to tell everyone how much i have enjoyed my four years in school. the whole environment was really ******" . Code Sample: foreach ($text as $word) { $select_word = $f->filterRecord("*", "parts_of_speech", "word", $word); $get_word = $f->show_data($select_word); $count_words = $f->numR($select_word); if ($count_words > 0) { $result[] = '<a href="word/?w='.$word.'">'.$word.'</a>'; } else { $result[] = "******"; } } Please i believe the code is not doing exactly what i want. If you have a better approach to how i can get the job done, i don't mind if you give me a fresh code snippet or script. I hope you understand what i'm trying to do now?
  25. my yii2 view/site/index is ok and my css is working there fine, however, other pages, for example view/about and view/login are just html without css and working terrible, what could be causing it? why my css is only working in view/index ?