Hi,

index.php posts data to process.php

I want users to remain in index.php when they summit their form. I have seen this in some websites but don't know hot it done.
Can anyone help me?

Thanks

Recommended Answers

All 20 Replies

This is where AJAX comes into play... For basics refer
http://www.w3schools.com/Ajax/Default.Asp

Hi,

index.php posts data to process.php

I want users to remain in index.php when they summit their form. I have seen this in some websites but don't know hot it done.
Can anyone help me?

Thanks

Hi,

index.php posts data to process.php

I want users to remain in index.php when they summit their form. I have seen this in some websites but don't know hot it done.
Can anyone help me?

Thanks

All you need to do is submit the page to itself from the form tag. you will also need to make sure you give your submit button a name attribute. For example.

<form action="index.php" method="post" >
   <!-- your form inputs here -->
   <input type="submit" name="submit" value="Submit" />
</form>

and at the top of your index.php before the header should look something like

<?php
   if(isset($_POST['submit'])) {
      // do stuff here
   }
?>
// continue to display what was intended for the visitors first visit to the page if submit was not detected.

hope that helps

This wont be a solution what he is looking... he wants index.php to submit data to process.php
n btw even if u submit the data to same page, the page gets refreshed which can be avoided only by asynchronous data transfer possible through AJAX.

All you need to do is submit the page to itself from the form tag. you will also need to make sure you give your submit button a name attribute. For example.

<form action="index.php" method="post" >
   <!-- your form inputs here -->
   <input type="submit" name="submit" value="Submit" />
</form>

and at the top of your index.php before the header should look something like

<?php
   if(isset($_POST['submit'])) {
      // do stuff here
   }
?>
// continue to display what was intended for the visitors first visit to the page if submit was not detected.

hope that helps

This wont be a solution what he is looking... he wants index.php to submit data to process.php
n btw even if u submit the data to same page, the page gets refreshed which can be avoided only by asynchronous data transfer possible through AJAX.

Apologies you are correct, I misread the original post.

Ok guys thanks for your very helpful information. Now i go and read about AJAX.
Thanks

anytime... n do remember to mark the thread as solved wen u r done...

Ok guys thanks for your very helpful information. Now i go and read about AJAX.
Thanks

yeah i did this with form="target_blank" and then used php header to close the processing file. its really simple.

sure this will do the trick but i dont feel its a healthy practice as the user will get a window flashed in front n then disappearing....
Also, after closing the process file, how will u update the values in original index.php without refreshing it... I agree u will submit the form but u need to show a success or error message to user regarding it...
so best way to achieve this(AFAIK) is AJAX

yeah i did this with form="target_blank" and then used php header to close the processing file. its really simple.

sorry it was for deleting msgs from an inbox. if u have a form u need to take it to the next page.

exactly... u have to submit ur form data to another page(or to same page with phpself) but u can do this without having user know anything abt it (ofcourse with AJAX).
cheers!!

sorry it was for deleting msgs from an inbox. if u have a form u need to take it to the next page.

o i meant ajaxx is an unessary fault to use to submit just a form

Thats fine coz i dont know any other way to transfer data asynchronously without user's notice... if u knw den do share ur knowledge.... dats wat this forum is meant for..

o i meant ajaxx is an unessary fault to use to submit just a form

Try this: At top of document which calls itself ...
<?php if(isset($_POST)) { // possibly check params here
include ("process.php"); ?>
User stays in index.php and include file can be in hidden directory.

Try this: At top of document which calls itself ...
<?php if(isset($_POST)) { // possibly check params here
include ("process.php"); ?>
User stays in index.php and include file can be in hidden directory.

I think that venkat0904 doesnt want to refresh the page.

Check out these few examples, they should point you in the right direction. I am currently trying to learn AJAX myself these are quite good with good explanation.

http://www.w3schools.com/Ajax/ajax_example_suggest.asp

u should just refresh the page. by all means. ajax is an uneccesary step in the web world im astounded why so many sites have implemented it.

m afraid i dont fully agree with u... Its totally absurd to refresh the whole page when all u need is to update a single frame or just to display a message especially when ur page is heavy.. Watch the difference in orkut(old orkut not new one) and facebook itself...
When bandwidth is low, using ajax can make significant difference in being user friendly.

u should just refresh the page. by all means. ajax is an uneccesary step in the web world im astounded why so many sites have implemented it.

maybe u should undercut why u are afraid. because im right. orcut is not a good website. i mean. ajax is left for the non forms. in genera. ajax should not be used to submit a form. and well. cant with mysl anyways

Even i believe orkut is not a good website... i mentioned it to compare with facebook(which i believe uses AJAX for most of its operations) and see u can tell the difference.. its way better than orkut...
And correct me if m wrong but I think we can very well use ajax for mysql.. wy wud u say that we cant... if u think it should not be used, its completely ur opinion...

maybe u should undercut why u are afraid. because im right. orcut is not a good website. i mean. ajax is left for the non forms. in genera. ajax should not be used to submit a form. and well. cant with mysl anyways

no. its not just my opinion. everyone on here like has told me that i cant use ajax to submit a form and update mysql databases. its impossible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.