Posting data behind the scene

Reply

Join Date: Apr 2008
Posts: 495
Reputation: veledrom is an unknown quantity at this point 
Solved Threads: 0
veledrom veledrom is offline Offline
Posting Pro in Training

Posting data behind the scene

 
0
  #1
22 Days Ago
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,612
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 464
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven
 
1
  #2
22 Days Ago
You can use AJAX to post form data. Take a look at this link http://www.captain.at/howto-ajax-form-post-request.php
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 147
Reputation: venkat0904 is an unknown quantity at this point 
Solved Threads: 15
venkat0904's Avatar
venkat0904 venkat0904 is offline Offline
Junior Poster
 
-1
  #3
22 Days Ago
This is where AJAX comes into play... For basics refer
http://www.w3schools.com/Ajax/Default.Asp

Originally Posted by veledrom View 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
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 101
Reputation: leviathan185 is an unknown quantity at this point 
Solved Threads: 14
leviathan185's Avatar
leviathan185 leviathan185 is offline Offline
Junior Poster
 
0
  #4
22 Days Ago
Originally Posted by veledrom View 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
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.

  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

  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
@ I'm gonna live forever, or die trying.

@ A wise man once told me, in order to understand recursion, you first must understand recursion.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 147
Reputation: venkat0904 is an unknown quantity at this point 
Solved Threads: 15
venkat0904's Avatar
venkat0904 venkat0904 is offline Offline
Junior Poster
 
0
  #5
22 Days Ago
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.

Originally Posted by leviathan185 View Post
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.

  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

  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
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 101
Reputation: leviathan185 is an unknown quantity at this point 
Solved Threads: 14
leviathan185's Avatar
leviathan185 leviathan185 is offline Offline
Junior Poster
 
0
  #6
22 Days Ago
Originally Posted by venkat0904 View Post
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.
@ I'm gonna live forever, or die trying.

@ A wise man once told me, in order to understand recursion, you first must understand recursion.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 495
Reputation: veledrom is an unknown quantity at this point 
Solved Threads: 0
veledrom veledrom is offline Offline
Posting Pro in Training
 
0
  #7
22 Days Ago
Ok guys thanks for your very helpful information. Now i go and read about AJAX.
Thanks
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 147
Reputation: venkat0904 is an unknown quantity at this point 
Solved Threads: 15
venkat0904's Avatar
venkat0904 venkat0904 is offline Offline
Junior Poster
 
0
  #8
22 Days Ago
anytime... n do remember to mark the thread as solved wen u r done...
Originally Posted by veledrom View Post
Ok guys thanks for your very helpful information. Now i go and read about AJAX.
Thanks
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 281
Reputation: SKANK!!!!! is an unknown quantity at this point 
Solved Threads: 2
SKANK!!!!! SKANK!!!!! is offline Offline
Posting Whiz in Training
 
0
  #9
20 Days Ago
yeah i did this with form="target_blank" and then used php header to close the processing file. its really simple.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 147
Reputation: venkat0904 is an unknown quantity at this point 
Solved Threads: 15
venkat0904's Avatar
venkat0904 venkat0904 is offline Offline
Junior Poster
 
0
  #10
20 Days Ago
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

Originally Posted by SKANK!!!!! View Post
yeah i did this with form="target_blank" and then used php header to close the processing file. its really simple.
Gimme reputation points if u find my post helpful.
use [code] tags wherever applicable
dont start a new thread unless u cant find the topic already on forum.
mark a thread "solved" as soon as u get a solution
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC