Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4029408
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:20:30+00:00 2026-05-20T11:20:30+00:00

I currently have a Joomla 1.5 installation, as well as another website. They both

  • 0

I currently have a Joomla 1.5 installation, as well as another website. They both reside on the same web server. They are in different folders within the wwwroot directory, however. I would like to place a login form within the non-joomla website, which will log the user in to Joomla. I have already tried copying and pasting the Joomla login form code into a page on the non-joomla site, and everything works fine up until the secret form value is not correct. Any help is greatly appreciated.

EDIT:
Here is the code-

Contact form:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="login" name="login" method="post" action="login.php">
  <label>
  <input name="username" type="text" id="username" value="username" />
  </label>
    <label>
    <input name="password" type="password" id="password" value="password" />
    </label>
  </p>
  <p>
    <label>
    <input type="submit" name="submit" id="submit" value="Submit" />
    </label>
  </p>
</form>
</body>
</html>

Login Script:

<?php
$uname = $_POST['username'];
$upswd = $_POST['password'];
$url = "http://www.mywebsite.com/joomla_site/index.php";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt($ch, CURLOPT_COOKIEJAR, './cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, './cookie.txt');
curl_setopt($ch, CURLOPT_HEADER, FALSE );
$ret = curl_exec($ch);
if (!preg_match('/name="([a-zA-z0-9]{32})"/', $ret, $spoof)) {
    preg_match("/name='([a-zA-z0-9]{32})'/", $ret, $spoof);
}

// POST fields
$postfields = array();
$postfields['username'] = urlencode($uname);
$postfields['passwd'] = urlencode($upswd);
$postfields['lang'] = '';
$postfields['option'] = 'com_login';
$postfields['task'] = 'login';
$postfields[$spoof[1]] = '1';
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$ret = curl_exec($ch);
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:20:30+00:00Added an answer on May 20, 2026 at 11:20 am

    Ok, in order for this to work here is what needs to be done –

    1. Create a new session and get the associated token
    2. Pass the username, password, and token to create a logged in session
    3. Get the new cookie values for logged in session
    4. Transfer cookie to the browser

    Here is the code needed to accomplish all of this:

    <?php
    $uname = $_POST['username'];
    $upswd = $_POST['password'];
    $url = "http://joomla website.com";
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url );
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE );
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE );
    curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE );
    curl_setopt($ch, CURLOPT_COOKIEJAR, realpath('./cookie.txt'));
    curl_setopt($ch, CURLOPT_COOKIEFILE, realpath('./cookie.txt'));
    curl_setopt($ch, CURLOPT_HEADER, TRUE );
    $ret = curl_exec($ch);
    if (!preg_match('/name="([a-zA-z0-9]{32})"/', $ret, $spoof)) {
        preg_match("/name='([a-zA-z0-9]{32})'/", $ret, $spoof);
    }
    
    // POST fields
    $postfields = array();
    $postfields['username'] = urlencode($uname);
    $postfields['passwd'] = urlencode($upswd);
    $postfields['option'] = 'com_user';
    $postfields['task'] = 'login';
    $postfields[$spoof[1]] = '1';
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
    $ret = curl_exec($ch);
    
    // Get logged in cookie and pass it to the browser
    preg_match('/^Set-Cookie: (.*?);/m', $ret, $m);
    $cookie=explode('=',$m[1]);
    setcookie($cookie[0], $cookie[1]);
    ?>
    

    This should work on any Joomla website as long as the URL used in the script has a login form on the page. Once you run this script you should then be able to access the website and be logged in.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to manually migrate a Joomla website to another server (shared hosting). Our
I have created a new website for a client, (joomla) which is currently running
Currently I have a dedicated server with WHM and Joomla running. I want to
I currently have $ echo `echo use joomla; describe jos_content | mysql --batch -u
If i look into PHP they have Joomla, although it was initially build for
I currently have a Joomla 1.5 site with VirtueMart installed. The hierarchy of product
I have custom Joomla(v1.5) component and currently working with component's router. The problem is
I have multilingual website in joomla and want to hide one menu item (not
I have an old joomla installation which was hacked. All I know for now
I have a (Joomla) site that is not currently pointing to a domain, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.