944,103 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1068
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Nov 6th, 2009
0

Posting data behind the scene

Expand Post »
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
Similar Threads
Reputation Points: 38
Solved Threads: 0
Master Poster
veledrom is offline Offline
724 posts
since Apr 2008
Nov 6th, 2009
1
Re: Posting data behind the scene
You can use AJAX to post form data. Take a look at this link http://www.captain.at/howto-ajax-form-post-request.php
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Nov 6th, 2009
-1
Re: Posting data behind the scene
This is where AJAX comes into play... For basics refer
http://www.w3schools.com/Ajax/Default.Asp

Click to Expand / Collapse  Quote originally posted by veledrom ...
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
Reputation Points: 13
Solved Threads: 21
Junior Poster
venkat0904 is offline Offline
186 posts
since Oct 2009
Nov 6th, 2009
0
Re: Posting data behind the scene
Click to Expand / Collapse  Quote originally posted by veledrom ...
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.

html Syntax (Toggle Plain Text)
  1. <form action="index.php" method="post" >
  2. <!-- your form inputs here -->
  3. <input type="submit" name="submit" value="Submit" />
  4. </form>

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

php Syntax (Toggle Plain Text)
  1. <?php
  2. if(isset($_POST['submit'])) {
  3. // do stuff here
  4. }
  5. ?>
  6. // continue to display what was intended for the visitors first visit to the page if submit was not detected.

hope that helps
Reputation Points: 19
Solved Threads: 15
Junior Poster
leviathan185 is offline Offline
105 posts
since May 2009
Nov 6th, 2009
0
Re: Posting data behind the scene
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.

html Syntax (Toggle Plain Text)
  1. <form action="index.php" method="post" >
  2. <!-- your form inputs here -->
  3. <input type="submit" name="submit" value="Submit" />
  4. </form>

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

php Syntax (Toggle Plain Text)
  1. <?php
  2. if(isset($_POST['submit'])) {
  3. // do stuff here
  4. }
  5. ?>
  6. // continue to display what was intended for the visitors first visit to the page if submit was not detected.

hope that helps
Reputation Points: 13
Solved Threads: 21
Junior Poster
venkat0904 is offline Offline
186 posts
since Oct 2009
Nov 6th, 2009
0
Re: Posting data behind the scene
Click to Expand / Collapse  Quote originally posted by venkat0904 ...
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.
Reputation Points: 19
Solved Threads: 15
Junior Poster
leviathan185 is offline Offline
105 posts
since May 2009
Nov 6th, 2009
0
Re: Posting data behind the scene
Ok guys thanks for your very helpful information. Now i go and read about AJAX.
Thanks
Reputation Points: 38
Solved Threads: 0
Master Poster
veledrom is offline Offline
724 posts
since Apr 2008
Nov 6th, 2009
0
Re: Posting data behind the scene
anytime... n do remember to mark the thread as solved wen u r done...
Click to Expand / Collapse  Quote originally posted by veledrom ...
Ok guys thanks for your very helpful information. Now i go and read about AJAX.
Thanks
Reputation Points: 13
Solved Threads: 21
Junior Poster
venkat0904 is offline Offline
186 posts
since Oct 2009
Nov 8th, 2009
0
Re: Posting data behind the scene
yeah i did this with form="target_blank" and then used php header to close the processing file. its really simple.
Reputation Points: 15
Solved Threads: 7
Posting Pro in Training
SKANK!!!!! is offline Offline
428 posts
since Apr 2009
Nov 8th, 2009
0
Re: Posting data behind the scene
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

Click to Expand / Collapse  Quote originally posted by SKANK!!!!! ...
yeah i did this with form="target_blank" and then used php header to close the processing file. its really simple.
Reputation Points: 13
Solved Threads: 21
Junior Poster
venkat0904 is offline Offline
186 posts
since Oct 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Returns only 1 record from mysql database..:(
Next Thread in PHP Forum Timeline: how to write regular expression in PHP?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC