0

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

6
Contributors
20
Replies
21
Views
7 Years
Discussion Span
Last Post by SKANK!!!!!
Featured Replies
  • 1
    __avd 1,826   7 Years Ago

    You can use AJAX to post form data. Take a look at this link [URL="http://www.captain.at/howto-ajax-form-post-request.php"]http://www.captain.at/howto-ajax-form-post-request.php[/URL] Read More

0

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

0

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

0

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.

0

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

0

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

0

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

0

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.

0

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

0

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.

0

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

0

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.

0

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

0

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.

0

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.

0

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

0

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

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.