PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have created an input form in php which will submit data to ms access2010 database and after submitting go to another page which is mentioned in form action. But if I use the url for another page in action, data don't insert into the database. If I remove the action than the data is inserted. I am giving the code bellow-
Last edited by Benjamin on Tue Jul 17, 2012 11:52 pm, edited 1 time in total.
Reason:Added [syntax=php||htm||css||javascript||sql||etc] - Please use [syntax] tags when posting code in the forums! Thanks.
saifphp wrote:I have created an input form in php which will submit data to ms access2010 database and after submitting go to another page which is mentioned in form action. But if I use the url for another page in action, data don't insert into the database. If I remove the action than the data is inserted. I am giving the code bellow-
Could you clarify what you mean by "another page"?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Another page means the target page which I want to show after submitting data. By clicking on the submit button, two things will be happened- 1. data will go to the database, 2. another page will be displayed which I mentioned in the form action.
saifphp wrote:If I remove the action than the data is inserted
This means that the code that inserts the data into the database is on the same page as the form. It's refered to as 'calling the form on itself'. Is there any other code on the form page?
saifphp wrote:By clicking on the submit button, two things will be happened- 1. data will go to the database, 2. another page will be displayed which I mentioned in the form action.
If you want something to display on the target page it has to be placed on the target page and (usually) be dependent on the results of something, in your instance submitting data to the database. A simple example
if (insertedIntoDatabase)
'Data successfully added'
else
'Data wasnt added.'
If you have the message on a totally different page than the value in the target attribute you would redirect depending on the result of something. You could use header() or perhaps a javascript alternative to achieve this.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Your suggestion was very very much helpful and my problem is solved. I have used a separate page for inserting data and than redirected to the target page.