Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Wednesday 14 September 2022

File Upload with new name Codeigniter

 HTML

<form method="post"  action="<?php echo site_url('/Admin/newsadddb'); ?>" enctype="multipart/form-data">

 <input type="file" name="NewsFile" id="NewsFile" style="display:none">

<input type="submit" name="submit" value="Save" class="btn btn-danger" >

</form>

Monday 11 July 2022

Google Recaptcha Integration | PHP , ASP.NET C# , Codeiginater 4

 




Wednesday 29 June 2022

Unable to write in session folder in windows 10 using Codeigniter 4

 This post is applied on following Codeigniter Error

  • Unable to write in session folder in windows 10 using Codeigniter 4
  •  SYSTEMPATH\Session\Handlers\FileHandler.php at line 102
  •  Uncaught Exception: Session: Configured save path
  • CodeIgniter\Session\Exceptions\SessionException

Solution 

I solved this issue... for anyone experiencing this... changing permissions to anything didn't work. Somehow they had been corrupted on the actual folder so I deleted the cache folder and session folder and created new folders and replaced the contents (files ended up not being an issue). This fixed my issue.

Note: In my case, this error occurred due to google cloud backup because I was working simultaneously while the backup is running and Google Backup corrupted the session folder. 

Friday 8 April 2022

Send Whatapp message from contact form | PHP

 

PHP Code

<?php

if(isset($_POST['submit']))
{

 

$str="https://wa.me/+91-9795000000?text=";

$str.="Roll%20:%20" . preg_replace('/ /','%20',$_POST['Roll']);

$str.= ",Name%20:%20. preg_replace('/ /','%20',$_POST['Name']);

$str.=",City%20:%20" . preg_replace('/ /','%20',$_POST['City']);

header("Location: $str");
}

?>          


HTML

<form method="post" style="margin:4%">

 

    <input type="text" name="Roll" /><br />

    <input type="text" name="Name" /><br />

    <input type="text" name="City" /><br />

    <input type="submit" name="submit" value="Send" />

 

</form>


Tuesday 15 March 2022

Layout In CI

Step 1 :

Make a folder named shared in app/Views

Step 2 : 

Make 3 files named menu.php,footer.php,layout.php

menu.php : will hold menu of website

layout.php : will hold master layout page for your website

footer.php : will hold footer code 

Thursday 10 February 2022

Begin CodeIgniter 4.1.8

Whoops! We seem to have hit a snag. Please try again later

Solution : 


Your PHP is missing intl extension. It is useful for formatting currency, number and date/time as well as UCA-conformant collations, for message formatting and normalizing text..etc.


Follow the steps to install it in XAMPP -

  • Open [xampp_folder_path]/php/php.ini to edit.
  • Search for ;extension=intl and remove the ;.
  • Save the php.ini file and restart Apache.

Sunday 14 November 2021

Layout/Master page in laravel

Layout/Master page in laravel

Making Layout or Master page in laravel is very simple . Go through the given steps below.

Step 1: Make a view named Layout.blade.php

Make a view for layout named layout.blade,php in resources\views folder.

Friday 12 November 2021

User difined function Laravel

 We make user difined function to reuse code. To use user difined function you need to follow the steps
given below.

  • Make your file in app folder and write your code in that file . In my case file name is helper.php and funtion name is Title . i.e.
function Title()
{
   echo "Girfa IT Services";
}
  • Goto  composer.json file and add the following lines in autoload section.In my case pagelib.php is my file. Write your file name.
        "autoload": 
        {
        "files" :["app/pagelib.php"],
        },
  • Now you can call the function inside of helper.php  file , anywhere in your project.
Note : Run given command  for update your function

          composer dump-autoload 

Then, in your hosting site, you can update two files, autoload_classmap.php and autoload_static.php, manually in vendor/composer folder. I prefer to copy and paste the added classes from local to the hosting server

Save form data into database

 This post will help  step by step to understand , how to save your HTML form data into Mysql Database.

Database Table structure 


Form

Step 1

Make  HTML Form , code is given below

<form method="post" action="index">

    @csrf

    Name : <input type="text" name="name" placeholder="Your Name" required class="form-control"><br>

    Phone : <input type="text" name="phone" required placeholder="Phone Number" class="form-control"><br>

    Message :

    <textarea rows="5" name="message" required placeholder="Message" class="form-control"></textarea><br>

    <input type="submit" value="Save" name="submit">

</form>


Step 2 


Create Model by given command

php artisan make:model stumodel 

Model Location :  app\Models

Model Code

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class stumodel extends Model
{
protected $table = 'kashiquery';
    use HasFactory;
public $timestamps=false;
protected $fillable = [
'name', 'phone','message','createddate'
];
}

Step 3 : Create Controller


Create controller by given command below

Command : PHP artisan make:controller common

Controller location : app\Http\Controllers

Code

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\stumodel;
class common extends Controller
{
    public function AddData(Request $req)
{
        $data=new stumodel;
//$r = $req->input();
$data->name=$req["name"];
$data->phone=$req["phone"];
$data->message=$req["message"];
$data->createddate=date("Y-m-d");
$data->save();
return redirect('index');
    }
}
 

Step 4 : Configure Route


Route File Location : \routes\web.php 

<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\common;


Route::get('/', function () {
    return view('index');
});
Route::view('index','index');
Route::post('index',[common::class,'AddData']);





Friday 29 October 2021

Laravel command for beginners

 

Create and run project using composer

composer create-project laravel/laravel your-project-name

cd your-project-name

Goto project folder i.e your-project-name

php artisan serve

Next Topic

Thursday 22 April 2021

PHP 404 page handling

 

PHP 404 page handling

Server shows 404 error code when requested resource not found at server. By default, the browser display 404 error page .which is not as user-friendly because it does not show our website look and layout. if you want to custom 404-page handling page then this post will help you. to do the above let follows the steps given below.