sell website making service

Convert HTML Select Dropdown field to Text Input field in Codeigniter or PHP

In this tutorial, I explore how to convert a select dropdown into a text input field in a CodeIgniter or PHP application. This process is ideal when I need a more flexible input option, allowing users to type in a custom value.

Step-by-Step Guide

Original Dropdown Example: Using a standard select dropdown, the options could be cars (e.g., Volvo, Audi). This setup works for predefined choices but limits user input.

Convert HTML Select Dropdown field to Text Input field in Codeigniter or PHP

Transformation to Text Field: To convert this to a text input, I start by replacing the <select> tag with an <input type="text">. I ensure that class names, IDs, and form controls match the original setup, as many applications rely on proper naming conventions for form elements.

Adjusting PHP Code: The original dropdown might be populated using PHP and connected to a database. However, when I convert it to a text field, the input won’t be tied to predefined values from the database. Instead, users can freely input any value.

Convert HTML Select Dropdown field to Text Input field in Codeigniter or PHP

Important Considerations: I make sure to preserve essential attributes like name, class, and ID, as these are crucial for the form to function correctly in PHP applications. The form will still work without a database, but values will be manually entered by the user.

Code:

<select class="form-control select" name="city" id="city">

 	<option value=""><?php echo $language['lg_select_city'];?></option>

 </select>   
												
												
  <input type="text" class="form-control" name="city" id="city" value="<?php echo $profile['city'];?>">

Conclusion

This simple approach allows for flexibility in cases where a dropdown isn’t the best option. For instance, in fields like “name” or custom user inputs, converting a select dropdown to a text field is a practical solution.

Stay tuned for more tutorials, and don’t forget to like, comment, and share!

How I Used To Work Like Crazy, My Work Life Balance

One thing passed my mind today. Back in the early days, I was 100% focused on client satisfaction. Some of the crazy things I did to make my clients go…WOW!!

  1. I would say I needed 3 days to deliver, but I actually used to deliver within 1-1.5 days by working more than 14 hours per day and night altogether.
  2. I used to work 16 hours per day to over-deliver on what I promised.
  3. I would sleep only 2-3 hours.
  4. I missed going out, family calls, and social functions.
  5. My hair started getting grey before 30.
  6. I would get a new email from a client for a project/task and start working on it without even telling the client, before they even promised to hire or pay for it.
  7. To ensure I could deliver what the client asked for (as most development projects are custom), I would start working on it immediately. When it was done, I would inform the client that I could deliver what they needed. This meant working without any payment security and taking risks to assure the client that their custom task was solvable.
  8. Sometimes, right after getting a new inquiry, I would start learning new technologies and processes to take on the project. Learning new things is a huge pain and tough process.
  9. I would sometimes work for free.
  10. No weekends, no weekdays—every day was a working day.
  11. I literally got sick with headaches, back pain, and sometimes depression.
  12. Some clients would send inquiries at 2 AM on holidays or weekends and demand 2 days of work within 12 hours. To meet such deadlines, I would work continuously and deliver within an impossible timeline. This type of project created health hazards, so I no longer take on such timelines.

The saddest part is that most of the clients I worked crazily for are gone, and 70% of them didn’t come back, though they left excellent feedback and comments. It felt like they were happy with what they got. Most of these clients were from different marketplaces like Upwork, Envato Studio, etc.

I changed some of the ways I used to work and stopped pressurizing myself for my health and mental well-being.

I will still work hard and smart but not crazy and still aim for client satisfaction—that’s what fulfills me.

#ClientSatisfaction #Dedication #HardWork #OverDeliver #ClientSuccess #WorkEthic #TechLife #CustomerService #LearningNewSkills #MentalHealth #WorkLifeBalance #Entrepreneurship #PersonalGrowth #CareerJourney #PHP #SEO #Ecommerce #DigitalMarketing #Rankings  #WebsiteManagement #MarketingInsights #SERP #OnlineBusiness #GoogleRankings #SEOtips #Programming #Coding #WebDevelopment #TechTips #Developers #CodeSnippet #BackendDevelopment #ServerManagement #WordPress #EmailSolutions #WebDevelopment #ClientSupport #WPPlugins #DigitalMarketing #WebDesign #TechTips #TechCommunity #WordPress #VA

PHP program to delete all files in a folder from server

PHP program to delete all files in a folder from server

Imagine a remote control to delete all files in server from a particular folder as soon you type that url and hit enter.

Here is the code:

<?php 
// PHP program to delete all files 
// from a folder 
  
// Folder path to be flushed 
$folder_path = 'getcwd();'; 
  
// Assigning files inside the directory 
$dir = new DirectoryIterator(dirname($folder_path)); 
  
// Deleting all the files in the list 
foreach ($dir as $fileinfo) { 
      
    if (!$fileinfo->isDot()) { 
  
        // Delete the given file 
        unlink($fileinfo->getPathname()); 
    } 
} 
?> 

Where to put this code?

Make a PHP file like example.php and put this file inside the folder with all the files you want to delete.

For example you want to delete all files under folder “website_staging” and url of the the folder is “example2.com/wp-content/website_staging” , put that file example.php inside “website_staging”

How to run the code?

Type in URL “example2.com/wp-content/website_staging /example.php” and hit enter, you will see all files under folder “website_staging” is gone.

Share this article if it helps.

Video on PHP program to delete all files in a folder from server

Check Most Recent Posts