redirect to home page?

A multipurpose module, plugin and component

redirect to home page?

New postby smika » Fri Jun 24, 2011 6:10 pm

Hello,

I made a form to display all birthdays in a specific month. When I try this script on my website without jooma, everything works fine. Also when I make a module from this code, i have no problem.
At this moment I made a menu item from my code and when I try to run it, I see no result and see the home pag from my site. How can I solve this issue?

This is my code:

Code: Select all
<html>
<head>
<title> Verjaardagen</title>
</head>
<body>
<h1>Verjaardagen</h1><br />
Hier ziet u alle verjaardagen! Selecteerd de maand!
<br /> <br />
<form name="form" method="get">
<select name="subject">
  <option value="januari">januari</option>
  <option value="februari">februari</option>
  <option value="maart">maart</option>
  <option value="april">april</option>
  <option value="mei">mei</option>
  <option value="juni">juni</option>
  <option value="juli">juli</option>
  <option value="augustus">augustus</option>
  <option value="september">september</option>
  <option value="oktober">oktober</option>
  <option value="november">november</option>
  <option value="december">december</option>
</select>

<input type="submit" name="Submit" />
</form>

<?php

$dbhost="********"; // Host name
$dbuser="*************"; // Mysql username
$dbpass="***************"; // Mysql password
$dbname="**************"; // Database name

$table = "birthday";

$db = @mysql_connect("$dbhost","$dbuser","$dbpass");
mysql_select_db("$dbname") or die( "Unable to select database. Are you sure the information in config.php is correct?");

// Build SQL Query
if (isset($_GET['subject']))
{
switch($_GET['subject'])
{
case 'januari':
$query = "SELECT date_format(datum, '%d-%m-%Y') as nldatum, naam FROM `birthday` where MONTH(datum) = 01 ORDER by nldatum";
break;
case 'februari':
$query = "SELECT date_format(datum, '%d-%m-%Y') as nldatum, naam FROM `birthday` where MONTH(datum) = 02 ORDER by nldatum";
break;
case 'maart':
$query = "SELECT date_format(datum, '%d-%m-%Y') as nldatum, naam FROM `birthday` where MONTH(datum) = 03 ORDER by nldatum";
break;
case 'april':
$query = "SELECT date_format(datum, '%d-%m-%Y') as nldatum, naam FROM `birthday` where MONTH(datum) = 04 ORDER by nldatum";
break;
case 'mei':
$query = "SELECT date_format(datum, '%d-%m-%Y') as nldatum, naam FROM `birthday` where MONTH(datum) = 05 ORDER by nldatum";
break;
case 'juni':
$query = "SELECT date_format(datum, '%d-%m-%Y') as nldatum, naam FROM `birthday` where MONTH(datum) = 06 ORDER by nldatum";
break;
case 'juli':
$query = "SELECT date_format(datum, '%d-%m-%Y') as nldatum, naam FROM `birthday` where MONTH(datum) = 07 ORDER by nldatum";
break;
case 'augustus':
$query = "SELECT date_format(datum, '%d-%m-%Y') as nldatum, naam FROM `birthday` where MONTH(datum) = 08 ORDER by nldatum";
break;
case 'september':
$query = "SELECT date_format(datum, '%d-%m-%Y') as nldatum, naam FROM `birthday` where MONTH(datum) = 09 ORDER by nldatum";
break;
case 'oktober':
$query = "SELECT date_format(datum, '%d-%m-%Y') as nldatum, naam FROM `birthday` where MONTH(datum) = 10 ORDER by nldatum";
break;
case 'november':
$query = "SELECT date_format(datum, '%d-%m-%Y') as nldatum, naam FROM `birthday` where MONTH(datum) = 11 ORDER by nldatum";
break;
case 'december':
$query = "SELECT date_format(datum, '%d-%m-%Y') as nldatum, naam FROM `birthday` where MONTH(datum) = 12 ORDER by nldatum";
break;
default:
echo 'Geen verjaardagen gevonden!';
}
}

if ($query) {
$resultaat = mysql_query($query);


while($rij = mysql_fetch_array($resultaat))

echo "<br />".$rij['nldatum']." <b>".$rij['naam']."</b><br />";

}

?>

</body>
</html>
smika
 
Posts: 2
Joined: Fri Jun 24, 2011 6:07 pm

Re: redirect to home page?

New postby Simon » Fri Jul 15, 2011 10:01 pm

Hi

Why you connect to database from jumi script?
If you need to connect to other database then joomla uses, use JDatabase::getInstance for that
User avatar
Simon
Site Admin
 
Posts: 1306
Joined: Wed Jul 13, 2011 8:53 pm

Re: redirect to home page?

New postby smika » Sat Jul 16, 2011 5:24 pm

I didn't realize that Jumi can connect to the default database. How can I configure this?

I search in this forum en see the demos, but I didn't find anything about connecting to the default joomla database.

Thanks a lot,

Smika
smika
 
Posts: 2
Joined: Fri Jun 24, 2011 6:07 pm

Re: redirect to home page?

New postby Simon » Sat Jul 16, 2011 6:26 pm

Jumi doesn't need to connect to joomla database. It just includes your script into content. (So you already connected to database).

So you can use database class without any problem.

Code: Select all
$db =& JFactory::getDBO();
$query = "/* some valid sql string */";
$db->setQuery($query);
...
User avatar
Simon
Site Admin
 
Posts: 1306
Joined: Wed Jul 13, 2011 8:53 pm


Return to Jumi

Who is online

Users browsing this forum: No registered users and 7 guests