Tagged Questions
7
votes
2answers
117 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 ...
2
votes
1answer
723 views
Random imgur image loader
Just a little thing I made to load 20 random images from imgur. I looked at the way that imgur references images on its site, and I felt like I could probably generate a random string of letters and ...
2
votes
2answers
56 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 ...
12
votes
3answers
233 views
Prepared statements from security viewpoint
I've decided to go with OOP style and prepared statements, and so far I like it a lot more than the procedural style. It's much more understandable in my opinion.
For this code review, I've just ...
4
votes
1answer
100 views
Image upload script for adding items to a database
I wrote my first simple image upload script that allows users to add items to a database along with pictures of said item. My script takes the images uploaded via a form, processes and resizes them ...
3
votes
1answer
44 views
3
votes
1answer
46 views
Validating various input HTML forms
I'm looking for a review of my code for better syntactical structure (to make sure it's more readable and legible).
...
6
votes
2answers
325 views
Singleton design pattern
I am a beginner in PHP-OOP and design patterns. I have got this basic piece of code in Singleton Pattern and I changed it in order to understand its behavior. I can see that it works as expected.
...
10
votes
3answers
5k views
Basic user registration code
My first attempt at a user registration code.
Login.php defines database log in variables (e.g. Database name, Table name, etc)
...
10
votes
4answers
807 views
Human class implementation
I just want an indication as to whether or not I'm on the right track regarding PHP OOP, at least on a basic level. Positive criticism welcome.
P.S. Excuse the visuals of the code. This is how I ...
5
votes
2answers
125 views
UK tax calculator
I'm very much on the beginner end of the PHP scale but I have read plenty of the entry level books and completed the online training at teamtreehouse.com so I know the basics.
I'm at a point where ...
1
vote
2answers
146 views
Too many nested blocks fixed but not sure if this way is right
I have previeous;y posted my php code with way to many nested blocks I hope I fixed it right.
I'd also like some tips on my OOP, as this is new to me.
...
4
votes
2answers
236 views
I have a huge function filled with nested blocks
Could someone help me on how to eliminate some nested blocks or improve this code? I am concerned this will slow down my site dramatically.
...
1
vote
0answers
181 views
Unzip and move function
I'm a PHP novice and so looking for some advice on a PHP function I have created to use within a WordPress installation.
As you can see from the code below, it runs when one of the admin's press ...
5
votes
1answer
73 views
Trying to create login
I'm new to PHP and web development in general. Is this a good coding style for me as a beginner? I don't care about password hashing. I use MD5 which is, as far as I know, not a good encryption ...
5
votes
2answers
56 views
Including a file (is this safe and effective?)
I'm not that experienced with PHP and I'm trying to make it so when I load a page, instead of directly browsing to the file, it will be "included" instead.
I have the code finished and it works. I ...
3
votes
1answer
110 views
Dynamically-loading interactive table
I've got a page on a website that shows a table, and upon clicking on a row in the table, it can dynamically load in more results. I am new to jQuery though.
index.php page:
...
5
votes
1answer
89 views
Safety issues in PHP log-in system
This is a user login (some session wrapper I managed to put together after a lot of web searching).
It's for a simple CMS I'm trying to build. It only needs one user and there is no need for ...
6
votes
3answers
73 views
Select input that is generated and populated with options
I started to learn PHP OOP recently and searched the web for some practical exercises and I found one that said to build a select input that is generated and populated with options by the object. I ...
2
votes
2answers
135 views
11
votes
6answers
756 views
Are there any open vulnerabilities in this mailer script?
I made a PHP mailer script does the basic validation of fields, return errors, else submit if all is good. But it also has a honeypot field that is not required to be filled in (I'm assuming by hiding ...
3
votes
3answers
100 views
Get contents from file
The following PHP code does exactly what I need it to do but, as a complete PHP novice, I am wondering: what can be improved here?
...
3
votes
2answers
149 views
PDO MySQL spaghetti coding
I'm new to this PDO PHP and I have coded this spaghetti style. I hope you can give me idea how to improve using prepared statements. I'm not a lazy person, but I really need your help to improve my ...
3
votes
0answers
92 views
Is this a good PHP strategy pattern?
I am a very beginning in PHP and Design Patterns. I have been studying the amazing Head First Design patterns. So, I have been trying to translate the original to PHP. The class is working well. ...
5
votes
2answers
121 views
OOP approach to using DOMDocument
I've tried to write an "OOP" approach to printing a website using the DOMDocument class. I'm kind of stuck here because I feel like I am blundering in how I am passing and using the DOMDocument. I ...
6
votes
3answers
196 views
JS validation and submission with AJAX
I've got an assignment to do pure JS validation as well as submit with AJAX. Here is the code I've got so far. I'm wondering if I can do away with the whole "reason" bit. That was because it was ...
-2
votes
1answer
98 views
5
votes
1answer
433 views
GIF to HTML5 video conversion
I'm still at a very beginner level and I'm constantly working on small things to try and develop my skills. I'm hoping someone could just give me a quick review if there's anything obviously horrible ...
10
votes
2answers
191 views
Review structure of PHP/HTML
I am very new to PHP and I kind of sort of want to create the pages like I would in ASP.NET; it's just the way I am wired. I have been inserting the header/menu using a PHP Include and here is what ...
5
votes
1answer
127 views
Best Practices concerning Includes and SQL Connect Strings
I'm just starting to learn PHP. I have three random questions about PHP and one question about Code Review. None of them are technical questions ("will this work?"); they're best practices questions ...
9
votes
1answer
292 views
PHP form review
I saw somewhere on here that it helps reduce spam by adding a dummy input field that you hide with display: none, and like if it's filled out, then it's obviously ...
1
vote
2answers
620 views
Secure image upload class
I am new to Code Review and PHP.
Last night I made the below image uploading class. It was the first time I made a file uploader to be used on a real site, so I thought I would share it here and on ...
3
votes
1answer
2k views
PDO Login/Register system review
I wrote my very first login/register PDO system today. I know there is still a lot of flaws, but I was wondering what tips and advice you have to help me improve this. I know that PDO is much more ...
1
vote
3answers
3k views
Basic slot machine game
I have been learning PHP and wanted to see if I could make a very simple slot machine game. Everything works, but I'm sure this is not the best way to do this. Please let me know how you would do ...
-1
votes
1answer
1k views
Sending form input to URL and retrieving JSON response [closed]
I am trying to take the form input, send its values to this URL, and retrieve the JSON response.
Should this code work? I'm fairly new to this stuff, so my apologies if things are not quite right.
...
1
vote
1answer
95 views
Updating visiting dates of each visitor
I am still a PHP beginner. Please review/improve my PHP code and reveal errors, typos and warnings.
...
2
votes
1answer
1k views
Converting entire table to JSON data. Is there a better way?
Building a 'card' database: I'm simply learning to take input data and store to database. Incorporating JSON, PDO, SQL, and enforcing my general coding skills through PHP, hopefully.
...
2
votes
3answers
130 views
Making PHP/WordPress code more efficient
I'm beginning with PHP programming and would appreciate a critique on my code and how I could make it more efficient, rather than repeating the if statements.
What I'm basically doing is getting the ...
1
vote
0answers
97 views
Trying to understand hooks class
I've built a small hooks class for adding some capabilities of basic plug-in functionality.
Is there room for improvement? I am just beginning to learn OOP, so ...
1
vote
1answer
147 views
Feedback on a small PHP function that generates JSON data
I wrote a PHP function that generates JSON data to populate a line graph. Through jQuery, my code uses a GET request to the PHP script to fetch the JSON data. An example of the JSON data is as ...
0
votes
2answers
79 views
Can I improve my code?
I'm a PHP newbie and I have a question. Is there a better way to do this? A nice solution? I know this site isn't called RewriteMyCode but maybe I can get some tips at least
...