How to include PHP and javascript code in articles ?

This forum is for general questions about extensions for Joomla! version 1.5.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Roops
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Jan 11, 2011 3:20 pm

Re: How to include PHP and javascript code in articles ?

Post by Roops » Fri Jan 21, 2011 12:17 pm

Hi tobypsl,

Thanks a lot for replying me.

I have downloaded Joomla Sourcerer Extension. I have gone through the install.txt file for steps to install it manually.

I am not able to understand where to place the "files/content" folder in my wamp/www/ folder.

will you please, let me know. where will be the root folder for website or is there any alternative way to install Joomla Sourcerer Extension.

Thanks
Roops

tobypsl
Joomla! Apprentice
Joomla! Apprentice
Posts: 46
Joined: Tue Nov 14, 2006 10:21 pm

Re: How to include PHP and javascript code in articles ?

Post by tobypsl » Fri Jan 21, 2011 5:35 pm

Hi Roops

I haven't used a local install for around 7 years, when Joomla was mambo so I can't recall how I used to install extensions then. I've never done a manual install with Joomla, always through the management console.

However I've checked the directory structure and the Sourcerer extension has unzipped in the plugin directory in a folder called editors-xtf.

So with joomla installed directly in httpdocs on my server the directory structure is: httpdocs/plugins/editors-xtd/

I haven't checked to see if there is a table in the mysql DB and wouldn't know whether plugins routinely create DB entries for themsleves or not. I am sure the plugin must be at listed in the DB for it to appear in the management console plugins list.

hope this is some help.

cheers, Toby

Roops
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Jan 11, 2011 3:20 pm

Re: How to include PHP and javascript code in articles ?

Post by Roops » Fri Jan 21, 2011 6:53 pm

Hi Toby,

I have installed my joomla on WAMP server, I mean to say, my directory structure is c:/wamp/www/joomla.
As per your reply, I found my editors-xtd in c:/wamp/www/joomla/plugins/editors-xtd. So, I have unzipped joomla sourcerer extensions in folder editors-xtd and where I can find these changes.
Will you please, let me now. What’s the next step?

Thank you,
-Roops

Roops
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Jan 11, 2011 3:20 pm

Re: How to include PHP and javascript code in articles ?

Post by Roops » Mon Jan 24, 2011 2:09 pm

Hi everybody,

I m stuck'd with editing PHP code in article.
I have web page called enrollment in my website, where i fill the form and submit.
as soon as i submit, the data should be in my database. i use WAMP as my server.

when i click on submit button.
I get the following error message:

"404 Forbidden

You don't have permission to access /joomla/< on this server."

Can you please help me at this point. its urgent!!!!

Cheers
Roops

tobypsl
Joomla! Apprentice
Joomla! Apprentice
Posts: 46
Joined: Tue Nov 14, 2006 10:21 pm

Re: How to include PHP and javascript code in articles ?

Post by tobypsl » Mon Jan 24, 2011 2:18 pm

Roops wrote:As per your reply, I found my editors-xtd in c:/wamp/www/joomla/plugins/editors-xtd. So, I have unzipped joomla sourcerer extensions in folder editors-xtd and where I can find these changes.
Hi Roops, is there a reason why you have not installed Sourcerer via the extension manager in Joomla ? That is, why have you chosen to install manually ?

Roops
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Jan 11, 2011 3:20 pm

Re: How to include PHP and javascript code in articles ?

Post by Roops » Mon Jan 24, 2011 3:07 pm

Hello Toby,

Thanks for your Reply. I have got installed successfully with Sourcerer extension.

I ill get back to you, If i need any suggestions.

Hope you will be in touch.

Cheers
-Roopa :)

tobypsl
Joomla! Apprentice
Joomla! Apprentice
Posts: 46
Joined: Tue Nov 14, 2006 10:21 pm

Re: How to include PHP and javascript code in articles ?

Post by tobypsl » Mon Jan 24, 2011 3:13 pm

So is your php editing issue resolved now ? or is that a seperate issue ?

Roops
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Jan 11, 2011 3:20 pm

Re: How to include PHP and javascript code in articles ?

Post by Roops » Tue Jan 25, 2011 3:27 pm

Hi Toby,

I have got problem with my code.

where my website contain ENROLLMENT PAGE, Where i need to enter some data like:
name
telephone
email
no_of_classes
fee
About_my_classes.

my code looks like this:-


<html>
<head>
<body>
<h1> enrollment</h1>
<form action="$_PHP_SELF" method="post">
Name:<input type="text" name="Name" value=""/>
Telephone:<input type="text" name="Telephone" value=""/>
Email: <input type="text" name="Email" value=""/>
How many classes would you like to attend?:<input type="text" name="No_Of_Classes" value="" />
How would you like to pay?<input type="text" name="Fee" value=""/>
How did you find out about my classes?:<input type="text" name="About_My_Classes" value="" />
<input type="submit" name="submit" value="Submit!" />
</form>
<?php
$dbhost= 'localhost';
$dbuser= 'root';
$dbpass= '';
$db='zumba';
$conn=mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($db);
$query="select *from enrollment";

$result=mysql_query($query);

while($enrollment=mysql_fetch_array($result))
{
echo "<h4>" . $enrollment['Name'] . "</h4>";
echo "<h4>" . $enrollment['Telephone'] . "</h4>";
echo "<h4>" . $enrollment['Email'] . "</h4>";
echo "<h4>" . $enrollment['No_Of_Classes'] . "</h4>";
echo "<h4>" . $enrollment['Fee'] . "</h2>";
echo "<h4>" . $enrollment['About_My_Classes'] . "</h4>";
}
$name=$_POST['Name'];
$telephone=$_POST['Telephone'];
$email=$_POST['Email'];
$no_of_classes=$_POST['No_Of_Classes'];
$fee=$_POST['Fee'];
$about_my_classes=$_POST['About_My_Classes'];

if(!$_POST['submit'])
{
echo "please fill out the form";

} else {
mysql_query("INSERT INTO enrollment(Name,Telephone,Email,No_Of_Classes,Fee,About_My_Classes)
VALUES ('$name','$telephone','$email','$no_of_classes','$fee','$about_my_classes')");
echo " \n in else my name is $name";

mysql_close($conn);
}
?>
</body>
</head>
</html>

When i attempt to refresh my enrollment page,Entire code itself is displayed on my page.

will you please suggest me some solution for this problem.

Thank you,
Roops

Roops
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Jan 11, 2011 3:20 pm

Re: How to include PHP and javascript code in articles ?

Post by Roops » Sun Feb 06, 2011 1:45 pm

Hi Toby,

I am waiting for your reply.

I have got problem with my code.The problem is when i click on to the submit button, my data will not be stored in the database. instead ,Entire code itself is displayed on my page.

Can you please check my code.

where my website contain ENROLLMENT PAGE, Where i need to enter some data like:

name
telephone
email
no_of_classes
fee
About_my_classes.

my code in article for Enrollment Page looks like this:-


<html>
<head>
<body>
<h1> enrollment</h1>
<form action="$_PHP_SELF" method="post">
Name:<input type="text" name="Name" value=""/>
Telephone:<input type="text" name="Telephone" value=""/>
Email: <input type="text" name="Email" value=""/>
How many classes would you like to attend?:<input type="text" name="No_Of_Classes" value="" />
How would you like to pay?<input type="text" name="Fee" value=""/>
How did you find out about my classes?:<input type="text" name="About_My_Classes" value="" />
<input type="submit" name="submit" value="Submit!" />
</form>


<?php
$dbhost= 'localhost';
$dbuser= 'root';
$dbpass= '';
$db='zumba';
$conn=mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($db);
$query="select *from enrollment";

$result=mysql_query($query);

while($enrollment=mysql_fetch_array($result))
{
echo "<h4>" . $enrollment['Name'] . "</h4>";
echo "<h4>" . $enrollment['Telephone'] . "</h4>";
echo "<h4>" . $enrollment['Email'] . "</h4>";
echo "<h4>" . $enrollment['No_Of_Classes'] . "</h4>";
echo "<h4>" . $enrollment['Fee'] . "</h2>";
echo "<h4>" . $enrollment['About_My_Classes'] . "</h4>";
}
$name=$_POST['Name'];
$telephone=$_POST['Telephone'];
$email=$_POST['Email'];
$no_of_classes=$_POST['No_Of_Classes'];
$fee=$_POST['Fee'];
$about_my_classes=$_POST['About_My_Classes'];

if(!$_POST['submit'])
{
echo "please fill out the form";

} else {
mysql_query("INSERT INTO enrollment(Name,Telephone,Email,No_Of_Classes,Fee,About_My_Classes)
VALUES ('$name','$telephone','$email','$no_of_classes','$fee','$about_my_classes')");
echo " \n in else my name is $name";

mysql_close($conn);
}
?>

</body>
</head>
</html>

Can you please give me some suggestion what I may be missing or doing wrong.


Thank you,
Roops

Roops
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Jan 11, 2011 3:20 pm

Re: How to include PHP and javascript code in articles ?

Post by Roops » Mon Feb 07, 2011 4:37 pm

Hi.... I'm fairly new to Joomla and I am trying to insert PHP Code.

I have got problem with my code.The problem is when i click on to the submit button, my data will not be stored in the database. instead ,Entire code itself is displayed on my page.

Can you please check my code.

where my website contain ENROLLMENT PAGE, Where i need to enter some data like:

name
telephone
email
no_of_classes
fee
About_my_classes.

my code in article for Enrollment Page looks like this:-


<html>
<head>
<body>
<h1> enrollment</h1>
<form action="$_PHP_SELF" method="post">
Name:<input type="text" name="Name" value=""/>
Telephone:<input type="text" name="Telephone" value=""/>
Email: <input type="text" name="Email" value=""/>
How many classes would you like to attend?:<input type="text" name="No_Of_Classes" value="" />
How would you like to pay?<input type="text" name="Fee" value=""/>
How did you find out about my classes?:<input type="text" name="About_My_Classes" value="" />
<input type="submit" name="submit" value="Submit!" />
</form>


<?php
$dbhost= 'localhost';
$dbuser= 'root';
$dbpass= '';
$db='zumba';
$conn=mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($db);
$query="select *from enrollment";

$result=mysql_query($query);

while($enrollment=mysql_fetch_array($result))
{
echo "<h4>" . $enrollment['Name'] . "</h4>";
echo "<h4>" . $enrollment['Telephone'] . "</h4>";
echo "<h4>" . $enrollment['Email'] . "</h4>";
echo "<h4>" . $enrollment['No_Of_Classes'] . "</h4>";
echo "<h4>" . $enrollment['Fee'] . "</h2>";
echo "<h4>" . $enrollment['About_My_Classes'] . "</h4>";
}
$name=$_POST['Name'];
$telephone=$_POST['Telephone'];
$email=$_POST['Email'];
$no_of_classes=$_POST['No_Of_Classes'];
$fee=$_POST['Fee'];
$about_my_classes=$_POST['About_My_Classes'];

if(!$_POST['submit'])
{
echo "please fill out the form";

} else {
mysql_query("INSERT INTO enrollment(Name,Telephone,Email,No_Of_Classes,Fee,About_My_Classes)
VALUES ('$name','$telephone','$email','$no_of_classes','$fee','$about_my_classes')");
echo " \n in else my name is $name";

mysql_close($conn);
}
?>

</body>
</head>
</html>

Can anybody, please give me some suggestion what I may be missing or doing wrong.



Thank you,
Roops

major2000
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Mon Mar 28, 2011 12:30 am

Re: How to include PHP and javascript code in articles ?

Post by major2000 » Mon Mar 28, 2011 12:58 am

MarHaj wrote:The path to the file you shoul write down is a relative path to the file with respect to the Joomla root in current Jumi releases.
Examples
a) If your Joomla root (i.e. where configuration.php and index.php is) is c:/wamp/www/Prototype
and your hello_args.php is at c:\wamp\www\Prototype\jumies\hello_args.php
then
{jumi [jumies/hello_args.php]}
will work.
b) If your Joomla root (i.e. where configuration.php and index.php is) is c:/wamp/www
and your hello_args.php is at c:\wamp\www\Prototype\jumies\hello_args.php
then
{jumi [Prototype/jumies/hello_args.php]}
will work.
Hi I am novice to Joomla and all the response i read in the forum was not clear to me.
I generate a form using a php form generator. The form is doing what it is suppose to do. I have three files:
- Process.php
- Form "Sign up"
- Global.inc.php

I have download and install the extension "jumi" as i read in the forum but now i am lost.
Where should i put each of these file?
After installing the extensions is there any configuration to do?
Does my code need to be modify?

Thanks for all your input.

MM
You do not have the required permissions to view the files attached to this post.

harendra09
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Oct 05, 2011 7:11 pm

Re: How to include PHP and javascript code in articles ?

Post by harendra09 » Wed Oct 05, 2011 7:17 pm

dear all

i gone through all your discussion but i am not able to pick that how and where to add simple php data fetch and show code into joomla article and if JUMI is helpful in this matter then please guide me. I will really appreciate it

thanks

mcongosto
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Thu Nov 02, 2006 6:35 pm

Re: How to include PHP and javascript code in articles ?

Post by mcongosto » Tue Oct 18, 2011 9:58 am

why in the fack is so hard to put some stupid js code on a joomla article? arghhhhhhhh

MatthewSchenker
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 233
Joined: Tue Nov 25, 2008 7:10 pm

Re: How to include PHP and javascript code in articles ?

Post by MatthewSchenker » Tue Nov 08, 2011 9:24 pm

Hello,
I'm wondering about the same thing.

It's usually pretty straightforward to include Javascript files in a Web site and I've done it many times in other systems. But for the life of me I can't figure out where it goes in Joomla. I don't want to install an extension just so I can reference a JS file in one of my site folders.

Where can I make a simple reference to the file?

Thanks,
Matthew

tusharkm
Joomla! Intern
Joomla! Intern
Posts: 57
Joined: Wed Nov 09, 2011 12:43 pm
Location: India
Contact:

Re: How to include PHP and javascript code in articles ?

Post by tusharkm » Wed Nov 09, 2011 12:55 pm

Hello all...dont know about PHP but if u want to include javascript in your joomla article then you have to make some changes as follow-
-on your adminisrator panel of joomla go to plug-in manager.
-then open 'Editor - TinyMCE'
-in right side panel, there is a section 'Prohibited Elements'.
-remove javascript and save it.
also u'll probably need to do following steps after making above changes..
-go to 'article manager', at top-right corner click on 'option' tab
-pop-up window appears, click on 'text filter' option.
-set 'Super Users' to 'no filtering'.

You are done now..
you can add your javascript in joomla article as usual.

MatthewSchenker
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 233
Joined: Tue Nov 25, 2008 7:10 pm

Re: How to include PHP and javascript code in articles ?

Post by MatthewSchenker » Wed Nov 09, 2011 7:24 pm

tusharkm,
I think we're talking about different things here.

I'm talking about being able to load JQuery elements created by various coders. The normal way to do it is to place the *.js file in a folder, then load up the JQuery script in a particular place on your page, and finally to call the JQuery via a class reference in the HTML.

For example, being able to run a slider like this: http://flex.madebymufffin.com/

There does not seem to be a straightforward way to do this in Joomla.

Thanks,
Matthew

Synthetronica
Joomla! Apprentice
Joomla! Apprentice
Posts: 32
Joined: Fri Oct 21, 2011 5:00 pm
Contact:

Re: How to include PHP and javascript code in articles ?

Post by Synthetronica » Fri Jan 20, 2012 2:19 pm

When I need to include PHP code, I write it to a file on my server, along with whatever HTML content goes around it, and link to it with an iframe wrapper menu item. No need for plugins or modules for this.

That's what I did here: http://synthetronica.com/index.php/radiomenuitem
This signature literally has no URL's in it.

carloszoom3000
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Mon Sep 16, 2013 7:45 pm

Re: How to include PHP and javascript code in articles ?

Post by carloszoom3000 » Fri Oct 04, 2013 1:54 pm

Hi.

I created a php file to insert data in a database through an article in joomla.
when i run the php file trhough localhost, i can see the new data in the table, but when using the article in joomla, it creates a new row but the fields are empty.

i used the "sourcerer" plugin to insert the php code in the article.

here is my code:


<html>

<form action="demo.php" method="post"/>
<p>Numero de acta: <input type="text" name="No_Acta"/></p>
<p>Numero de serie: <input type="text" name="input2"/></p>
<p>Dia: <input type="text" name="input3"/></p>
<p>Mes: <input type="text" name="input4"/></p>
<p>Año: <input type="text" name="input5"/></p>
<p>MD1: <input type="text" name="input6"/></p>
<p>MD2: <input type="text" name="input7"/></p>
<p>MD3: <input type="text" name="input8"/></p>
<p>MG1: <input type="text" name="input9"/></p>
<p>MG2: <input type="text" name="input10"/></p>
<p>MG3: <input type="text" name="input11"/></p>
<p>GBMD1: <input type="text" name="input12"/></p>
<p>GBMD2: <input type="text" name="input13"/></p>
<p>GBMD3: <input type="text" name="input14"/></p>
<p>GBMG1: <input type="text" name="input15"/></p>
<p>GBMG2: <input type="text" name="input16"/></p>
<p>GBMG3: <input type="text" name="input17"/></p>
<p>Precintos: <input type="text" name="input18"/></p>
<p>Numero de precintos: <input type="text" name="input19"/></p>
<p>Retirado: <input type="text" name="input20"/></p>
<p>Instalado: <input type="text" name="input21"/></p>
<p>Comentarios: <input type="text" name="input22"/></p>



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

</html>

<?php

define('DB_NAME', 'mibasededatos');
define('DB_USER', 'root');
define('DB_PASSWORD', 'root');
define('DB_HOST', 'localhost');

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

if (!$link) {
die('Could not connect: ' .mysql_error());
}

$db_selected= mysql_select_db(DB_NAME, $link);

if (!$db_selected) {
die('Can\'t use ' .DB_NAME . ': ' .mysql_error());
}

$value= $_POST['No_Acta'];
$value2= $_POST['input2'];
$value3= $_POST['input3'];
$value4= $_POST['input4'];
$value5= $_POST['input5'];
$value6= $_POST['input6'];
$value7= $_POST['input7'];
$value8= $_POST['input8'];
$value9= $_POST['input9'];
$value10= $_POST['input10'];
$value11= $_POST['input1'];
$value12= $_POST['input12'];
$value13= $_POST['input13'];
$value14= $_POST['input14'];
$value15= $_POST['input15'];
$value16= $_POST['input16'];
$value17= $_POST['input17'];
$value18= $_POST['input18'];
$value19= $_POST['input19'];
$value20= $_POST['input20'];
$value21= $_POST['input21'];
$value22= $_POST['input22'];

$sql = "INSERT INTO demo (No_Acta, input2, input3, input4, input5, input6, input7, input8, input9, input10, input11, input12, input13, input14, input15, input16, input17, input18, input19, input20, input21, input22) VALUES ('$value', '$value2', '$value3', '$value4', '$value5', '$value6', '$value7', '$value8', '$value9', '$value10', '$value11', '$value12', '$value13', '$value14', '$value15', '$value16', '$value17', '$value18', '$value19', '$value20', '$value21', '$value22')";

if (!mysql_query($sql)) {
die('Error: ' .mysql_error());
}

mysql_close();

echo "datos enviados a base de datos";
echo "<a href=\"javascript:history.go(-1)\"><p>volver al formulario</p></a>";
?>


Locked

Return to “Extensions for Joomla! 1.5”