Search found 41 matches

by iago
Sun Mar 21, 2021 3:07 pm
Forum: PHP General
Topic: Switch case replace old value with new value
Replies: 1
Views: 894

Re: Switch case replace old value with new value

Where do these new values for each trail (for each data set) come from?
by iago
Sat Mar 20, 2021 7:34 am
Forum: PHP Scripts
Topic: How to shorten a text?
Replies: 2
Views: 1254

Re: How to shorten a text?

Do you have some code?
by iago
Fri Mar 19, 2021 2:29 pm
Forum: PHP General
Topic: Question regarding Sessions
Replies: 2
Views: 1086

Re: Question regarding Sessions

$_SESSION is an associative array, but you can do s.th. like: $_SESSION['foo']['bar']
by iago
Fri Mar 12, 2021 8:26 am
Forum: PHP coding => General
Topic: create "state" with php / file upload
Replies: 2
Views: 1136

Re: create "state" with php / file upload

Thanks for the answer strider64! I'm still working on a tool of my last job. We had a text editor with special texts for our customers. I improved that editor and I'm still improving that. (perhaps I can sell it to the company one day :D ) The new editor should be able to import files that contain J...
by iago
Wed Mar 10, 2021 8:27 am
Forum: PHP coding => General
Topic: create "state" with php / file upload
Replies: 2
Views: 1136

create "state" with php / file upload

Hello, I would like to make a file upload (JSON) then import the data into the db then destroy the file. I want to create some "state", so that if the user has not imported the data yet (also after logout-login) he will always be prompted to import the data or abort the process. What would be the be...
by iago
Sun Feb 14, 2021 11:08 am
Forum: PHP coding => General
Topic: refactor class for HTTP request
Replies: 0
Views: 1184

refactor class for HTTP request

Hello, I wrote an HTTP class in order to handle my http requests from the front-end. My question to the php pros here is, how can I refactor it concerning security and performance. The DB class uses PDO + prepared statements and should be o.k. So I just want to focus on the HTTP class. E.g. I submit...
by iago
Mon Dec 28, 2020 2:59 pm
Forum: PHP coding => General
Topic: router, how to improve that
Replies: 3
Views: 3841

Re: router, how to improve that

Code: Select all

 That code is just poor programming in my opinion and my new advice is to find something better. Sorry about that.
I wanted to write a SPA, but I cannot stand theres JavaScript guys from these frameworks (vue/react) anymore. Less than you. Just regard it as a compliment.
by iago
Sat Dec 26, 2020 4:34 pm
Forum: PHP coding => General
Topic: router, how to improve that
Replies: 3
Views: 3841

router, how to improve that

Hello, I wrote some kind of router for a multipage php application How could I improve/refactor that code? Here is the index.php code (Input::get('...') just returns $_GET['...'] ) <?php require_once 'core/init.php'; if(Session::exists('home')) { echo '<p>'.Session::flash('home').'</p>'; } $user = n...
by iago
Thu Dec 17, 2020 1:36 am
Forum: PHP Scripts
Topic: OOP in php, object structure, handling
Replies: 2
Views: 1606

OOP in php, object structure, handling

Hello, I have the following object handling from a tutorial and I don't understand why the object is passed to another variable and then the other variable is then used as the referent? (by the way I get an error message when I do it like that) if(Input::exists()) { if(Token::check(Input::get('token...
by iago
Thu Dec 17, 2020 1:26 am
Forum: PHP Scripts
Topic: Can't get PHP to produce Alert() box
Replies: 2
Views: 1591

Re: Can't get PHP to produce Alert() box

What does dbCheck() exactly return?
by iago
Mon Nov 23, 2020 5:15 am
Forum: JavaScript
Topic: APIs forever (with problems)
Replies: 0
Views: 1109

APIs forever (with problems)

Hello, My intention was to focus on frontend dev., now I stuck with API requests (no data -> no frontend) I was about to build up a small app with the data of the yahoo finance API. Here I have a problem with CORS. Even a CORS proxy (see below) does not work. Ok, taking a step back, I chose https://...
by iago
Sun Aug 30, 2020 1:39 am
Forum: PHP coding => General
Topic: error in Validation class / check method (for HTML form)
Replies: 2
Views: 1287

Re: error in Validation class / check method (for HTML form)

HTML has the required attribute, so if you want to make a field required then simple do so in HTML I'm completely with you. The point is the code is from a tutorial, and the teacher has a specific way to program the things. Now, I can check if the code works without the "required"-check, but if not...
by iago
Sat Aug 29, 2020 1:19 am
Forum: PHP coding => General
Topic: error in Validation class / check method (for HTML form)
Replies: 2
Views: 1287

error in Validation class / check method (for HTML form)

Hello, I have a Validation class here, where I validate user input from a HTML form. I have an array of presettings that I pass to a check method of the Validation class. I first of all check if the input fields are empty or not, also checking there with the help of the presettings array if it is re...
by iago
Thu Jul 30, 2020 3:44 am
Forum: PHP coding => General
Topic: redirect, trying to get rid of "#" at the end of an URL
Replies: 8
Views: 2780

Re: redirect, trying to get rid of "#" at the end of an URL

The $this--> is OOP as it is a way to use an argument(variable) and I still need to refine the script a little. You are using object orientation a littel bit here and a little bit there, but that's not a clear structure. That's not a class hierarchie that you are building up that enbales you to wri...
by iago
Fri Jul 17, 2020 1:15 am
Forum: JavaScript
Topic: put xml data into table (DOM parser)
Replies: 2
Views: 1529

Re: put xml data into table (DOM parser)

Ok, I put everything in an multidimensional array so that I'm more flexible.

I wonder why something like this does not work??

Code: Select all

 let tableFields = [];

first loop:
 tableFields.push(channelName[i].firstChild.nodeValue); 

 second loop:
     tableFields[].push(title[j].firstChild.nodeValue);
by iago
Wed Jul 15, 2020 2:47 am
Forum: JavaScript
Topic: put xml data into table (DOM parser)
Replies: 2
Views: 1529

put xml data into table (DOM parser)

Hello. I want to display the current Britsh TV in a table: here is the feed: http://www.xmltv.co.uk/feed/7365 I start with the channel and the programm. I've already made a list by looping through the nodes. It looks like that: <li>channel1</li> <li>programm<li> <li>programm<li> <li>channel2</li> <l...
by iago
Sun Jul 12, 2020 11:40 pm
Forum: PHP coding => General
Topic: OOP, composition does not work (user, userllist)
Replies: 2
Views: 1250

Re: OOP, composition does not work (user, userllist)

which is not used, not an error, but may lead to confusion. I instantiate user also directly and invoke its methods, which is not recommended, but it makes things a bit easier. That works perfectly fine. I start the script with: error_reporting(-1); Concerning the error I also checked the source co...
by iago
Sun Jul 12, 2020 2:03 am
Forum: PHP coding => General
Topic: OOP, composition does not work (user, userllist)
Replies: 2
Views: 1250

OOP, composition does not work (user, userllist)

Hi guys, I'm digging deeper into OOP and t 'm trying to use composition for implementing a userlist class (with user objects) (as adviced by a Java senior developer of my company). However, this does not work with my PHP code here. Does anybody see the mistake? I invoke: $usersList->printUsersList()...
by iago
Wed Jun 17, 2020 5:14 am
Forum: PHP coding => General
Topic: redirect, trying to get rid of "#" at the end of an URL
Replies: 8
Views: 2780

Re: redirect, trying to get rid of "#" at the end of an URL

Why are you using a function for a login?
Because I separate the controler or view (depending on how to consider the index.php) from the model.
by iago
Wed Jun 10, 2020 5:43 am
Forum: PHP coding => General
Topic: redirect, trying to get rid of "#" at the end of an URL
Replies: 8
Views: 2780

Re: redirect, trying to get rid of "#" at the end of an URL

The following is how I do my login for my trivia game. The $this--> is OOP as it is a way to use an argument(variable) and I still need to refine the script a little. php is not really an object oriented language compared to Python or Java. What is the benefit for writing $this->query instead of ju...
by iago
Wed Jun 10, 2020 4:48 am
Forum: PHP coding => General
Topic: redirect, trying to get rid of "#" at the end of an URL
Replies: 8
Views: 2780

Re: redirect, trying to get rid of "#" at the end of an URL

The code you've posted shouldn't be causing this problem on its own. Are you using any javascript at all? Not for this. When I take the header command out of function, I have the same result: if(isset($_POST['submit'])) { $error = array(); if(empty($_POST['username'])) { array_push($error,"Please e...
by iago
Wed Jun 10, 2020 2:06 am
Forum: PHP coding => General
Topic: redirect, trying to get rid of "#" at the end of an URL
Replies: 8
Views: 2780

redirect, trying to get rid of "#" at the end of an URL

Hello, I make a redirect from a login page to my index.php. A "#" is added to the index.php ( http://localhost/cpicks/index.php# ), that makes problems later on when I use the application. Where does this come from, how can I get rid of that? Here is the login function within login.php, that initiat...
by iago
Sat May 30, 2020 10:14 am
Forum: PHP coding => General
Topic: return $error[] for fileupload, best options?
Replies: 4
Views: 1500

Re: return $error[] for fileupload, best options?

If you are referring to the error array, no, same reason given above. Do you understand why I'm asking this? I have the error array but I need the redirect in order to avoid that the browser executes the same commands in case s.b. refreshed the site. (POST-redirect-GET). When I use the redirect the...
by iago
Fri May 29, 2020 11:03 am
Forum: PHP coding => General
Topic: return $error[] for fileupload, best options?
Replies: 4
Views: 1500

Re: return $error[] for fileupload, best options?

Code: Select all

Why? if there are errors, represent the form highlighting the errors with a a hint as to why the check failed.
Good call!
Because the browser is LOCKED when I do not use: POST,redirect-GET.
by iago
Fri May 29, 2020 4:23 am
Forum: PHP coding => General
Topic: return $error[] for fileupload, best options?
Replies: 4
Views: 1500

return $error[] for fileupload, best options?

Hello, I'm about to write a script for uploading JSON-files. As far as I understand it I cannot use AJAX for the file upload (JS is blocked here), so I go the traditional way, just submitting the form. If I want to give out an error (array) then, I cannot just do it like that, since I have to redire...