I’m an experienced, dedicated and ambitious Programmer looking for a challenging career as a Web Developer with the opportunity to work with the latest technologies on challenging and diverse projects.
Thursday, January 7, 2021
Tuesday, September 15, 2020
Add Google's reCAPTCHA V2 in Codeigniter and verify reCaptcha
// Controller to Load Recaptcha
$this->load->library('recaptcha');
$recaptcha = $this->recaptcha->create_box();
$data['recaptcha'] = $recaptcha;
$this->load->view('home',$data);
/**************************************************/
// View to Show reCaptcha in Form
<!DOCTYPE html>
<html>
<head>
<title>CodeIgniter reCAPTCHA</title>
<!-- reCAPTCHA JavaScript API -->
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<form action="/path/to/controller">
<?=$recaptcha?>
<button type="submit" name="action" value="submit">Submit</button>
</form>
</body>
</html>/**************************************************/
// Action Controller
public function send_mail() {
$from_name = $this->input->post('name');
$from_email = $this->input->post('email');
$from_message = $this->input->post('message');
$to_email = "zakeerio25@gmail.com";
//Load email library
$this->load->library('email');
$this->load->library('recaptcha');
$this->email->from($from_email,$from_name);
$this->email->to($to_email);
$this->email->subject('contact us form submitted');
$this->email->message($from_message);
$is_valid = $this->recaptcha->is_valid();
if($is_valid['success'])
{
if($this->email->send())
{
echo "success";
}
else
{
echo "failure email";
}
}
else
{
echo "failure recaptcha";
}
}
Further Details:
Tuesday, September 1, 2020
Laravel Redirect HTTP to HTTPS via .htaccess
Today, i share with you, redirect http to Https in laravel
You create file .htaccess in root laravel
RewriteEngine On
RewriteRule ^(.*)$ public/ [L] Way code above it redirect to http, if you want http to https, you can using following code above
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^(.*)$ public/ [L]
</IfModule>
Sunday, August 30, 2020
There is no existing directory at /storage/logs and its not buildable: Permission denied
This issue is resolved by running 3 artisan commands in squence
php artisan route:clear
php artisan config:clear
php artisan cache:clearIt worked fine after running these commands.
Saturday, August 8, 2020
How to change phpmyadmin Path in Linux
sudo nano /etc/phpmyadmin/apache.conf
Change Alias in config File
#Alias /phpmyadmin /usr/share/phpmyadmin
Alias /mydbs /usr/share/phpmyadmin
Save the file and resart apache service
sudo service apache2 resart
then check the url in browser
http://localhost/mydbs/
Wednesday, July 8, 2020
Add directory and set permissions rewritable in Linux PHP
$directory = 'images/author_pic/james';
if(check_dir($directory))
{
echo "Direcotry Created"
} else {
echo "directory not created something went wrong!";
}
// create writable directory or change the chmod permission of chosen directory
function check_dir($dir) {
if (!file_exists($dir)) {
if (mkdir($dir, 0777))// create images dir
$done = true;
} else if (!is_writeable($dir)) {
if (chmod($dir, 0777)) // change perm. setting
$done = true;
} else
$done = true;
return $done;
}
Tuesday, May 12, 2020
Firebase Push Notification in PHP
// Push notification
$message = "This is test message here.";
$this->sendGCM($message, 'CODE_FOR_DEVICES_TO_RECEIVE');
-----------------------------------------------------------------------------------
Callback Funciton
function sendGCM($message, $id) {
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'API_ACCESS_KEY_VALUE' );
$registrationIds = array( $id );
// prep the bundle
$msg = array
(
'message' => $message,
'title' => 'This is a title. title',
'subtitle' => 'This is a subtitle. subtitle',
'tickerText' => 'Ticker text here...Ticker text here...Ticker text here',
'vibrate' => 1,
'sound' => 1,
'largeIcon' => 'large_icon',
'smallIcon' => 'small_icon'
);
$fields = array
(
'registration_ids' => $registrationIds,
'data' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
// curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' );
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );
echo $result;
}