331 Reusable Code Snippet Topics
Remove Filter ![]() | |
The Markdown editor that we use here at DaniWeb is called [CodeMirror](https://codemirror.net/) and we've been using it for forever. The other day, I noticed some bugs in the editor toolbar that we use, which is based on the [CodeMirror API](https://codemirror.net/docs/ref/). (The one that allows the buttons for bold, italic, etc.) … Web Development typescript | |
Never published this before, so this is a DaniWeb.com Exclusive :) If your WP-Site has a lot of K-Links, you should consider using this script. It definetly works. For now... ## **Negative SEO** through spamming Backlinks can be a huge problem for the visibility of a webpage. ## You can … | |
DaniWeb is built on top of the Codeigniter 3.1.x PHP framework. Although I probably should have built it as a CI model, here is the database library that we are using. You can see it mainly serves as a wrapper for CodeIgniter's built-in database class. You can see we use … Web Development php | |
This is a simple to use, self-contained website slideshow utility. Do you have a monitor or TV setup in your lobby where you'd like to present web content automatically? With this HTML/Javascript page, simply edit an array of pages or "slides". You define a title, duration, and URL for each … Web Development javascript | |
I wanted to post something in Daniweb for a while but I didn't had anything new. Recently I decided to write a new implementation for websocket connections client side using Shared Web Workers. Shared Web Workers are supported today by most browsers for desktop but few for mobile devices , … Web Development javascript | |
This function is usefull for peoples with a link directory where the links are stored inside a (MySQL) database. The PHP script is easy to use to find out if a reciprocal link still exists on the corresponding webpage. It takes care about the trailing slash in urls and can … Web Development php | |
Here is the function that I use here at DaniWeb to manage flood control. It keeps track of how often a specific user or IP address is making a request, and increments a counter. If there have been no requests after 5 minutes, the counter resets to 0. It returns … Web Development php-codeigniter redis | |
Sometimes we have a need to take a simple PHP array and represent it as an encoded string. One use case that we have for this at DaniWeb is when a new user signs up, and we ask them to click on a link that was sent to them via … Web Development php | |
Sometimes we want to know if the webpage was fetched over an SSL connection (e.g. the URL begins with https:// instead of http://). This way, if an end-user is accessing an insecure version of our site, we can redirect them to the secure version. The following PHP function called `no_ssl()` … Web Development php | |
For some reason, PHP class constants don't play nicely with inheritance. For example, suppose you have the following code: class Foo { const VAR = 'foo'; public function __construct() { echo self::VAR; } } class Bar extends Foo { const VAR = 'bar'; } // This will actually print out … Web Development php | |
By default, PHP's clone keyword just creates a shallow copy of an object, and doesn't work as desired if the object contains properties that are also objects, because it doesn't create real copies of those objects but rather just pointers to the initial version of them. This function creates a … Web Development php | |
A little while ago, I wrote a [tutorial](https://www.daniweb.com/programming/web-development/tutorials/537376/sanitize-php-user-input-strings) about how important it is to sanitize PHP user input strings. Not only is it important to sanitize user input being fed into a database query, but it's also important to sanitize user input being displayed to the end-user to generate valid … | |
FPDF is a class that provides a useful way to deal with PDF documents using dynamic content. Sometimes, according to a special circumstance, also would be valuable to send directly the PDF as attachment e.g. send an invoice automatically after processing a payment. In this example we use a html … | |
I browsed google and found nothing so thought i would put my efforts up here. hope this all helps. this function will allow you to return the number of days between two dates minus saturdays and sundays. (including the start date) Web Development javascript | |
After page loading , when I click on the ellipsis , horizontal tabs transform from bottom of the product image . After opening of the tabs menu bar , first tab should open by default.I tried multiple solutions but none of them worked out. Web Development html-css javascript javascript-jquery | |
Hello Daniweb Community, I have been talking on a couple [Facebook](http://www.facebook.com) groups such as sale pages where you post your own stuff for people to buy. Most groups like this have rules about bumping like once per day, every 12 hours etc... So it got to the point where it … Web Development php social-media | |
I needed a script that would grab all the folders in the directory and add them to a dropdown list and allow the user to upload to there choosen folder. This is what i came up with. (upload script is not mine) Thought i would share. Web Development file-system php | |
As usual i searched google to convert Decimal numbers to their Binary equivalents but i couldnt find any short algorithm for that matter. So here is mine.. Web Development javascript | |
Hello! I needed a configuration file for a application I'm working on so I first used the built in ini functions in php but it wasn't easy to write the ini files. So I wrote myself a class here to parse a configuration file and write/edit configuration files. I plan … Web Development php | |
If you need your PHP script to redirect to a different website, you can send an HTTP header to do that. Remember, `header()` must be called before any actual output is sent, which includes not just HTML, but blank lines, etc.. as well. Web Development http-protocol php | |
You might be familiar with the dreaded blank page when your PHP script doesn't work. Here's how to spit out errors to the screen, instead of getting just a blank page, as well as logging errors to a file. Web Development php | |
There are two ways to write to a file in PHP. You can either open a stream, and write to it in parts, or you can use `file_put_contents()` which is much more convenient, with the trade off being that it takes up much more memory, and is not ideal if … Web Development php | |
| |
...was asked for some php file upload code, so I thought I would post some stripped down, barebones code that I use in admin/dashboard pages to add/change images associated with products. Please see attached image for folder setup. The code uses the [jQuery Form](http://malsup.com/jquery/form/) plugin by Mike Alsup. **index.php** has … Web Development file-system javascript javascript-jquery | |
I recently had to mass insert a really large text file of strings into MySQL. Here's how I did it. Web Development mysql php php-codeigniter | |
I am building an e-commerce website i found one error in last night in my site Error: If user enters the zipcode in zip code field & without clicking on CHECK OR GO Button, when he clicks on ADD TO CART button then products are getting added in Shopping cart. … Web Development wordpress | |
Hello everybody. I'm starting to build an event calendar for employees in my company, and the first thing I needed was an working calendar to build from, so I wrote a simple one. Hope it can be usefull for someone. Cheers. Web Development javascript | |
I found myself starting to answer a question that I have answered many times , so I thought why not making a code snippet and just reference this. This is a short code snippet only to demonstrate how this thing work (with apache and rewrite engine on) , in real … Web Development php | |
The Code Given is for only beginners in HTML 1.The code implements a simple login form 2.It checks whether the password and usernames are matching or not 3.While you are using replace the predefined username and password that I'v given that is replace "myuserid" and "mypswrd" with your own userid … Web Development html-css javascript |
The End.