PHP is a widely-used, general-purpose scripting language that is especially suited for web development.
-1
votes
0answers
13 views
just one email at every two minutes swiftmailer is not helping me [on hold]
I am trying send some emails with swiftmailer and a smtp relayer at two minutes interval. I need to send as many as 300 emails, and each email must hit each recipient's indox at the rate of just one ...
4
votes
2answers
45 views
Would this be considered MVC?
For many days, I've been re-designing my application, applying some custom pattern and making our code looks like a framework. I have something like this for separate the business logic, from views:
...
0
votes
1answer
65 views
Did you like my product?
I have the following MySQL query which selects product details and whether the viewing user likes them. I feel like it could be more efficient and that there is a more practical approach than using a ...
1
vote
0answers
25 views
Themed Folder Classification
I am trying a very simple method of getting the theme information via a theme.xml within each theme folder.
What it should do:
Scan the theme directory ../themes
Return the names of all the theme ...
-3
votes
0answers
20 views
Why isn't my PHP working? (mysql_fetch_array() expects parameter 1 to be resource) [on hold]
Why isn't this code working? I've already checked by echoing $salt and it echos out the salt on the page, so I know it's nothing to do with the salt.
...
-3
votes
0answers
16 views
Rewriting Dynamic URL with .htaccess not working [on hold]
I am working on a e-commerce website and I am trying to make its URL better. I enabled Apache configuration, then created a .htaccess file, but my URL is still the same. I am not able to figure out ...
0
votes
0answers
18 views
Error handling within functions [on hold]
I am wondering how to handle this error.
A cron calls this function regularly (every 10 minutes): userNotifications()
...
2
votes
2answers
35 views
Checking empty object
Is there a better method for covering errors in my case? I am looking for best practice for now and future instances.
Foreseen errors that could arise:
No attributes at all
Some attributes could be ...
2
votes
0answers
40 views
Validator extended to handle domain objects / entities
I started improving my validator library even more, and I think I'm at the last final element (domain object / entity validations) before I can gladly say that my Validator library is completely done ...
3
votes
1answer
46 views
My first login class in PHP with PDO and bcrypt
This is the first time using a class. Please review this and tell me if it's secure and if it's the right way to do it. The code itself is working, but I have doubts in the way I used all this.
...
1
vote
3answers
111 views
Security of code snippets
Last time I made a website using PHP, I didn't know of PDO, so someone dropped all my tables. I think I've made an improvement now. I'm sorry if there's a lot to go through, but I want to make sure ...
5
votes
1answer
43 views
3
votes
2answers
65 views
POST security with PDO?
So I have some code that works as PDO. But is it secure? I'm trying to prevent SQL injection. This is my first PDO script and was hoping to see if it was done correctly. Here it is.
...
2
votes
0answers
23 views
Update database, reload page then show a success message
I have spent a long time trying to find a way to do the following:
Update a MySQL database with AJAX
Reload the Page to show changes
Show a success message
I think I have finally found a way! ...
4
votes
1answer
195 views
Have I prepared this prepared statement well?
This is a prepared statement (I think). Have I done this well?
...
4
votes
1answer
32 views
Simple file downloader
On my website I want to offer some PDFs, ZIP files and images for download. They are all in the same folder and I could simply link to them like ...
3
votes
0answers
24 views
Detect prefered language
I am using this script to detect the most prefered language by the user.
...
5
votes
2answers
67 views
Update of Classes for user registration and authentication
Old Post: Classes for user registration and authentication
This post is an update of the old post of mine. This is the code after suggestions were implemented in the review. Do you think I could make ...
0
votes
2answers
32 views
5
votes
1answer
56 views
3
votes
0answers
35 views
Laravel - Repository and Entity patterns
I've spent quite a bit of time studying the repository and entity patterns and this is what I came up with. I would appreciate it if you could post suggestions and critique.
...
2
votes
1answer
25 views
Login System Security Part 2
Old code:
Login system security
This is an update on the code and suggestions I received from generous users on the old thread.
So same rules apply, just check it out, tell me what you think. Is ...
3
votes
1answer
52 views
Laravel - lots of dependency injection
I have the following UserServiceProvider and I'm wondering whether so much dependency injection is overkill:
...
4
votes
2answers
52 views
Cleaning up validator class
I updated my class with more functionality, but I kind if feel like it's a mess or that it can at least be improved by a bit readability, efficiency and/or DRY wise.
Anybody who could see if that can ...
7
votes
3answers
457 views
Is this PHP code snippet safe?
Mostly asking for critiques of vulnerability. Am I using any functions or methods that are unsafe?
...
2
votes
2answers
59 views
Preg_match pattern for user input filtering
My users may need to supply a 'disease category' to my site. I need to let them use all alphanumeric characters, hyphens and single quotes. Would someone review this to see if they feel it's ...
4
votes
2answers
78 views
Validator refactored to be OO
Based on my previous post I completely re-factored my code to make it object oriented.
Anything I could improve when it comes to:
Object oriented code;
Efficiency;
Readability.
Any other ...
4
votes
1answer
90 views
Login system security
Here is a login system I am working on. I just want an opinion on it and whether I am going in the right direction or am just completely missing something.
The main thing I would like to know is: am ...
2
votes
2answers
93 views
Form with a country list statically or dynamically generated
I want to create a form with a country drop down list so I can just google and get all the countries but the question should I just encode it statically or generate dynamically with PHP. (Note it ...
4
votes
2answers
52 views
Optimizing cron job for sending reminders
The following script is being run with a cron. It runs once a minute to see if there is a reminder that needs to be sent.
Should I make this run once every 30 minutes? The choices to send a reminder ...
-1
votes
0answers
25 views
PHP While Loop 2 difference class [closed]
I have a problem.
I want show 2 images or 2 link videos or 1 images 1 link videos together but image/videos not appear, because 2 difference class.
...
7
votes
1answer
88 views
PHP isset over use? Good or bad?
First, I'm in no way an experienced PHP coder. This is my 5th time working with PHP, so if you see anything that can bee improve, please point them out for me.
I have the code checking for the ...
0
votes
0answers
12 views
Simple Query Using Multiple AND/ORs with PDO [closed]
I am trying to get a simple password from my technician's database but it seems that the $query line is not running. I am new to this PDO idea and I am not sure what to use for this either query or a ...
4
votes
1answer
36 views
Secure Functions in a Database Class
I am trying to solve as many issues as possible with my Database Class and bind statements as far as possible without actually doing it in the front-end. The goal is to do all of the heaving lifting ...
1
vote
0answers
25 views
How to regenerate my session ID often when using this class?
I have created a class that will manage my session. I am hoping to acomplish a class that will secure my site from all known attacks (ie. fixation, precedent, and capture.)
The idea is to
Change ...
3
votes
2answers
75 views
Getting cars and bicycles from a database and writing them into two different arrays
I've written a simple class which should:
get 10 top cars and 10 top bicycles from database
write them into 2 different arrays
It works, but I'm trying to find a simpler or clearer solution.
...
3
votes
3answers
76 views
Add “1” and overwrite the previous value [closed]
I have a cookie where a number is stored.
When I want to add "1" to the stored number and then overwrite it, I use this php code:
...
5
votes
1answer
38 views
explode textarea and commas [closed]
Am attempting to recreate a common feature, where a user can type several items in to a textarea, separated by commas and newlines and then submit them, i.e. for multiple record entry.
The data does ...
2
votes
1answer
41 views
Script for adding a set of form fields on clicking an Add More button
This is a script that I use to add a set of form fields on clicking an Add More button:
...
1
vote
2answers
84 views
PHP Router for MVC
I recently started developing my first serious project in PHP, a MVC completely build by myself, which is quite a challenge, when being new to OOP.
So the main struggle of the whole project has, and ...
2
votes
2answers
55 views
String sanitisation function
I have a search function on my website. In addition, elsewhere I have a place where users can submit categories for their posts. I want the categories to have an uppercase first letter and the rest ...
4
votes
2answers
149 views
Injections and query
I made a class that connects to my DB and inserts some values. Is it secure or how can I protect this further from injections? The object declaration will come from variables with POST from a form, ...
6
votes
1answer
140 views
Converting any PHP function toString() like in JS
In JavaScript, any function is basically an object on which you can call (function(){}).toString() to get it's underlying code as a string.
I'm working on a ...
1
vote
2answers
83 views
SQL Injection when not using variables
Do I still need to protect my code against SQL injection when I'm not using variables in SQL queries?
Is this code still vulnerable?:
...
5
votes
2answers
64 views
Benchmarking our LAMP servers with this php script
I've written a small script to benchmark our LAMP hosted servers that assess the performance based on three factors:
Disk I/O
Database I/O (mysql)
Database I/O (sqlite)
The logic is as follows:
...
2
votes
2answers
78 views
Should a PDO object be passed to classes and procedural functions as a parameter?
I've been trying to figure out the best way to manage database connections for a while now and am still unsure of how I should be doing things. I know there are a lot of similar questions on here, but ...
0
votes
1answer
29 views
PHP ImageMagick Image Processing Class
I've written an image processing library for downscaling, sharpening, compressing and caching images using PHP and ImageMagick.
Having recently been a chef in the kitchen of procedural and vague ...
2
votes
1answer
97 views
SQL injection security
I wanted to know if this code is safe against SQL injection or not?
Also do I need to mysqli_close if I already did the ...
2
votes
1answer
43 views
DB security and efficiency in WordPress plugins
I recently wrote my first WordPress plugin, which was also my first PHP project. After I was done, I didn't care for the code at all, so I have spent the past couple of days refactoring it. I'm trying ...
1
vote
1answer
61 views
A cart that uses SessionID
I wanted to create a cart that I can easily add some item or simply help someone at the other end over the phone. I decided to create a cart that would store everything on MySQL instead of using ...