Stack Exchange Network

Stack Exchange network consists of 174 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.

-4
votes
0answers
18 views

How to export Mysql request on PHP to CSV file on UTF-8 without BOM character [on hold]

I would like to extract my request SQL from php to a CSV file. When I write my csv file, I've an file encoding on UTF-8 with BOM. But When I open this file on excel, I modify the data and save. Excel ...
4
votes
2answers
43 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
votes
0answers
17 views

Generating PHP code for web requests

I have a program that generates PHP code for web requests using a template and its output is like the code below. I was trying to make it a function that could be easily pasted and called in every ...
0
votes
0answers
18 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 ...
-1
votes
0answers
19 views

MongoDB group product categories reduce complexity [on hold]

I made a MongoDB query that works and will produce what I need, but I want to make it shorter (refactor) for readability because it has some repetitive lines and I would like to follow the DRY ...
-2
votes
1answer
47 views

How to correct this OOP? [on hold]

I have 2 classes user and topics, a user can follow/unfollow topics, but i don't know where to add the follow function, in User class or Topic class ? ex:- ...
-1
votes
0answers
20 views

PHP database constructor [on hold]

Im getting started with PHP and trying to write a constructor for a DB using this piece of sample code ...
-4
votes
0answers
28 views

PHP CONNECTION - BEST PRACTISE TIPS [closed]

I have been learning phpmyadmin, this is my current learning/test environment below. I created my first database today I refer to as db1 it is simple structure with only three input fields. And one ...
1
vote
0answers
36 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 ...
0
votes
1answer
53 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 ...
2
votes
0answers
26 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 ...
2
votes
1answer
30 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 ...
0
votes
1answer
61 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 ...
0
votes
1answer
49 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 ...
1
vote
1answer
50 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
39 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: ...
1
vote
1answer
36 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. ...
1
vote
0answers
45 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 ...
2
votes
3answers
74 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 ...
4
votes
1answer
83 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 ...
1
vote
2answers
60 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: ...
2
votes
2answers
81 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 ...
0
votes
2answers
58 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: <...
2
votes
1answer
38 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
23 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 <...
1
vote
1answer
75 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 ...
2
votes
1answer
72 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 ...
1
vote
1answer
54 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 ...
1
vote
3answers
99 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, ...
0
votes
0answers
21 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
67 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 ...
2
votes
1answer
292 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
25 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
217 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
35 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
54 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? ...
0
votes
0answers
29 views

Doctrine Query with subquery

I'm wondering if this is the right way to have a subquery in Doctrine. I have two entities, one called User and one called Log. ...
2
votes
1answer
92 views

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

I wrote this class a few months ago and noticed from a few examples that it's better to break down these classes and separate them. I am not so sure what is the proper way to break it into parts. It ...
2
votes
1answer
69 views

System_user Class - all in one class including login functions

I wrote this class a few months ago and noticed from a few examples that it's better to break down these classes and separate them. I am not so sure what is the proper way to break if to parts. It ...
1
vote
1answer
63 views

PHP user class usability

I'm new to PHP OOP programming and I'm trying to make a user class with login, register, logout and some other methods. I'm concentrating in the login method that will be used with Ajax. Session ...
0
votes
1answer
54 views

Probability suite for an array of elements

I wrote a function that can be used to generate a probability distribution for an array of elements (probGen()), and another that can be used to select an element ...
1
vote
2answers
76 views

Shuffle array elements by rearranging the key value associations

PHP's shuffle() function destroys the array keys, so I decided to write a shuffle function that doesn't do that and instead rearranges key-value associations. As I ...
1
vote
3answers
62 views

Date Comparison Function for `usort()`

I am working through a PHP book, and date comparison was mentioned as one of the uses of usort(), so I wrote a date comparison function to use in line with ...
3
votes
3answers
90 views

Dynamic PHP PDO insert method

This is my attempt at making a class for dynamic PDO queries in PHP. The code works, but I would like the hear what I can improve to make it more secure and readable. ...
0
votes
1answer
39 views

PHP flatfile storage

So, I made a tiny (~2 KB, <100 lines) library for simple flat-file data storage. How it works is, you define a file to be used, and then you can add/read/modify/delete objects as "keys" to/from ...
2
votes
2answers
78 views

PHP login system with prevention for session hijacking, fixation, injection, etc

I'm creating a login system and I have been reading a lot about the security measures needed to prevent session hijacking, fixation, and injection attacks, etc. These two Stack Overflow posts were ...
0
votes
2answers
50 views

Random dice game

I was just wondering if someone could check my small "random dice game", which I programmed due to a "do it yourself" from my PHP book. I am happy that it is working and finished the DIY, but however, ...
0
votes
1answer
58 views

PHP OOP MVC Project Structure

I'm a beginner in OOP and PHP frameworks. I used slim skeleton to create a project and designed the project in this way. Project structure is given by the slim skeleton. Object Mappers are added by ...
2
votes
3answers
210 views

Adding / updating user info into MySQL database

I'm working on an app that will be used for employee management and I'm using MySQL for the database. You can add employees, view/update/delete them, and on the dashboard I'm listing them in different ...
2
votes
2answers
72 views

Sanitize vars on form submit

I have this code and I would like to know if I filtered my code correctly. I am practicing my security coding for a system that I am working on and I would like to know if I am doing it the right way. ...