simple html post form not working
Moderators: ooffick, General Support Moderators
Forum rules
-
- Joomla! Apprentice
- Posts: 14
- Joined: Sun Jun 12, 2016 11:27 am
simple html post form not working
Hi folks
I started using Joomla a couple of days ago but was already familiar with HTML and PHP. I have created a simple form in my Joomla website which posts to a php file for actioning to update a Mysql database. The form itself works ok outside of Joomla but not when I use it within Joomla, I press the submit button and nothing happens, no text is echoed back to screen and no updates are made to the database, its as if it can't find the php file which processes the form.
I'm using ver 3.5.1 with the direct.php extension. PHP and Mysql are working ok as I can code these directly in the Joomla article fine, its only the form that isn't working.
Have looked already on the web but can't find an answer.
Thanks in advance for any suggestions.
Pete
I started using Joomla a couple of days ago but was already familiar with HTML and PHP. I have created a simple form in my Joomla website which posts to a php file for actioning to update a Mysql database. The form itself works ok outside of Joomla but not when I use it within Joomla, I press the submit button and nothing happens, no text is echoed back to screen and no updates are made to the database, its as if it can't find the php file which processes the form.
I'm using ver 3.5.1 with the direct.php extension. PHP and Mysql are working ok as I can code these directly in the Joomla article fine, its only the form that isn't working.
Have looked already on the web but can't find an answer.
Thanks in advance for any suggestions.
Pete
Last edited by toivo on Sun Jun 12, 2016 12:27 pm, edited 1 time in total.
Reason: mod note: moved to 3.x Coding
Reason: mod note: moved to 3.x Coding
- toivo
- Joomla! Master
- Posts: 17445
- Joined: Thu Feb 15, 2007 5:48 am
- Location: Sydney, Australia
Re: simple html post form not working
If the form is a PHP script and the file to which the data is posted is also a PHP script that you wrote, how are you using the form "within Joomla"?The form itself works ok outside of Joomla but not when I use it within Joomla
Toivo Talikka, Global Moderator
-
- Joomla! Apprentice
- Posts: 14
- Joined: Sun Jun 12, 2016 11:27 am
Re: simple html post form not working
Hi Toivo
The form is not a php script, it is HTML within my Joomla article. The file that the form posts to is a php script.
The following code doesn't mean much at the moment, it's just a way of getting a form to work so that once it is I can put it to proper use. Within my Joomla article the code is:-
# <form action="EvaluateForm.php" method="POST">
# <b>Name</b>
# <input type="text" size="45" name="Username"><br />
# <input type="submit" value="Submit now">
# </form>
This gets processes by the EvaluateForm.php file which echoes the username and some other text back to screen and updates a record in a database.
To test, If I create a file in my XAMPP/htdocs folder and use this code it works fine.
Snewzer
The form is not a php script, it is HTML within my Joomla article. The file that the form posts to is a php script.
The following code doesn't mean much at the moment, it's just a way of getting a form to work so that once it is I can put it to proper use. Within my Joomla article the code is:-
# <form action="EvaluateForm.php" method="POST">
# <b>Name</b>
# <input type="text" size="45" name="Username"><br />
# <input type="submit" value="Submit now">
# </form>
This gets processes by the EvaluateForm.php file which echoes the username and some other text back to screen and updates a record in a database.
To test, If I create a file in my XAMPP/htdocs folder and use this code it works fine.
Snewzer
- toivo
- Joomla! Master
- Posts: 17445
- Joined: Thu Feb 15, 2007 5:48 am
- Location: Sydney, Australia
Re: simple html post form not working
Does your script EvaluateForm.php bootstrap the Joomla CLI so that the methods of the Joomla API are available or are you somehow using some component?
Toivo Talikka, Global Moderator
-
- Joomla! Apprentice
- Posts: 14
- Joined: Sun Jun 12, 2016 11:27 am
Re: simple html post form not working
I should mention that although familiar with PHP and HTML I consider myself a newbie. Self taught, and I haven't done a jot of coding in the last 4 years. Sorry but I'm afraid I don't really understand what your question is asking.
-
- I've been banned!
- Posts: 13639
- Joined: Sun Jul 05, 2009 3:30 am
- Location: Canberra, Australia
Re: simple html post form not working
What I suspect we're trying to understand here is how you've gone about inserting your PHP code into Joomla. As with most CMS products, injecting PHP into Joomla is not done merely by adding a few lines into a "article", for example, but it's done via what we call Joomla extensions (e.g. components, modules and plugins). Perhaps the "simplest" way of having a site visitor interact with the site database—from a Joomla perspective, at least—is via a module. That's not the only way, but it's one that I'm certainly familiar with. I'm guessing here, however, because I don't know how your EvaluateForm.php tool utilises the Joomla API (or whether it interacts with it in the way you want it to).
- Per Yngve Berg
- Joomla! Master
- Posts: 30940
- Joined: Mon Oct 27, 2008 9:27 pm
- Location: Romerike, Norway
Re: simple html post form not working
In Joomla all posts have to go through index.php.
You will be easier to use a forms extension or a cck.
http://extensions.joomla.org/category/c ... back/forms
http://extensions.joomla.org/category/a ... nstruction
I use Fabrik myself.
You will be easier to use a forms extension or a cck.
http://extensions.joomla.org/category/c ... back/forms
http://extensions.joomla.org/category/a ... nstruction
I use Fabrik myself.
-
- Joomla! Apprentice
- Posts: 14
- Joined: Sun Jun 12, 2016 11:27 am
Re: simple html post form not working
Thanks...That I do understand, and it's via the 'direct.php' extension which I have installed. PHP itself works fine, I can write php code directly into the article and it works fine. it's only when I try to use this form that it isn't working.
-
- Joomla! Apprentice
- Posts: 14
- Joined: Sun Jun 12, 2016 11:27 am
Re: simple html post form not working
[quote="Per Yngve Berg"]In Joomla all posts have to go through index.php.
Sorry, not sure what this entails.
Sorry, yes I know what index.php is but I'm not sure what you mean by the form 'going through' it.
Sorry, not sure what this entails.
Sorry, yes I know what index.php is but I'm not sure what you mean by the form 'going through' it.
- Per Yngve Berg
- Joomla! Master
- Posts: 30940
- Joined: Mon Oct 27, 2008 9:27 pm
- Location: Romerike, Norway
Re: simple html post form not working
That means you have to write your own component with models and views.
https://docs.joomla.org/Portal:Developers
https://docs.joomla.org/Portal:Developers
-
- Joomla! Apprentice
- Posts: 14
- Joined: Sun Jun 12, 2016 11:27 am
Re: simple html post form not working
Now that I don't understand! Will check out your link. Thanks.
-
- Joomla! Apprentice
- Posts: 14
- Joined: Sun Jun 12, 2016 11:27 am
Re: simple html post form not working
So what you are saying is that a plain simple HTML post form will not work without one of these extensions?Per Yngve Berg wrote:In Joomla all posts have to go through index.php.
You will be easier to use a forms extension or a cck.
I use Fabrik myself.
-
- I've been banned!
- Posts: 13639
- Joined: Sun Jul 05, 2009 3:30 am
- Location: Canberra, Australia
Re: simple html post form not working
I don't think that's actually what Per was saying. In your case, you want to have a simple form in your Joomla website to update a MySQL database table. I understand that. I've done this kind of thing before.Snewzer wrote:So what you are saying is that a plain simple HTML post form will not work without one of these extensions?
The issue here is that you can't just "simply" write a piece of PHP and merely insert it anywhere in your Joomla website and expect it to work as you might hope. There are methods of using PHP with Joomla (there is a standard API) and that's what we're trying to help you understand. A few messages earlier in this topic I mentioned the use of Joomla modules—for me, these are fairly easy to write once you get the hang of them. There are also other products (CCKs and components like Fabrik) that allow you to hook your PHP into one or another table in your database.
Assuming you're trying to update a specific database table that you've created yourself (outside of what might be available in a component like Fabrik) it's possible to write something that will process a form. In my case, I've done that by writing a Joomla module and that's all I am saying. I don't have any experience with Fabrik or BreezingForms and I'm unable to comment on the features of those products, sorry.
-
- Joomla! Apprentice
- Posts: 14
- Joined: Sun Jun 12, 2016 11:27 am
Re: simple html post form not working
Hi Sozzled, I think that I should go away and read 'Joomla for dummies' and come back when I understand a bit more about it as I'm struggling to follow the advice being given. So I can get an HTML post form to work if I write a Joomla module, is that what you are saying?
Going back to your earlier post, I am using the direct php extension. My 'Evaluate form.php' is just a php srcript executing a mysql query and updating a database, it doesn't need to interact with Joomla to my way of thinking, just execute the query, update the database and return me back to my Joomla article with the new updated values displayed.
Going back to your earlier post, I am using the direct php extension. My 'Evaluate form.php' is just a php srcript executing a mysql query and updating a database, it doesn't need to interact with Joomla to my way of thinking, just execute the query, update the database and return me back to my Joomla article with the new updated values displayed.
-
- Joomla! Explorer
- Posts: 457
- Joined: Sun Jan 30, 2011 10:09 am
- Location: Leicester, UK
Re: simple html post form not working
I would go with sozzled's suggestion and use Fabrik. As well as doing what you need, it will take care of integrating with Joomla (and your template), provide security, a huge range of field types, responsive (bootstrap) form and list views, and still let you use your own php code whenever you need to customize it.
-
- Joomla! Intern
- Posts: 83
- Joined: Thu Jan 18, 2007 5:35 pm
Re: simple html post form not working
Your just... update the database ... is bypassing every security level of Joomla. Do not blame Joomla if you turn off the filters for text and fields.Snewzer wrote:....
Going back to your earlier post, I am using the direct php extension. My 'Evaluate form.php' is just a php srcript executing a mysql query and updating a database, it doesn't need to interact with Joomla to my way of thinking, just execute the query, update the database and return me back to my Joomla article with the new updated values displayed.
Depending on what you want to achieve in the future there are different approaches as suggested above. I agree with Sozzeled that a very good start, if you want to add functionality to Joomla are Joomla modules. Start with something easy and create forms and database connections in the next steps. Read documentation and follow tutorials on how to do this in a most secure way. The handling of reading and writing databases are allways a security risk that has to be minimized or your system is on a VERY local machine.
Even if you want to use some helper addons you'd better learn some Joomla basics first.
Happy coding
-
- Joomla! Apprentice
- Posts: 14
- Joined: Sun Jun 12, 2016 11:27 am
Re: simple html post form not working
Thanks Over, but don't worry... all this is on my local machine at the moment. I am nowhere near thinking about going live until I know more, especially about security. The official Joomla book is on its way to me and I just wanted to make a start on writing my article while waiting.
Thanks to all others for suggestions so far, I will get Fabrik and take it from there and no doubt I will be back soon with further questions if I still can't get it to work!
Thanks to all others for suggestions so far, I will get Fabrik and take it from there and no doubt I will be back soon with further questions if I still can't get it to work!
-
- Joomla! Explorer
- Posts: 325
- Joined: Fri Feb 26, 2010 4:01 pm
Re: simple html post form not working
Since you're familiar with writing PHP, another short-cut method is to use the sourcerer extension from NoNumber. This extension allows you to insert PHP code in places where Joomla usually doesn't allow you to do so.
If you install the sourcerer extension, and then use it to insert your PHP code into an article or into a Custom type module, you'll likely get the result you're looking for. It's not quite the proper solution which is to create a new extension (probably a new component) but it works. There's a lot of code overhead that goes along with creating a new component, so you may want to wait on that until you've got more familiarity with Joomla.
Or use one of the extensions like RSForms or ProForms. I use RSForms a lot and it is very powerful and flexible and allows you to connect the form created in RSForms to custom database fields and to integrate your own scripts into the form processing.
If you install the sourcerer extension, and then use it to insert your PHP code into an article or into a Custom type module, you'll likely get the result you're looking for. It's not quite the proper solution which is to create a new extension (probably a new component) but it works. There's a lot of code overhead that goes along with creating a new component, so you may want to wait on that until you've got more familiarity with Joomla.
Or use one of the extensions like RSForms or ProForms. I use RSForms a lot and it is very powerful and flexible and allows you to connect the form created in RSForms to custom database fields and to integrate your own scripts into the form processing.
Erich
www.bectin.com
www.bectin.com
-
- Joomla! Apprentice
- Posts: 14
- Joined: Sun Jun 12, 2016 11:27 am
Re: simple html post form not working
Thanks erichf, I have already installed the direct php extension which allows me to write the php code and I was presuming would be equivalent to sourcerer for my purposes. PHP works fine and I can do other things with it in my Joomla article, its just the form that isn't working.
-
- Joomla! Apprentice
- Posts: 14
- Joined: Sun Jun 12, 2016 11:27 am
Re: simple html post form not working
I have obtained the official Joomla book but that hasn't helped me, it's just written in a style that doesn't work for me, so I have sent off for another beginners guide.
I have installed Fabrik but can't find a tutorial which can get me started on it so I am struggling to make any sense of it. I have installed breezing forms lite, but again, can't find a tutorial which can help me.
I have installed DirectPHP and this seems to do the job. I have got my forms working fine, the only modification needed to the standard HTML code is to pass along the Joomla parameters as hidden values in the form.
The only difficultly that I am having is that my drop down select menus are very wide, far wider than the text that they contain. Has anyone encountered this problem and can offer a solution ?
I have installed Fabrik but can't find a tutorial which can get me started on it so I am struggling to make any sense of it. I have installed breezing forms lite, but again, can't find a tutorial which can help me.
I have installed DirectPHP and this seems to do the job. I have got my forms working fine, the only modification needed to the standard HTML code is to pass along the Joomla parameters as hidden values in the form.
The only difficultly that I am having is that my drop down select menus are very wide, far wider than the text that they contain. Has anyone encountered this problem and can offer a solution ?
-
- I've been banned!
- Posts: 13639
- Joined: Sun Jul 05, 2009 3:30 am
- Location: Canberra, Australia
Re: simple html post form not working
Different question, different subject. It is much better in these "technical discussion forums" to discuss different issues in specific subjects. As a general answer, the width of a <select ...> element (assuming that's what you mean) can be adjusted with CSS as well as with its own width attribute.Snewzer wrote:The only difficultly that I am having is that my drop down select menus are very wide, far wider than the text that they contain. Has anyone encountered this problem and can offer a solution ?
On the other hand, when you refer to the word "menu", most menus in Joomla comprise <div><ul><li> ... </li></ul></div> constructs, so I'm not quite sure I understand your problem. A separate topic (with a reference to your website) may provide us with a better clue.
-
- Joomla! Apprentice
- Posts: 14
- Joined: Sun Jun 12, 2016 11:27 am
Re: simple html post form not working
That was quick! Thanks Sozzled. Yes that's right, the < select ...> element in a HTML drop down select menu, I am trying to do everything the old fashioned way at the moment because I haven't learnt enough about Joomla yet to do things the Joomla way.
It would normally take the width of the longest entry, but mine is over twice as wide. Will try the suggestions you have given but I'm puzzled as to why it should be so wide to begin with.
I don't have a website yet, this is just code I am building to install into someone else's pre-existing Joomla site.
It would normally take the width of the longest entry, but mine is over twice as wide. Will try the suggestions you have given but I'm puzzled as to why it should be so wide to begin with.
I don't have a website yet, this is just code I am building to install into someone else's pre-existing Joomla site.
-
- I've been banned!
- Posts: 13639
- Joined: Sun Jul 05, 2009 3:30 am
- Location: Canberra, Australia
Re: simple html post form not working
Please create a new topic with a separate subject concerning your unrelated issue. But, as a general response, let me offer some advice.
Considering that you are unable or unwilling to provide us with access to your site, it makes it 99.9% impossible to figure an answer based on this generalised "something-isn't-quite-right" assessment or, for that matter, merely on a screenshot.
It's a bit like telephoning your doctor and saying, "I'm unhappy with my appearance. What is your professional opinion?" I think you know what your doctor would say in reply, don't you?
Considering that you are unable or unwilling to provide us with access to your site, it makes it 99.9% impossible to figure an answer based on this generalised "something-isn't-quite-right" assessment or, for that matter, merely on a screenshot.
It's a bit like telephoning your doctor and saying, "I'm unhappy with my appearance. What is your professional opinion?" I think you know what your doctor would say in reply, don't you?
-
- Joomla! Apprentice
- Posts: 14
- Joined: Sun Jun 12, 2016 11:27 am
Re: simple html post form not working
Thanks for the replies. I had made it clear earlier that I no nothing\little about Joomla and hadn't done any coding of any kind for years, so please excuse the 'vagueness' of my enquires.
When I said 'Joomla website' I meant localhost, I do not have a website.
I think it better that I endeavour to learn more about Joomla and then come back if I still need help.
Sorry Javieruis88 but I do not understand the phrase ' ***** Manual signatures are NOT allowed ***** '.
When I said 'Joomla website' I meant localhost, I do not have a website.
I think it better that I endeavour to learn more about Joomla and then come back if I still need help.
Sorry Javieruis88 but I do not understand the phrase ' ***** Manual signatures are NOT allowed ***** '.
-
- I've been banned!
- Posts: 13639
- Joined: Sun Jul 05, 2009 3:30 am
- Location: Canberra, Australia
Re: simple html post form not working
@Snewser: ignore what javieruis88 wrote; his message was spam and it has been reported to the moderators to act upon as they see fit.
-
- Joomla! Apprentice
- Posts: 14
- Joined: Sun Jun 12, 2016 11:27 am
Re: simple html post form not working
Thanks to everyone. The form is working perfectly now. I have used the DirectPHP extension and passed along the Joomla parameters in the form posting to index.php (...thanks Per !).
It's probably nothing like what you guys would write but this is a simple hobby project of no great importance so it will do for now while I learn how to use Joomla properly.
I have sorted out my other problems (... different subject !) also so this should be the end of this post.
Thanks to everyone.
It's probably nothing like what you guys would write but this is a simple hobby project of no great importance so it will do for now while I learn how to use Joomla properly.
I have sorted out my other problems (... different subject !) also so this should be the end of this post.
Thanks to everyone.