Ausnahme gefangen: SSL certificate problem: certificate is not yet valid ๐Ÿ“Œ Tags Input with Autocomplete using jQuery and PHP

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š Tags Input with Autocomplete using jQuery and PHP


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

Tags are used to organize posts or articles on the website. Tags provide an effective way to group related posts and make it easier for the user to find relevant posts quickly. It also helps readers to get a brief idea about the post without reading the entire content. Tags are more like categories, but they can describe posts in more detail than categories. Generally, one category is assigned to a post, on other hand you can use multiple tags for a single post.

The tags input field should be allowed to input multiple values separated by a specific separator. Mostly, the comma (,) is used as a separator for the multiple valueโ€™s input field. In this tutorial, we will show you how to create multiple tags input field using jQuery. You can build a user interface to manage tags with autocomplete feature using jQuery and PHP.

The example code will integrate a text field to input multiple tags. Also, an autocomplete feature will be provided to display tag suggestions from the database under the input field while the user starts typing.

Tags Input with jQuery
In this code sample, we will use the TagsInput jQuery plugin to convert a simple text input field to the tag list input area and allow the user to input multiple tag values.

The tag can be added by entering a comma (,).
The tag can be removed by a cross icon (x).
Define an HTML input field.

<input type="text" id="tags_input">
Include the jQuery and TagsInput library files.

`<!-- Include jQuery library -->

`
Initialize the tagsInput plugin and specify the selector (#tags_input) to attach it to the input field.

<script>
$('#tags_input').tagsInput();
</script>

Tags Input with Autocomplete using PHP and MySQL
In the following example code snippet, we will show you how to add autocomplete feature to the tags input field using jQuery and PHP.

Create Database Table:
To store the autosuggestion tags data a table is required in the database. The following SQL creates a tags table with some basic fields in the MySQL database.

CREATE TABLEtags(
idint(11) NOT NULL AUTO_INCREMENT,
namevarchar(100) COLLATE utf8_unicode_ci NOT NULL,
statustinyint(1) NOT NULL DEFAULT 1 COMMENT '1=Active | 0=Inactive',
PRIMARY KEY (
id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
HTML Input Element:
Create an input element with HTML.


jQuery Library:
jQuery library is required to use the TagsInput plugin.

jQuery UI Library:
To use autocomplete feature in tagsInput, the jQuery UI library is required. Include the jQuery UI library files first.

tagsInput Plugin:
Include the library files of the tagsInput jQuery plugin.


Set server-side script URL in autocomplete_url option of the tagsInput() method.

<br> $(&#39;#tags_input&#39;).tagsInput({<br> &#39;autocomplete_url&#39;: &#39;fetchData.php&#39;,<br> });<br>
Fetch Autocomplete Tags from Database with PHP and MySQL (
fetchData.php):
The
fetchData.php file is called by the tagsInput()` method to retrieve the tags from the server-side script based on the search term.

Get the search term using the PHP $_GET method.
Fetch the matched records from the database with PHP and MySQL.
Return tags data as JSON encoded array using PHP json_encode() function.
`<?php

// Database configuration
$dbHost = "localhost";
$dbUsername = "root";
$dbPassword = "root";
$dbName = "codexworld";

// Create database connection
$db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);

// Check connection
if ($db->connect_error) {
die("Connection failed: " . $db->connect_error);
}

// Get search term
$searchTerm = $_GET['term'];

// Fetch matched data from the database
$query = $db->query("SELECT * FROM tags WHERE name LIKE '%".$searchTerm."%' AND status = 1 ORDER BY name ASC");

// Generate array with tags data
$tagsData = array();
if($query->num_rows > 0){
while($row = $query->fetch_assoc()){
$data['id'] = $row['id'];
$data['value'] = $row['name'];
array_push($tagsData, $data);
}
}

// Return results as json encoded array
echo json_encode($tagsData);

?>`
tagsInput Options
Various configuration options are available to customize the tagsInput() functionality. Some useful options are given below.

autocomplete_url โ€“ URL to fetch the autocomplete data
autocomplete โ€“ Options and values for autocomplete data ({option: value, option: value})
height โ€“ Height of the tags input area (100px)
width โ€“ Width of the tags input area (300px)
defaultText โ€“ Placeholder text for the input field (add a tag)
onAddTag โ€“ A callback function that triggers when the tag is added
onRemoveTag โ€“ A callback function that triggers when the tag is removed
onChange โ€“ A callback function that triggers when the tag value is changed
delimiter โ€“ Separator for a new tag ([โ€˜,โ€™,โ€™;โ€™] or a string with a single delimiter. Ex: โ€˜;โ€™)
removeWithBackspace โ€“ Remove tag by backspace (true)
minChars โ€“ Minimum character limit (default, 0)
maxChars โ€“ Maximum character limit (default, no limit)
placeholderColor โ€“ Placeholder text color (default, #666666)
Get Value of Input Tags with PHP
Once the form is submitted, you can get the value of the tags input field using the $_POST method in PHP. The following example code snippet shows how to submit the form and get the tags input fieldโ€™s value using PHP.

HTML Form with Tags Input:

`


<!-- Input field -->

Tags:

<!-- Submit button -->
<input type="submit" name="submit" value="Submit">
`
Get Value of Tags Input:
After the form submission, use the $_POST method in PHP to retrieve the value from the tags input field.

`if(isset($_POST['submit'])){
$tags = $_POST['tags_input'];

echo '<p><b>Selected Tags:</b></p> '.str_replace(',', '<br/>', $tags); 

}`
Autocomplete Textbox with jQuery UI using PHP and MySQL

Conclusion
Tags input with autocomplete feature is very useful for the tags management in post/product creation form. You can the example code to allow the user to input multiple tags and manage them easily. The autocomplete functionality helps to find relevant tags quickly and select from the pre-populated list. You can also get multiple values from the input fields and insert tags in the database with PHP and MySQL.

...



๐Ÿ“Œ Tags Input with Autocomplete using jQuery and PHP


๐Ÿ“ˆ 67.33 Punkte

๐Ÿ“Œ Piwigo bis 2.9.2 Administration Panel admin/tags.php tags SQL Injection


๐Ÿ“ˆ 33.36 Punkte

๐Ÿ“Œ Piwigo up to 2.9.2 Administration Panel admin/tags.php tags sql injection


๐Ÿ“ˆ 33.36 Punkte

๐Ÿ“Œ LinkDesk Smart Tags vorgestellt: Schicke NFC-Tags mit App-Anbindung


๐Ÿ“ˆ 29.85 Punkte

๐Ÿ“Œ LinkDesk Smart Tags vorgestellt: Schicke NFC-Tags mit App-Anbindung


๐Ÿ“ˆ 29.85 Punkte

๐Ÿ“Œ Medium CVE-2016-10707: Jquery Jquery


๐Ÿ“ˆ 28.45 Punkte

๐Ÿ“Œ Low CVE-2015-9251: Jquery Jquery


๐Ÿ“ˆ 28.45 Punkte

๐Ÿ“Œ Low CVE-2012-6708: Jquery Jquery


๐Ÿ“ˆ 28.45 Punkte

๐Ÿ“Œ jQuery up to 1.8.1 jQuery(strInput) String cross site scripting


๐Ÿ“ˆ 28.45 Punkte

๐Ÿ“Œ jQuery bis 1.8.x jQuery(strInput) String Cross Site Scripting


๐Ÿ“ˆ 28.45 Punkte

๐Ÿ“Œ jQuery up to 1.11.3/2.2.4 on Node.js jQuery.globalEval Datatype cross site scripting


๐Ÿ“ˆ 28.45 Punkte

๐Ÿ“Œ jQuery up to 1.8.3 on Node.js jQuery(strInput) cross site scripting


๐Ÿ“ˆ 28.45 Punkte

๐Ÿ“Œ Low CVE-2020-7656: Jquery Jquery


๐Ÿ“ˆ 28.45 Punkte

๐Ÿ“Œ Medium CVE-2020-28488: Jquery Jquery ui


๐Ÿ“ˆ 28.45 Punkte

๐Ÿ“Œ Low CVE-2022-2144: Jquery validation for contact form 7 project Jquery validation for contact form 7


๐Ÿ“ˆ 28.45 Punkte

๐Ÿ“Œ CVE-2021-4243 | claviska jquery-minicolors up to 2.3.5 jquery.minicolors.js cross site scripting


๐Ÿ“ˆ 28.45 Punkte

๐Ÿ“Œ jQuery bis 1.8.3 auf Node.js jQuery(strInput) Cross Site Scripting


๐Ÿ“ˆ 28.45 Punkte

๐Ÿ“Œ jQuery bis 1.11.3/2.2.4 auf Node.js jQuery.globalEval Datatype Cross Site Scripting


๐Ÿ“ˆ 28.45 Punkte

๐Ÿ“Œ Create Tags Input Field in React.js โ€” No package Required!


๐Ÿ“ˆ 22.7 Punkte

๐Ÿ“Œ Nextcloud: Users can set up workflows using restricted and invisible system tags


๐Ÿ“ˆ 21.83 Punkte

๐Ÿ“Œ How to alias and navigate to directories with autocomplete in Linux


๐Ÿ“ˆ 21.78 Punkte

๐Ÿ“Œ Cod: New Command Line Autocomplete Daemon For Bash and Zsh That Detects --help Usage


๐Ÿ“ˆ 21.78 Punkte

๐Ÿ“Œ goto v2.1.0 - alias and navigate to directories with autocomplete


๐Ÿ“ˆ 21.78 Punkte

๐Ÿ“Œ Chrome's new address bar features automatic typo correction, better autocomplete, and more


๐Ÿ“ˆ 21.78 Punkte

๐Ÿ“Œ Setting up ZSH and Oh-my-ZHS with autocomplete plugins


๐Ÿ“ˆ 21.78 Punkte

๐Ÿ“Œ How To Create Responsive Website Using HTML CSS and Some jQuery


๐Ÿ“ˆ 21.14 Punkte

๐Ÿ“Œ How to See What Tags a YouTube Video Is Using [100% working]


๐Ÿ“ˆ 20.05 Punkte

๐Ÿ“Œ How to See What Tags a YouTube Video Is Using [100% working]


๐Ÿ“ˆ 20.05 Punkte

๐Ÿ“Œ Czkawka 5.0 - my data cleaner, now using GTK 4 with faster similar image scan, heif images support, reads even more music tags


๐Ÿ“ˆ 20.05 Punkte

๐Ÿ“Œ Czkawka 5.0 - my data cleaner, now using GTK 4 with faster similar image scan, heif images support, reads even more music tags


๐Ÿ“ˆ 20.05 Punkte

๐Ÿ“Œ How to replace links in a text with Anchor Tags using JavaScript


๐Ÿ“ˆ 20.05 Punkte

๐Ÿ“Œ Autocomplete a novel phishing hole for Chrome, Safari crims


๐Ÿ“ˆ 19.99 Punkte

๐Ÿ“Œ Vuln: Drupal Autocomplete Deluxe Module Cross Site Scripting Vulnerability


๐Ÿ“ˆ 19.99 Punkte

๐Ÿ“Œ Autocomplete a novel phishing hole for Chrome, Safari crims


๐Ÿ“ˆ 19.99 Punkte

๐Ÿ“Œ Vuln: Drupal Autocomplete Deluxe Module Cross Site Scripting Vulnerability


๐Ÿ“ˆ 19.99 Punkte











matomo