https://software.codidact.com/categories/44/tags/3294.rssNew Posts Tagged 'php' - Software DevelopmentSoftware Development - Codidact2024-03-27T22:43:41Zhttps://software.codidact.com/posts/291175PHP - Why using "global" considered bad?Vanity Slug ❤️https://software.codidact.com/users/609902024-03-27T12:58:43Z2024-03-27T22:43:41Z<p>In PHP why is using <code>global</code> like in the example below <a href="https://stackoverflow.com/questions/8488407/php-global-variable-scope-inside-a-class#comment-10502390">considered bad</...https://software.codidact.com/posts/290696Is there any rationale for the lack of local constants in PHP?klutthttps://software.codidact.com/users/81962024-02-05T04:50:07Z2024-02-05T04:50:07Z<p>The last few years, PHP has basically exploded with lots of modern language constructs that makes the life easier.</p>
<p>But local constants are still missing, and I find that very strange. I ...https://software.codidact.com/posts/290482Having problems with my php scriptzick853https://software.codidact.com/users/756222024-01-01T20:05:45Z2024-01-02T04:29:13Z<p>The exam checking for the backend is working perfectly well but the front end keeps saying an error occurred. Am like ok then tried the demo version replaced the javascript and everything i can ...https://software.codidact.com/posts/290279How to speed up MySQL query?erenlerhakanhttps://software.codidact.com/users/690142023-11-23T11:38:06Z2023-11-25T12:47:42Z<p>I have a website about vacation villa rentals. Around 800 properties are listed. When i start a search, i get properties with my first query which filters type, style, area, no. of rooms, capaci...https://software.codidact.com/posts/289840Adding two products into cart with help of a checkbox.gfthttps://software.codidact.com/users/658842023-09-29T11:06:31Z2023-09-29T11:09:31Z<p>I've created a code snippet in "functions.php" that should add another product to your cart if you mark the checkbox, but somehow, only the original product is add (like the single product from ...https://software.codidact.com/posts/289539Embedding other controller-action with Phalconposthyhttps://software.codidact.com/users/651112023-08-26T21:10:17Z2023-08-27T08:28:26Z<p>I'm trying to revive an old project of mine. It was built with Phalcon
PHP 2 or 3 (I don't even remember which version, but quite old). There I could include a call to the loop inside the contr...https://software.codidact.com/posts/286065Load site based on cookie value in PHPhajakutbudeenhttps://software.codidact.com/users/564202022-03-06T08:11:36Z2023-06-23T21:14:18Z<p>I need to load a site based on a cookie. I wrote code to validate that, like this.</p>
<pre><code>if(!isset($_COOKIE['cookie'])){
$domain = $_SERVER['SERVER_NAME'];
setcookie('cookie'...https://software.codidact.com/posts/288531How to use self referential N-M relationship to make 2 users friends using RedBean PHP ORM?Vanity Slug ❤️https://software.codidact.com/users/609902023-06-19T12:55:56Z2023-06-19T12:55:56Z<p>I am working with PHP and <a href="https://redbeanphp.com/index.php">RedBean PHP ORM</a>. I have a table <code>user</code> like so:</p>
<pre><code>id | username
---|---------
1 | Alice
2 |...https://software.codidact.com/posts/288059PHP code is not excluding the watched videos.Collins https://software.codidact.com/users/597372023-04-16T11:32:57Z2023-04-23T21:40:27Z<p>Can someone explain why this PHP code is not excluding the watched videos?</p>
<p>The <code>email_id</code> parameter is used to specify the location of the watched videos array. The code shoul...https://software.codidact.com/posts/286163How To Verify Old Password in PHP?rrenildopereiraahttps://software.codidact.com/users/564952022-03-27T17:49:43Z2022-03-29T08:40:46Z<ul>
<li>
<p>I have a page to change the user password in my website, this page can only be used if the user have a logged in!</p>
</li>
<li>
<p>The change password page have 3 inputs: Old Pas...https://software.codidact.com/posts/284778How to to make a store tree view cartFyonihttps://software.codidact.com/users/546462021-11-06T03:57:59Z2021-11-07T16:51:28Z<p>I am building an MVC cart system. I have the MERCHANTS table and the PRODUCTS table. A merchant (store) can have one or more products, everything works fine but what I want is to display product...https://software.codidact.com/posts/280937What solutions available for a CMS-agnostic contact form?deleted user#2021-02-28T19:57:12Z2021-10-22T20:11:48Z<p>By principle, I normally work with two different companies for establishing websites for myself:</p>
<ul>
<li>One for <em>domain registration and domain-sole email address</em></li>
<li>One f...https://software.codidact.com/posts/284220Executing a PHP HTML-CSS container on top of various content management systemsdeleted user#2021-09-17T03:28:48Z2021-09-17T14:45:58Z<p>I have created two PHP modules, one is a contact form module and one is a a sticky "call now" module.</p>
<p>I can access the contact form by <code>example.com/contact_form.php</code> but in co...https://software.codidact.com/posts/284089What input functions can I use in TIO's PHP?General Sebast1anhttps://software.codidact.com/users/541142021-09-09T15:01:01Z2021-09-09T16:56:18Z<p><a href="https://tio.run/">Try It Online!</a> is an online interpreter for many supported languages, including <a href="https://php.net/">PHP</a>. I'm trying to solve coding challenges using the...https://software.codidact.com/posts/282532Splitting a large HTML file into two or more HTML files without JavaScriptdeleted user#2021-07-04T07:41:29Z2021-07-05T17:16:57Z<p>I am developing a modular HTML-PHP-CSS no-JavaScript (JavaScriptless) contact form and the HTML is becoming increasingly large, around 80 lines (and could easily grow to be significantly larger ...https://software.codidact.com/posts/281926Is the concept of a PHP lint feasible?deleted user#2021-05-27T15:08:28Z2021-06-03T20:33:35Z<p>When I review JavaScript files in various text editors (Visual Studio Code, Greasemonkey/Tampermonkey) I sometimes get notified about syntax errors.</p>
<p>I never encountered this behavior wit...https://software.codidact.com/posts/281288yyyy/mm/dd instead expected dd/mm/yyyy format in PHP-created-HTML outputdeleted user#2021-04-03T13:58:38Z2021-04-07T22:15:48Z<p>I have an HTML-PHP-CSS contact form with a date field:</p>
<pre><code><input type="date" name="date" id="cf_input_date"></input>
</code></pre>
<ul>
...https://software.codidact.com/posts/281302Backendly redirecting a user from a contact form webpage to a success webpagedeleted user#2021-04-07T15:09:24Z2021-04-07T15:09:24Z<p>On a CentOS Apache-MySQL-PHP environment I have a website with a simple HTML-PHP-CSS contact form; the contact form itself is working.</p>
<p>This is how I backendly redirect a user from the co...https://software.codidact.com/posts/281293PHP for simple HTML-PHP-CSS contact form --- aimed solely for RTL websitesdeleted user#2021-04-05T05:22:03Z2021-04-05T05:22:03Z<p>As a non PHP programmer I have tried to program some basic PHP <code>mail()</code> function code to send Right To Left (RTL) contact form messages to my local email client (i.e. an email client ...https://software.codidact.com/posts/281170PHP emails are sent when $message is a string, but not when its an arraydeleted user#2021-03-25T13:40:01Z2021-03-31T16:46:48Z<p>I host my website on a CentOS-Bash, PHP and MySQL environment; my local email client is engined by <a href="https://roundcube.net/">Roundcube</a>. I don't know almost anything about PHP nuances....https://software.codidact.com/posts/281214Not obligating http:// or https:// in a url field of a contact formdeleted user#2021-03-30T15:46:01Z2021-03-31T05:54:45Z<p>I have a simple HTML-PHP-CSS contact form (no JavaScript) with an <code>input type="url"</code> field.</p>
<p>Currently in 30/03/2021, the default behavior of <code>input type="u...https://software.codidact.com/posts/281193PHP variables aren't expanded when inside HTML which is by itself inside PHPdeleted user#2021-03-28T09:37:41Z2021-03-28T11:15:32Z<p>I transfer emails from my Right To Left (RTL) contact form → to my local email box (powered by <a href="https://roundcube.net/">Roundcube</a>).</p>
<p>Emails reach my email box (inbox) just fin...https://software.codidact.com/posts/281182Are JavaScriptless forms accessible?deleted user#2021-03-27T02:21:33Z2021-03-27T09:24:33Z<p>I consider to make my website's contact form totally javascriptless (only HTML-PHP-CSS --- no JavaScript at all).</p>
<ul>
<li>No modals or alerts</li>
<li>No prevent default</li>
<li>No AJA...https://software.codidact.com/posts/281043Creating a Right-To-Left, primarily-backend, HTML-PHP contact formdeleted user#2021-03-12T17:52:12Z2021-03-13T07:14:31Z<p>I host my website on a PaaS-modeled, shared hosting environment by <em>SiteGround</em> which is quite a well known hosting company with (as I believe) well-venerated email servers.</p>
<hr>
<p...https://software.codidact.com/posts/280490Mocking tempnam() with vfsstreamtyteen4a03https://software.codidact.com/users/537392021-01-15T15:08:05Z2021-02-17T16:39:32Z<p>How do I mock <code>tempnam()</code> with vfsStream for code that uses it to create temporary files (for example, in a PHPUnit test)?</p>
<!-- g: js, mdit -->https://software.codidact.com/posts/279634What are the pros and cons of using objects vs associative arrays for JSON results of a CURL request in PHP?Charlie Brumbaughhttps://software.codidact.com/users/81632020-11-30T20:17:49Z2021-01-19T12:23:35Z<p>I have a PHP script that uses CURL to return a JSON result that looks</p>
<pre><code>//Curl set up code
$result = curl_exec($ch);
//Error checking code
$json = json_decode($result, true);
/...https://software.codidact.com/posts/279149In PHP what is the use case for include instead of require when including PHP scripts?Charlie Brumbaughhttps://software.codidact.com/users/81632020-11-13T20:36:00Z2020-11-13T23:00:37Z<p>In PHP one can either use <code>include</code> or <code>require</code> to include files, the difference is that if the file doesn't exist it will emit a fatal error and halt with a <code>require...https://software.codidact.com/posts/279089Iterating through a MySQL table with a LIMIT clause and PHP gets progressively slowerCharlie Brumbaughhttps://software.codidact.com/users/81632020-11-12T17:29:38Z2020-11-12T23:40:35Z<p>I have a very large table that I need to iterate through with a PHP script and I can't do all of the results at once so I do it in sections with a LIMIT like</p>
<pre><code>for ($x = 0; $x <...https://software.codidact.com/posts/278800PHP script to create a KML square centred on a point.Charlie Brumbaughhttps://software.codidact.com/users/81632020-10-25T20:00:19Z2020-11-08T19:56:04Z<p>The objective here is to create a set of square kml coordinates centered on a point. I use this to create a square map centered on a mountain peak and then turn that into a <a href="https://outd...https://software.codidact.com/posts/277367How to store credentials for PHP scripts on a Windows machine?Charlie Brumbaughhttps://software.codidact.com/users/81632020-08-19T16:18:02Z2020-08-31T14:49:25Z<p>I have a number of command line PHP scripts that are either run by a user or by Windows Task Scheduler.</p>
<p>These scripts use DB and API credentials and I am wondering <strong>if there is a b...