I presently possess a Joomla 1.5 installation, in addition to another website. Both of them reside on a single web server. They're in various folders inside the wwwroot directory, however. I must place a login form inside the non-joomla website, that will log the consumer directly into Joomla. I've already attempted copying and pasting the Joomla login form code right into a page around the non-joomla site, and everything works fine up to the key form value isn't correct. Any assistance is greatly appreciated.

EDIT: This is actually the code-

Contact page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1. Transitional//EN" "http://world wide web.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://world wide web.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />

<title>Untitled Document</title>

</mind>

<body>

<form id="login" title="login" method="publish" action="login.php">

  <label>

  <input title="username" type="text" id="username" value="username" />

  </label>

    <label>

    <input title="password" type="password" id="password" value="password" />

    </label>

  </p>

  <p>

    <label>

    <input type="submit" title="submit" id="submit" value="Submit" />

    </label>

  </p>

</form>

</body>

</html>

Login Script:

<?php

$uname = $_Publish['username']

$upswd = $_Publish['password']

$url = "http://world wide web.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_professional($ch)

if (!preg_match('/title="([a-zA-z0-9])"/', $ret, $spoof)) title='([a-zA-z0-9])'/", $ret, $spoof)



// Publish 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_Publish, 1)

curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields)

$ret = curl_professional($ch)

?>

Ok, to ensure that this to operate here's what must be done -

  1. Produce a new session and obtain the connected token
  2. Pass the username, password, and token to produce a drenched in session
  3. Obtain the new cookie values for drenched in session
  4. Transfer cookie towards the browser

This is actually the code required to accomplish all this:

<?php

$uname = $_Publish['username']

$upswd = $_Publish['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_professional($ch)

if (!preg_match('/title="([a-zA-z0-9])"/', $ret, $spoof)) title='([a-zA-z0-9])'/", $ret, $spoof)



// Publish 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_Publish, 1)

curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields)

$ret = curl_professional($ch)

// Get drenched in cookie and pass it towards the browser

preg_match('/^Set-Cookie: (.*?)/m', $ret, $m)

$cookie=explode('=',$m[1])

setcookie($cookie[], $cookie[1])

?>

This will focus on any Joomla website as lengthy because the URL utilized in the script includes a login form around the page. When you run this script next have the ability to access the web site and become drenched in.