Posts by Clayderson Ferreira • 1,002 points
40 posts
-
2
votes1
answer65
viewsQ: Tests with Phpunit in class that uses $_SERVER variable
Hello, all right with you? I created the following class for my own mini-framework (developed for study purposes). <?php declare(strict_types=1); namespace Atlas\Core; final class Request {…
-
2
votes1
answer62
viewsA: System in a single folder with multiple Bds
It’s really not necessary to do this by creating a database for each user. You can allocate all of them in the same database. Just know how to structure the tables by placing an identifier in each…
-
6
votes2
answers1397
viewsA: Dynamic subdomain system
Web server People don’t notice, but this is already set up by default on your web server. When you access a domain that has been pointed to your server, but your server has none virtual host…
-
11
votes2
answers2058
viewsQ: What would the route model look like for a Rest API in more complex operations?
I did some research on the REST API model, but among the many questions I had, I have one that is essentially important. People always gave examples of route models that looked like this:…
-
0
votes1
answer119
viewsA: Block a request that contains a certain element in the header using Nginx
I focused so much on Ny that I forgot that I can force a return along with some code, ending the request. The solution for those who have the same problem is the following: server { listen 80;…
nginxanswered Clayderson Ferreira 1,002 -
0
votes1
answer119
viewsQ: Block a request that contains a certain element in the header using Nginx
Hello, Let’s assume that a request has the HTTP_CF_CONNECTING_IP element in the header. This element is included by Cloudflare. How do I block all requests that have this element in Nginx? I tried…
nginxasked Clayderson Ferreira 1,002 -
0
votes2
answers495
viewsQ: How to adjust a div to fit across the screen if there isn’t enough content to do so
Hello, I’m using freamework Materialize to create an administrative panel for a system I’m creating in PHP, but I know very little about front-end. I would like help to adjust the leftbar to fit…
-
3
votes1
answer628
viewsA: Save to database or generate new html page?
Without any doubt, you should store the news in a database. Creating a page for each news story is completely unviable. It only works on static content sites that don’t change. Think of the…
-
0
votes1
answer473
viewsA: Take external variable value and play in an input
As the questioner said that he does not have time to explore and the right way, he wants something simple and did not give enough information for a better answer, I will give a solution. Although…
phpanswered Clayderson Ferreira 1,002 -
0
votes1
answer257
viewsA: Two selects in a while with PDO
As they said in the comments, your code makes little sense. It would be better if you spoke what you want, maybe some print of the project. Anyway, with a few modifications this will help you.…
-
1
votes1
answer196
viewsQ: Is using specific data types like SMALLINT and MEDIUMINT instead of INT and marking columns with UNSIGNED an exaggeration?
Speaking of databases, we know that they have several data types to be used in each specific situation. But, following the data types to the letter can be considered an exaggeration in most cases or…
-
0
votes1
answer607
viewsA: How to save the full HTML of a form to Mysql?
The problem You have to escape the data coming from the form, this on any data going to the bank. If you are not doing this in addition to the problem presented, probably your system is vulnerable…
-
6
votes2
answers2958
viewsA: How to find the origin of the request in PHP?
The most efficient method is to make a type of registration of your servers and then compare the IP, this you can do in several ways, some very ingenious, but the objective here is to give a base.…
-
1
votes1
answer82
viewsA: Several equal checkbox Value[]
Identifying and solving problems You are passing the data via GET, with input with the same name, but with array initializer defined in the Names, so so far so good. The data arrived at PHP in the…
-
0
votes2
answers433
viewsA: How to put a default php option Selected
To capture the current year, use $anoAtual = date('Y'); To do what you want, you can use the PHP conditions <?php $anoAtual = date('Y'); if ($anoAtual == $row['ano']) { $ano[] = "<option…
phpanswered Clayderson Ferreira 1,002 -
2
votes2
answers540
viewsA: Taking values of equal variables by URL
I recommend via POST, because as we all know, GET has a character limit that depends on the browser, and if it is something that the client can make many selections, maybe it gives problem via GET.…
phpanswered Clayderson Ferreira 1,002 -
7
votes2
answers307
viewsA: As only receive gets from a certain IP
Use the global variable $_SERVER['REMOTE_ADDR'] It will inform the IP of where the page is being requested. Remember that if you use Cloudflare or some other similar mechanism, it may change the…
phpanswered Clayderson Ferreira 1,002 -
2
votes1
answer463
viewsA: Redirect via COOKIE
On all pages that will have this feature, you should add a command to save the URI to the cookie, like this: setcookie('client_uri', $_SERVER['REQUEST_URI'], (time() + (30 * 24 * 3600))); The above…
-
0
votes2
answers107
viewsA: Use Cookies or Session for business guide?
Sesssions are destroyed when the browser is closed (except if the visitor marks the option to continue where he left off in the browser), cookies remain valid for as long as you determine, or until…
phpanswered Clayderson Ferreira 1,002 -
0
votes2
answers1906
viewsA: Swap Image and clear cache
Based on the comments of the questioner, here is one of the possibilities of achieving the desired goal simply and effectively. Create a PHP file called get-image.php and put the following code…
javascriptanswered Clayderson Ferreira 1,002 -
4
votes2
answers22742
viewsA: View Div in Mobile Version Only
You can use Javascript, or CSS media querys (which is the most appropriate for this). In your CSS, apply the rule: @media screen and (max-width: 380px) { #divMobile { //Aqui você aplica as regras…
-
1
votes1
answer1071
viewsA: Pass variable value to input in another PHP file
Come on. Include jQuery in your project (you can do it with pure Javascript, just search the internet). <script…
phpanswered Clayderson Ferreira 1,002 -
1
votes1
answer42
viewsA: How to use the rel_canonical tag when two domains point to the same site?
For SEO reasons, you should choose one to be your main domain, and the other you can create a 301 redirect. Leaving two domains separate and pointing to the same site, showing the same content is…
htmlanswered Clayderson Ferreira 1,002 -
7
votes2
answers50
viewsA: How to send hidden information through a form?
In input, set the attribute hidden and place the value within value, thus: <input type="hidden" name="input1" value="valor que você quer passar">…
-
2
votes1
answer44
viewsA: Is it possible to add a php code in a . js file?
Rename the . js file to . php, after that, at the beginning of the file, add the following. <?php header("Content-type: text/javascript"); ?> Now you can include PHP code both within these…
-
4
votes1
answer3802
viewsA: How to end the user’s session if it closes page/tab?
Come on Add a table to your database by following the template below. It will be responsible for managing open sessions. Change the validation you already have, and switch to the code below.…
phpanswered Clayderson Ferreira 1,002 -
3
votes1
answer5501
viewsA: Pass value to modal window, retrieve data and reuse it
You can’t capture the data because you set the attribute on it disabled as true. In doing so, these fields are ignored. It is as if they do not exist. To solve your problem, remove the disabled…
-
4
votes5
answers6498
viewsA: Clear Browser Cache after Version Upgrade
Solution Rename the extensions of all JS files (which I believe are the files causing caching problems) to . php Set the content type of the JS page using header("Content-type: text/javascript");…
-
5
votes4
answers1047
viewsA: How to invert words and count total characters
Simple <?php $string = (isset($_POST['input1'])) ? trim($_POST['input1']) : null; $stringInvertida = strrev($string); $qntCaracteres = strlen($string); echo "Seu texto invertido é:…
phpanswered Clayderson Ferreira 1,002 -
0
votes0
answers281
viewsQ: How to use a dynamic URL to receive Paypal notifications?
So, I know it’s possible to set a notification URL through the client area, and I also know that you need to activate the notification feature. However, I need to define the notification URL at the…
-
6
votes2
answers3664
viewsA: How to prevent CSRF attack without PHP frameworks?
I, in particular, found the code very messy, not to mention that it is not doing the treatment in case $_POST does not exist (if any improper modification is made to the form). I recommend you do it…
-
2
votes1
answer1447
viewsA: How to create an installer (setup) for tables and connection to the database?
Modifications within the main system In your script (the system that will be sold), it should check if the file exists config.inc.php, which in our case, will (or should be) in the folder system. if…
-
2
votes1
answer2569
viewsA: Error when establishing a connection to the Database
This is a very simple problem to solve. It’s a mistake, but why? Of course there’s a problem with the connection, so at first it could be the login data or the access permission. Is the bank located…
-
2
votes2
answers2288
viewsA: Can I use PHP to create dynamic meta tags for SEO?
Answer You can use yes. But why? Both Google and any other search engine or browser will understand the data the same way you would if you set the values directly in HTML. This is basic PHP concept.…
-
6
votes5
answers1793
viewsA: Login system with PHP
Forget SHA1 and MD5 Before you start, make it clear. Do not use any of these encryption methods. You will understand why in the course of this answer. Important information I recommend you read this…
-
-2
votes2
answers521
viewsQ: How to use unit of time less than milliseconds in a setInterval or setTimeout
I would like to know (if possible) how to use a unit of time less than milliseconds in the functions setInterval or setTimeout. I made a progressive stopwatch using the following code function…
-
1
votes1
answer264
viewsA: Manage variables with PHP session
Your code is wrong. You are setting the value of $_SESSION['nome'] with a $_POST that does not yet exist and the same situation is repeated when calling the popup. Do so <?php…
-
3
votes2
answers3830
viewsA: Insert data from one table into another
Your question was not clear enough, but come on. Make a related table as follows: In the model above, a line will be created in the sales tables, sales_product and sales_service whenever something…
-
0
votes3
answers5447
viewsQ: Remove element Focus using pure Javascript
I want to know how to remove the focus of an element when it is clicked using pure Javascript. I did it this way using jQuery $(function(){ $(".btn").click(function(){ $(".btn").blur(); }); }); This…
javascriptasked Clayderson Ferreira 1,002 -
1
votes2
answers519
viewsA: Placeholder does not appear after applying "padding" to input
In your class .caio-input, you set up a padding 25px on all sides. Adding the padding-top and padding-bottom, would be 50px padding, ie the placeholder is there, however, the padding is overlapping…