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
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
vote
1answer
578 views

Printing results in XML

I have been writing PHP programs in the MVC pattern for quite some time. But I am not sure if I am doing it right. For instance, I have this PHP file that prints results in XML, and I put this file ...
-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 ...
-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 ...
5
votes
2answers
4k views

Retrieving all the email addresses on a web page

I recently discovered the file_get_contents function and wanted to put it to some use, alongside preg_match_all, off the ...
-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 ...
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
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 ...
3
votes
1answer
2k views

Send blob image using Ajax/PHP

I have an image cropper that crops the uploaded image, Before sending it to the server using PHP and AJAX. Here is a live fiddle to preview a working cropping example. Here is the code: ...
-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:- ...
3
votes
1answer
85 views

Refreshing / Cycling through a parsed RSS feed every 5 mins

I am working on a monitor signage display and have a "welcome to RSS" feed with just a title and description. I have code from feedEk that's been tweaked a bit to parse the feed and cycle it so I only ...
-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 ...
2
votes
1answer
101 views

Bool function in PHP to check if you run the script inside docker

I had to do a CLI script that does something, I also had to add a validation that checks if it runs inside the Docker. After some research I found a solution that people check some processes via ...
-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
2answers
418 views

Efficient Strip Special Characters

I have a private function in PHP that takes a given URL string and just leave the Alpha or numeric and certain punctuation left. I need the stripping of string due to having it match against ...
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 ...
4
votes
1answer
131 views

File uploads in Laravel - Single and multiple

I have been reading up on file uploads in Laravel, reading through the documentation and looking at best practices. In my application, I have two instances: an upload area for single files, and an ...
0
votes
1answer
91 views

Retrive relation on a polymorphic model

I have a Game model that is "static". Containing game information and such, and users can comment on all games. Games model <...
3
votes
1answer
128 views

Bill settlement for multiple users

I want to improve the logic for bill settlement and calculation of amount due. I managed to write code with T.D.D., but I think those loops could be improved somehow. Do you have any ideas on that ...
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 ...
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: ...
0
votes
2answers
57 views

Preventing XSS in Input $_POST Form

I tried to prevent XSS attacks by adding ...
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 ...
3
votes
2answers
280 views

PHP function to convert a Portuguese word from plural to singular

I know, this sounds really difficult, but it is really easy. I needed to convert a single Portuguese word in the plural into singular. I know there's a right name for that, but it is escaping me. ...
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
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 ...
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 ...
3
votes
4answers
8k views

Performance: getting first value from comma delimited string

I've got a string that has values that are delimited by comma's, like so: $var = '1,23,45,123,145,200'; I'd like to get just the first value, so what I do is ...
2
votes
1answer
750 views

BDD tests in PHPUnit

No one in my team knows how to write BDD tests, so I started writing some and it's quite working well. I think the time has come to improve the code quality. This contains a lot of duplicated code ...
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 ...
4
votes
1answer
95 views

Effective to-do list in PHP and jQuery AJAX

I made this to-do list since I never seriously used jQuery (in particular way AJAX) and I need this kind of script for a project that I'm working on. Principal features: Use of a database to manage ...
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 ...
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: ...
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
1answer
1k views

Escaping XML to be used with SOAP [closed]

I'm attempting to escape ampersands from a string before passing to PHP's SimpleXMLElement->addChild() for use with some SOAP webservices, but I don't want to ...
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 ...
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. ...
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 ...
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 ...
14
votes
6answers
4k views

Palindrome checking function

I recently did a little task for fun that required me to create a class to determine if a word is a palindrome or not. I know this is quite simple, but I'd be interested to know if a real developer (I'...
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, ...
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. ...
0
votes
2answers
38 views

Wrapping certain elements in an array with an array with PHP

I have a function that's doing this correctly, but I feel as though this can be done (possibly) with minimal code, with recursion, but I'm just wracking my brain. Basically I have JSON that gets ...
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 ...
5
votes
2answers
749 views

Login with facebook, store data in MySQL, render profile and admin panel

I have an online catalog on which I need the customers to save their favorite products and shipping addresses. I want to manage the access with Facebook for security of all. I also need a section for ...