PHP is a widely-used, general-purpose scripting language that is especially suited for web development.
-1
votes
0answers
13 views
PHP USB serial port call from Windows to Linux [on hold]
I have a piece of simple code that works on a Windows - WAMP environment, e.g.
...
0
votes
1answer
16 views
PHP script to connect to MySQL database using PDO
Introduction
I am preparing to use a basic script to cover how you can connect to a MySQL database using PDO. This script is meant for educational purposes (introductory class on PHP/MySQL) and does ...
2
votes
0answers
13 views
Boarding cards route finder
Recently I had an interview project, which I did and sent, so this question is not for avoiding thinking. I am just struggling to build my own opinion about it so I decided to ask in public.
My ...
4
votes
0answers
37 views
Handling CSRF protection
I'm currently working on an implementation of a CSRF protection. What is the best practice when we detect a CSRF? Is it better to 404 the page, 403 (forbidden), 200 (OK) with an error message, ...
-3
votes
0answers
21 views
Major difficulties turning this into prepared statement [on hold]
I have been wrapping my head around making this more secure by using prepare statements but my attempt has failed.
Below is the original:
...
1
vote
0answers
35 views
Multiple 0-1 knapsack type solution (Bin Packing)
I had a problem similar to the 0-1 knapsack problem, only that I have multiple knapsacks (bins) of the same capacity. Given a set of items (pool) can another item be added to it and then be ...
0
votes
1answer
18 views
Applying prepare statements
I don't feel that my code is secure, and would like some help in using prepare statements for the following;
...
2
votes
1answer
48 views
Using $_POST and $_SESSION - passing variables between pages
I have an index page which gets passed $_POST['timestart'] and $_POST['timeend'] variables. In addition, I have a cart page ...
-4
votes
0answers
30 views
0
votes
0answers
23 views
Implementing DES algorithm in PHP on linux [closed]
I wrote this PHP script trying to implement DES algorithm.
I'm running it on terminal, not browser, with
php des.php AAAAAAAA AAAAAAAA
Here the script
...
-2
votes
2answers
69 views
Using a lot of IF in loop WHILE to print information
I made a code and it is doing what I want.
But, I would like to know if I am doing it right or in the best way.
Could you please give me your thoughts about it? Thank you.
...
1
vote
1answer
59 views
Checking whether a site is up or down
I have this PHP curl function to check if a site is online or not:
...
-1
votes
0answers
20 views
PDO object directly in while-loop instead of from a variable [closed]
I thought this should work:
...
2
votes
3answers
101 views
Checkout (page) backend
I am developing an e-commerce site and am confused about this.
Customers come on the site and add some products to the cart.
Customers click on the checkout link if already logged in, then will go ...
5
votes
3answers
211 views
String to Array formatting
I'm tying to convert from this formatted string:
$filtersStr = "id:1||name:alex";
to:
['id' => 1,'name' => 'alex']
...
5
votes
1answer
25 views
Volunteer Signup Report - follow-up
Here is the original question. I've incorporated a lot of the feedback and I'm ready for another round of feedback and suggestions.
Here is the PHP file's output. It creates a volunteer signup report ...
4
votes
0answers
118 views
Small PHP-MVC system (for personal learning / use)
I've made an "simple" / "small" MVC-like PHP system. I've used some code of an project I used before and ask questions about it back then to.
The thing is, it works (the admin part to begin with), ...
2
votes
2answers
68 views
Registering usernames and passwords to a database
Here is my script that registers a user to a database. I am still very much a newbie when it comes to this topic so any guidance would be greatly appreciated.
...
0
votes
1answer
44 views
Update live table in MySQL
After populating the stock_tmp table, i'm running these SQL queries via legacy mysqli wrapper code. I don't think this code ...
3
votes
1answer
45 views
Loading files or directories based on type
I am building a config class for PHP which initially loads all given config files. To add files, users should be able to provide either a single file or a directory where files can be JSON or PHP.
...
1
vote
1answer
32 views
Handle data received by Ajax request and update database (prepared statement)
I have an Ajax request from a page where the user is being asked to enter their date of birth. The request URL file has the code below and works all good. However, I'll be rewriting all MySQL/MySQLi ...
0
votes
1answer
32 views
Use header application/x-download
Zend framework 1. Physically, the file does not exist, it is created based on database.
Okay so use header?
...
1
vote
3answers
52 views
Print Bootstrap 3 Tabs Component using only one foreach Loop
I'm using Bootstrap 3 to build a tab-panel component, based on information coming from the end-user. I don't like how there's a second foreach loop, but I don't know how else to print the HTML ...
0
votes
1answer
41 views
Basic sign-up method, testable and with try/catch [closed]
I am learning how to implement testing and try/catch statements into my code. I have a Laravel application with the following ...
3
votes
3answers
57 views
Grabbing hashed password from a database
I have just discovered the beauty of prepared statements in PHP and how they protect against SQL injection. In my first time using them, I am attempting to grab a hashed password from a database and ...
3
votes
1answer
56 views
PHP password encryption algorithm
I've written a password encryption algorithm in PHP, which (I think) is not very vulnerable to rainbowtable attacks. It's just that I don't have a lot of experience with encryptions, nor PHP. But from ...
0
votes
0answers
50 views
Simple Router class
I made a simple routing class that I like to get reviews for, mostly because I do not know how to make it SOLID, since I even made this class separate from the HTTP response, request ... for the sake ...
0
votes
1answer
76 views
MySQL JOIN to JSON array
I'm building a HTTP API and this part should return a JSON list of posts and their attached photos, like this:
...
2
votes
2answers
77 views
Immutable subclass of a Set class
If I'm creating an immutable class from an existing class, should I override methods that mutate the property or have an instance of it and write my own methods to read from the property?
I have an ...
6
votes
2answers
284 views
Password hashing and matching
I took information from a series of posts and some prior knowledge to implement the following hashing algorithm.
However, there is a lot of talk about what implementations are secure and not secure. ...
1
vote
3answers
106 views
Count specific array values
I want to count specific strings from array values
$array = array("report=D","report=D","report=D","report=I","report=I");
I am going to count the number of ...
5
votes
2answers
38 views
Volunteer Signup Report
I was creating a Volunteer Signup Report report in Microsoft Excel yesterday for my job and I had a moment of inspiration. What if I turned it into a website and made it dynamic? The volunteers sign ...
1
vote
1answer
43 views
Laravel controller for a grocery list
What I have is a grocery list. Once I select a grocery by ticking the checkbox, I can select an amount for that product and a unit (unit is referred to in my below code as group). Once I am done, I ...
1
vote
1answer
156 views
Simple PHP session handler class (using MySQL for session data storage)
I have tried to write a small light weighted php session handling class that use PHP's session_set_save_handler() function to overwrite the default session handling ...
3
votes
1answer
115 views
Basic login script for educational purposes
I have created a login script to demonstrate the usage of sessions in PHP. The focus is not on security, databases or encryption. The idea is to exemplify how you can use sessions to protect pages ...
-1
votes
2answers
70 views
Learning OO PHP: Am I doing this with “good practices”?
Trying to practice some OO PHP and I'm just wondering if what I'm doing is okay or not. Please tell me if there are any alarms in my method so that I can stop doing it and learn a better way.
In my ...
5
votes
2answers
77 views
Password recovery program
This is a password recovery program I made, and I just want it checked out.
These aren't all the files for the login and register system, only the password recovery part. The columns in the ...
3
votes
1answer
30 views
Validate profile completeness
This function checks these 6 fields for a user profile to determine if they have "completed" their profile. This just feels like it could be done better, but I can't figure how.
...
1
vote
2answers
45 views
Comparing two almost exact arrays
I have two arrays:
$row
$rowTwo
The only difference between these two arrays are the first two keys have slightly different ...
-2
votes
5answers
90 views
What is the better way to write such code in PHP?
Is there a better way to write the below code?
...
3
votes
1answer
23 views
Exception Handler on a Switch
I am working on rewriting an application in Laravel 5.1. I am new to the exception handling technique introduced in 5.0. I have overlooked taking advantage of throwing/catching exceptions frequently ...
1
vote
0answers
32 views
Chunked file upload
I'm working on an PHP application that will allow (but not require) chunked file upload (from jQuery File Upload on the front side). I tried to find appropriate code and was only able to find the ...
1
vote
1answer
48 views
Receiving an language string from file
I'm receiving an language string out of an PHP file which returns an array like this:
DIR_LANG\en\home.php:
...
2
votes
2answers
164 views
Session Handling Setup
Just wanted to run through my PHP session handling and get some feedback and tips with regard to what is good (if anything!), what could be better and what is either plain wrong, or using out of date ...
1
vote
0answers
15 views
Web Scraping class schedules
I just want some advice regarding code style and best practices. Also I want to know if I'm using constant declaration and closures properly.
This code is used to get the data from here ...
1
vote
1answer
34 views
Resize images in the background after upload
I have working code that uploads and resizes images. What im trying to figure out is how I can direct the browser to another page or view kind of the way facebook does, but still call the resize ...
0
votes
1answer
60 views
1
vote
1answer
43 views
Website register functionality
I have two links in my header:
Register
Login
I am not creating it dynamically. If the user clicks on "login," the login form will be visible, similarly for the register form.
My registration:
...
1
vote
1answer
30 views
Selecting orders submitted by a user, segregated by status
I have recently started using Laravel as my chosen framework. It is my first time using a framework. As I have made progress through my project, my controller methods have started to increase in size. ...
4
votes
2answers
215 views
Upload a photo with a unique name using PHP
I have written a script for basic uploading of a single image to a web server using PHP. This is an example that is intended for educational purposes in a basic PHP course. It does not take extensive ...