Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [php]

PHP is a widely-used, general-purpose scripting language that is especially suited for web development.

2
votes
1answer
61 views

My code get data from database using AJAX and return to view

My code get data from database using AJAX the problem is i want to filter data by month year and quarter and the code that does that is: ...
1
vote
2answers
59 views

Securing login PHP script

I have made a login system where the inserted_id and inserted_password are sent to the login.inc.php via the XMLHttpRequest. I'm ...
0
votes
0answers
54 views

Forgot password / Reset password

I have a working example of 2 methods: Forgot password: A user inserts an account number and an email => An email is sent to the user right after it creates a token in the database. Validate Reset ...
0
votes
1answer
48 views

Php: how to lower complexity of method [closed]

I have this method rated B on Scrutinizer (direct link: https://scrutinizer-ci.com/g/sineverba/domotic-panel/inspections/76996c9f-543f-43b4-9475-c64fe810a278/code-structure/operation/App%5CHttp%...
2
votes
2answers
83 views

PHP New User Creation

I'm learning more about PHP, so I've decided to create a simple login/create account system. Entering information for creating a new account sends the data to my ...
2
votes
2answers
77 views

PHP find cheapest permutation

I have multiple products that all have sizes and I need to find the cheapest configuration that meets the minimum required size. For example, John needs a minimum of 10 litres of storage - it can be ...
2
votes
0answers
36 views

PHP - Saving inbound email and its attachment

I have below code, which is basically handling inbound emails in my application, save the actual email content (text + attachments) to my database, and further save the actual attachment file on my ...
2
votes
1answer
98 views

PHP - function to handle requests

I have the following function which handles requests. It has more than 130 lines ...
1
vote
1answer
51 views

Optimize Multiple Insert SQLite Coming From MySQL

I'm currently developing an app that requires sending and receiving of data from android studio going to MySQL and then data coming from MySQL will be saved from the SQLite. I need advice on how to ...
3
votes
1answer
69 views

Sending and receiving of JSON data to and from Android Studio

I'm currently developing an app that requires sending and receiving of data from android studio going to MySQL and then data coming from MySQL will be saved from the SQLite. I need advice on how to ...
2
votes
1answer
43 views

Adding prefixes to headers in markdown

I'm adding prefixes to headers in markdown using a script. For example, if I have: # Hello ## World ### Let's add ## Some headers ### Yay! # Foo ## Bar I ...
1
vote
0answers
21 views

run different validation strategy based on condition

I need to execute different validators depending for different countries ($country_id), each validator should return error message variable in case of failure. One validator (CommonValidator) is ...
2
votes
0answers
31 views

Generating two Woocommerce Order CSV files based off url query

I wrote this code about one year ago. I'm looking to refactor it to be solid SOLID and secure, as this is being generated off a custom endpoint. The script is to read parameters from a query and ...
3
votes
2answers
118 views

PHP script that writes a JSON file with iextrading API data

iextrading has two APIs (v1, v2) which provide financial market data. Following script records a JSON file with their equity information (using a CRON job). Would you be kind and review it for any ...
2
votes
1answer
43 views

Checking if a shipping method exists

I am trying to create a custom WordPress/WooCommerce function in PHP. I am a newbie and would really appreciate some feedback on my code and how to improve the code! Right now it feels like there is a ...
1
vote
0answers
24 views

PHP API Query using CURL and return JSON

Fairly new to writing PHP. I want some PHP code to query an API with a post request, set specific headers and message body, and echo out the JSON response. This is the code I have come up with, which ...
7
votes
2answers
713 views

Reading source code and extracting json from a url

I made a program to read the source code from a url. To reach this url I need to specify a token. After read the source code, I extract a url in json format, andIi ...
3
votes
2answers
106 views

Asking 2 values, feet and inches, and it converts them to centimeters

I was doing an exercise in PHP, and it works perfectly, no problems. But I think that maybe I coded it so long, and I think it can be shorter than it is now, but I don't know how to make it shorter ...
2
votes
0answers
19 views

Create a new WordPress admin page, and add an admin table to it

I completed this WordPress coding task as part of an interview. I'm hoping someone can review my work and comment on everything, especially my general approach to the task, and the sanitization of ...
1
vote
1answer
66 views

User registration and authentication using hashed passwords

I'm working on a game project (with Unity) that shall handle user credentials and other data. The game connects send requests to a php script and this script send requests to the database. After ...
5
votes
2answers
70 views

PHP password-resetting page

I am producing a PHP code and I want to implement it in my server to do its function. My question is, are there any vulnerabilities that I should correct? I tried to establish the session first then ...
1
vote
1answer
46 views

When slide show web page is reopen, the web page loading is very slow

Here is a script that opens about 200 pictures, the first time you open the webpage, loading of the 200 pictures is fast, However if you reopen the page, it takes about 4 minutes to load the same page ...
2
votes
0answers
58 views

PHP project with Google Calendar API

I'm playing with a simple (for now) project in PHP with Google Calendar API. I have posted the code here in order to improve my programming style about whatever you think it's worth suggesting. Thank ...
1
vote
1answer
78 views

PDO login script

Just started using PDO for my newest project. I'd like to get input on how this login script looks and if I should alter it in any way. When the user clicks the link to the index.php page, a script ...
3
votes
0answers
47 views

Verify OpenSSL RSA signature (PHP) with .NET (VB)

I would like to achieve something I believe is pretty standard: A) My VB.NET client (ideally targetting Framework 4.0) sends a text string to my Apache/PHP Server via an HTTPS POST request. B) My ...
3
votes
1answer
95 views

PHP PDO search & pagination

I know that OOP is ubiquitous nowadays. Nonetheless I still write procedural PHP. It now seems to me that I had fallen into a spaghetti code trap, because my code starts to seem meaningless even to me ...
1
vote
1answer
75 views

PHP code for search page

Want to show you part of code that I wrote to process search request. User commit search by articles (codes) of products. The goal is to allow user write his search request to textarea element in any ...
1
vote
1answer
74 views

Laravel show and update currency from rest api

I need: Daily save new exchange rates from the REST API in the database. Return the current exchange rate for a given currency, the whole table for a given day, the exchange rate for a given currency ...
2
votes
1answer
68 views

Retrieving data from active directory with PHP

I have the following php function, that reads and returns data from the active directory. It is part of a project which will be graded (I'm in an apprenticeship). It is very long and I think the code ...
2
votes
1answer
95 views

Symfony AJAX comment system with votes

How can I improve this code ? It was quite hard to implement AJAX comment system in Symfony 3, and result is a bit of mess: Controller: ...
2
votes
1answer
49 views

Retrying Curl X amounts of Time until Successful Return (Script/Functions)

I'm under no illusion that this is at all the best way or even a good way of doing this. It's simply a working solution. Tips, opinions, suggestions, insults, death threats, let's hear it. ...
2
votes
0answers
62 views

LSB Image Steganography

After learning the concept of steganography, I've decided to code an application for it in PHP out of all languages, using the Least Significant Bit technique. A pixel of a colored image generally ...
3
votes
3answers
91 views

Check if a postcode is in a list

I'm looking for improvement / advice / reviews on how I can improve this code. I feel like there is a better way or more efficient way of doing this and I am over looking it. The Plugin I made is ...
5
votes
1answer
86 views

Aggregating HTML files

I am using PHP to keep my webpage organized. The directory looks like this: root/folder/file1 root/folder/file2 root/folder/file3 root/index.php Each file is ...
2
votes
2answers
66 views

ORM class for Posts

I'm new to PHP OOP and I'm making some tests. I have 2 classes: database and posts and the two interact with each other. Class Database: ...
3
votes
2answers
90 views

Efficient method to look for an instance of an object in a collection

I'm trying to determine if an instance of an object exists within a collection. I'm using array_walk_recursive to walk and check the leaves of an array. I've added a small short circuit, but still ...
1
vote
2answers
96 views

Simple wrapper for PHP mysqli connection

I'm creating some web apis to sync some data between desktop/mobile apps. Working on it, I wrote a simple wrapper for mysqli connection to simplify querying like: <...
3
votes
1answer
44 views

Forum system implementation

I have a function which does the following: When new Post Entity is added some fields in Category table are updated. When new Thread Entity is added the same fields in Category table are updated. ...
0
votes
0answers
29 views

Laravel working with dynamic start and end dates to grab some data

So, to start off, the below code does work, but it feels like a newbie solution to me, and if I ever need to come back to this code, I will have no idea what I was thinking. I have a table called <...
2
votes
1answer
97 views

Using singleton pattern for a MySQL connection

I'm new to web programming, and writing some web apis to enable users to sync their data between devices. Is it okay to use singleton pattern to prevent reconnecting the MySQL database on every api ...
3
votes
1answer
92 views

Authentication system (no browser) with mail verification

I made an authentication system for my software (no browser is used) that works like this: User receives a Key on it's mail after buying the software User registers account using that key and inputs ...
2
votes
1answer
76 views

Creating objects from xml-data

I've got an XML file with some info about hosts connected to my home network and I would like to create objects containing that info in a neat way, so that I can make some nice front-end application ...
2
votes
3answers
125 views

PHP HTTP request class

I would like to get you opinion on this class, which is used to send HTTP requests (at that moment only POST method). It is working ok, but I would like to get response on maintainability, ...
1
vote
0answers
23 views

Fetching specific records in a RESTful application

Basically what I'm trying to achieve here is I need to fetch a set of images based on the selected folder. Is this a correct way to do it? I'm using ZF 2.5, and have the following function in my ...
0
votes
1answer
75 views

User class: getting user data, logging in, secure CSRF session handling, logging out

In reference to my previous code: User class: getting user data, logging in, secure CSRF session handling I re-wrote my SystemUser class, without the DI container (for now), I'm still trying to ...
3
votes
1answer
326 views

Upload a user's avatar

Could you guys tell me if my code is safe? And i want to know how to improve it. You will see a detailed explanation about the code on the comment blocks inside the code. profileIMGform.php <...
1
vote
1answer
26 views

Processing form values for each day of week [closed]

I am using PHP, and I am getting the value back from the form. Since I am working with time, I have an array by (1 x 4) x 7, and I feel like I could do a better job at it. I just don't know exactly ...
1
vote
1answer
271 views

Applying multiple php FilterIterator instances in a cascading fashion

I wrote an implementation of php FilterIterator objects that allows me to apply them in a "cascade" way, so I can finally obtain an array of objects which is the ...
0
votes
1answer
58 views

PDO multiple queries with 2 different tables

I joined this 2 tables and dropped the user_id afterwards. I am defining the user_id elsewhere in my code based on my session/cookies and I do not want to return this value as a global. Is there a ...
0
votes
2answers
60 views

Selecting an email template and BCC address based on the message type

My code-editor "show hints" says that the method length exceeds 20 lines. How can I refactor the setEmailTemplateBcc function? ...