Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all 14348 articles
Browse latest View live

how to access database created with dbforge

$
0
0
Hello!

I'm kinda new with dbforge. I have some questions.

1. If a database is created using dbforge, can you use query builder for the dynamic database(insert, update, delete)?  

2. If you can't use query builder on the dbforge created database, do you just have to build queries with "$this->db->query("YOUR QUERY")"?

3. How do you "select" the dbforge created database to preform queries on? ("$this->db->query('use db2');" so, this is the 'use' statement and it works the same as in SQL syntax?)

Thank you!

Redirect() ignore baseURL?

$
0
0
I have some troubles with the redirect function.

I test my code with MAMP on my Mac. I don't want to set up multiple subdomains so I have multiple CI4 installations in subdirectories like this:
http://localhost:8888/ci4-test1/public/index.php
http://localhost:8888/ci4-test2/public/index.php
http://localhost:8888/ci4-test3/public/index.php

I submit a form to this URL:
http://localhost:8888/ci4-test1/public/index.php/some_controller/save/1

...after the data is updated in the database, I want to redirect to:
http://localhost:8888/ci4-test1/public/index.php/album/edit/1

But here is my problem. It redirect to this URL and gives a 404 not found error:
http://localhost:8888/some_controller/edit/1

In .env I set the baseURL like this:
app.baseURL = 'http://localhost:8888/ci4-test1/public/'

In my controller I do the redirect like this:
return redirect()->to('/some_controller/edit/' . $id');

What am I doing wrong? Why is the directory name 'ci4-test1/public' not in the destination URL?

About All Members Count?

$
0
0
Hi,

How can I make show the total number of members registered in Codeigniter?

Model? Controller? View?

Facebook composer library for login - class not found

$
0
0
Hello! 

In CI3 sites that I have, to create a facebook login with PHP SDK, I use the instructions from this page ( https://shareurcodes.com/blog/facebook%2...odeigniter ) .

The problem is that in CI4 I get the following error: "Class 'App\Controllers\Facebook\Facebook' not found"
The error is on this line: "$fb = new Facebook\Facebook"

Please help.

CI4: How to run modules in views?

page load slowly and also rotating anticlock wise

$
0
0
how to check page load error. It rotating reverse side at initial stage after some time it loaded. is it a page problem or network problem or anyother problem

.jpg   pagerotate.jpg (Size: 18.03 KB / Downloads: 1)

Is there a way to migrate existing session data from DB to files?

$
0
0
I regret choosing DB as my session driver now, it is too slow. how do I change to files driver without log out all of my users? Is there a way to do this? Please help.

Thanks

How to create Do follow link for my website

$
0
0
I recently create a website for my small business. Everybody say to create backlink but i don't know how to create that. If you want to check my *SEO LINK REDACTED* , no problem .. but if you have any solution about this problem, kindly help me..

Multiple File zip in CI

$
0
0
I have multiple image in folder,And i get it on Href button so how to zip that file in codeingiter

HERE is MY View Code:


Code:
<a href="<?php echo base_url()."index.php/itr1/download/".$key['pan_card']."/".$key['previous_itr'] ?>" name="images">Downalod All Attachments</a>


Here my Controller:


Code:
public function download()
{
   // File path
   $id =  $this->uri->segment(3);
   $id1 =  $this->uri->segment(4);

   $filepath1 = FCPATH.'upload/'.$id;
   $filepath2 = FCPATH.'upload/'.$id1;

   $filename = "backup.zip";
   $this->zip->download($filename);
}

How to seperate admin and regular user with one login

$
0
0
Good day everyone!

I have my login working fine but wanted to see how does an admin and basic connect using only one login? Here is my login code:

<?php
// Initialize the session
 if(!isset($_SESSION)) { session_start(); }
// Check if the user is already logged in, if yes then redirect him to welcome page
if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){
    header("location: welcome.php");
    exit;
}
 
// Include config file
require_once "application/config/database.php";
 
// Define variables and initialize with empty values
$username = $password = "";
$username_err = $password_err = "";
 
// Processing form data when form is submitted
if($_SERVER["REQUEST_METHOD"] == "POST"){
 
    // Check if username is empty
    
    if(empty($_POST["username"])){
        $username_err = "Please enter username.";
    } else{
        $username = trim($_POST["username"]);
    }
    
    // Check if password is empty
    if(empty($_POST["password"])){
        $password_err = "Please enter your password.";
    } else{
        $password = trim($_POST["password"]);
    }
    
    // Validate credentials
    if(empty($username_err) && empty($password_err)){
        // Prepare a select statement
        $sql = "SELECT id, username, password FROM users WHERE username = ?";
        
        if($stmt = mysqli_prepare($link, $sql)){
            // Bind variables to the prepared statement as parameters
            mysqli_stmt_bind_param($stmt, "s", $param_username);
            
            // Set parameters
            $param_username = $username;
            
            // Attempt to execute the prepared statement
            if(mysqli_stmt_execute($stmt)){
                // Store result
                mysqli_stmt_store_result($stmt);
                
                // Check if username exists, if yes then verify password
                if(mysqli_stmt_num_rows($stmt) == 1){                    
                    // Bind result variables
                    mysqli_stmt_bind_result($stmt, $id, $username, $hashed_password);
                    if(mysqli_stmt_fetch($stmt)){
                        if(password_verify($password, $hashed_password)){
                            // Password is correct, so start a new session
                            session_start();
                            
                            // Store data in session variables
                            $_SESSION["loggedin"] = true;
                            $_SESSION["id"] = $id;
                            $_SESSION["username"] = $username;                            
                            
                            // Redirect user to welcome page
                            header("location: welcome.php");
                        } else{
                            // Display an error message if password is not valid
                            $password_err = "The password you entered was not valid.";
                        }
                    }
                } else{
                    // Display an error message if username doesn't exist
                    $username_err = "No account found with that username.";
                }
            } else{
                echo "Oops! Something went wrong. Please try again later.";
            }
        }
        
        // Close statement
        mysqli_stmt_close($stmt);
    }
    
    // Close connection
    mysqli_close($link);
}
?>
 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
        <style type="text/css">

    :Confusedelection { background-color: #E13300; color: white; }
    ::-moz-selection { background-color: #E13300; color: white; }

    body {
        background-color: black;
        margin: 40px;
        font: 20px normal Helvetica, Arial, sans-serif;
        color: #4F5155;
        text-align: center;
        color: #708090;
    
 
    }

    a {
        color: #003399;
        background-color: transparent;
        font-weight: normal;
    }

    h1 {
        color: #800000;
        background-color: transparent;
        
        font-size: 40px;
        font-weight: normal;
        margin: 0 0 14px 0;
        padding: 14px 15px 10px 15px;
        text-align: center;
    }

    code {
        color: #800000;
        font-family: Consolas, Monaco, Courier New, Courier, monospace;
        font-size: 20px;
        background-color: #f9f9f9;
        border: 1px solid #D0D0D0;
        color: #002166;
        display: block;
        margin: 14px 0 14px 0;
        padding: 12px 10px 12px 10px;
    }

    #body {
        margin: 0 15px 0 15px;
    }

    p.footer {
        text-align: center;
        font-size: 12px;
        position: fixed;
   left: 0;
   bottom: 0;
   width: 100%;
        line-height: 32px;
        padding: 0 10px 0 10px;
        margin: 20px 0 0 0;
            color: #800000;
    }


    
.button {
  display: inline-block;
  padding: 15px 25px;
  font-size: 24px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  outline: none;
  color: #708090;
  background-color: #800000;
  border: none;
  border-radius: 15px;
  box-shadow: 0 9px #708090;
}

.button:hover {background-color: #800000}

.button:active {
  background-color: #800000;
  box-shadow: 0 5px #708090;
  transform: translateY(4px);
}

#main {
  width: 70px;
  height: 200px;
 
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-align-content: center;
  align-content: center;
}

#main div {
  width: 70px;
  height: 70px;
}

a:link {
  color: #800000;
  background-color: transparent;
  text-decoration: none;
}
    </style>
</head>
<body>
    <div class="wrapper">
        <h2>Login</h2>
        <p>Please fill in your credentials to login.</p>
        <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
            <div class="form-group <?php echo (!empty($username_err)) ? 'has-error' : ''; ?>">
                <label>Username</label>
                <input type="text" name="username" class="form-control" value="<?php echo $username; ?>">
                <span class="help-block"><?php echo $username_err; ?></span>
            </div>    
            <div class="form-group <?php echo (!empty($password_err)) ? 'has-error' : ''; ?>">
                <label>Password</label>
                <input type="password" name="password" class="form-control">
                <span class="help-block"><?php echo $password_err; ?></span>
            </div>
            <div class="form-group">
                <input type="submit" class="btn btn-primary" value="Login">
            </div>
            
            <p>Don't have an account? <?= anchor('register/pass','Sign up now');?>.</p>
        </form>
    </div>    
</body>
</html>


What do I add that when the Admin logs in they are redirected to admin dashboard?



Heart Heart ,
Mekaboo

language abbreviation in url

$
0
0
Hello everybody,

I am working with codeigniter 4. I have a problem.
how can i recognize language abbreviation in url.

with
PHP Code:
$routes->get('{locale}/books''App\Books::index'); 

I tried but the problem is the following.

1. for all routes {locale} must be defined.
2. without language abbreviation the controller is not found.
3. $routes->setAutoRoute(true); no longer works.

it has to work like this:
when user enters the URL:
http://www.domain.com requires its browser language to be recognized and redirected to http://www.domain.com/en/

and if user enters the URL http://www.domain.com/de/ the locale must be changed in German.

this must work as well:
http://www.domain.com/contoller/method redirect to http://www.domain.com/en/contoller/method

I look forward to your suggestions
thanks

Load Model giving Error 500

Database Migration confusion

$
0
0
Hi guys

Currently trying to wrap my head around database migrations, and I guess I just dont get how they are supposed to be used.

I can see that you can create database tables, and also drop them, but what I dont see in the documentation is, say you want to add a field to a table, have you got to create the table again in another file with the changes, or just issue an update?

If someone could explain how they use them it would be appreciated.

Thanks

Switching to memcache for sessions

$
0
0
Hello,

I need to save sessions to memcache instead of files in my local instance of codeignitor.

This is what I did:
Step 1 : updated config.php
$config['sess_driver'] = 'memcached';
$config['sess_save_path'] = 'localhost:11211';


Step 2: update php.ini
session.save_handler=memcached
session.save_path="tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15" 

Step 3: Restart apache

This works fine.

Now when I need to deploy this to the server, I came to know that I am not allowed to update the ini settings because Im using shared services. 

My question is: how do I set session.save_handler and session.save_path via code in codeignitor and not depend on updating php.ini of the server?

how to use if condition in array variables?

$
0
0
How to use if condition in array
Code:
$insert = array();
       $insert[] = array(
           'appno' => $appno,
           'regno' => $regno,
          'certid' => $certid,
             'amt' => if($certid=1,8500 else 300 ,
             'date' => $today
               );      

Can I use system variables or functions if using view parser

$
0
0
I've worked through the tutorial (https://www.codeigniter.com/userguide3/t...index.html) - very good BTW - and the decided to redo it using the parser library for all views/templates instead of php. Now while I've managed to get the examples to all work ok, I have some questions:

- The input form example wants to display validation errors using validation_errors() function. Cam this be called/shown is a view rendered via the parser library? Or do we have to collect any errors in a parser friendly format and inject them as 'data'?

- It would be good reference base_url in the for input view, instead of just hoping that relative paths work ok - is this possible?

Cheers
Mark

Codeigniter + Blade + Eloquent

What is the name what is the name of these design?

$
0
0
 What is the name what is the name of these design?

   i want to make a design for my *REDACTED* website[/font][/b]

Have look on the attachment file.


Please help me out 



Thanks

 Debabrata Dutta
*SEO SPAM LINKS REDACTED*

.png   Capture.PNG (Size: 170.91 KB / Downloads: 1)

How to add scroling effect on my website ?

$
0
0
How to add scroling effect on my website ?


Hello, Everybody


I hope your well and fine.

I want to make a Scroling Effect. It's that possible..!


Please help me out 



Thanks

Debabrata Dutta

*SEO SPAM LINK REDACTED*

localhost is currently unable to handle this request. HTTP ERROR 500

$
0
0
I have this error when i am trying to access a website from wamp, it is done in codeigniter.
Error:

Code:
localhost is currently unable to handle this request. HTTP ERROR 500

homeindex controller

Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class HomeIndex extends CI_Controller {

   public function __construct(){
       parent:: __construct();
       $this->load->helper('html');
       $this->load->helper('form','url','file');
       $this->load->library('session','upload');
   }

   public function index()
   {  
       //$this->load->view('coming_soon');
       $this->load->view('homeIndex');
   }
}

route

Code:
$route['default_controller'] = 'HomeIndex';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

I am able to access other website which are not done using any frameworks.
This website is done using codeigniter. I am not able to access the website.
Can anyone tell me what is the problem?
Viewing all 14348 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>