LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-01-2005, 10:17 AM   #1
AskMe
Member
 
Registered: Jul 2003
Posts: 123

Rep: Reputation: 15
Passing form values between multiple forms!!


How to pass values of Form A to form B then to form C which will have values of form A and Form B.
I mean passing value between multiple form, using either PHP and JavaScript if possible. I tried with hidden field and variable, but it did not work for me. Here is my codes:

Code for Form A named f1.php

Code:
<form method="POST" action="f2.php">    Bank Name:<input type="text" name="bankname" size="20"></p>  <p><input type="submit" value="Submit" >  <input type="reset" value="Reset"></p></form>
Code for Form B name f2.php

Code:
<?php$bankname=$_POST['bankname'];echo $bankname;?><form method="POST" action="f3.php"><input type="hidden" name="bankname" value="'<?php $bankname ?>'">  Sender Name:<input type="text" name="sendername" size="20"><input type="submit" value="Submit"></form><?php echo $bankname;?>
Here is the code for Form C named f3.php

Code:
<?php$bankname=$_POST['bankname'];$sendername=$_POST['sendername'];echo $bankname;echo $Sendername;?><form method="POST" action="f4.php"><input type="hidden" name="bankname" value="'<?php $bankname ?>'"><input type="hidden" name="sendername" value="'<?php $sendername ?>'">  Receiver Name:<input type="text" name="receivername" size="20"></p><p><input type="submit" value="Submit"><input type="reset" value="Reset"></p><hr></form><?phpecho $bankname;echo $sendername; ?>
I tried to debug by echoing values, but still not working.

Please help me how to do it.
Sample of the form I am looking can be found at site:

https://www.xoom.com/sendmoney/NP?am...NP&deliverin=1

Last edited by AskMe; 09-01-2005 at 10:21 AM.
 
Old 09-01-2005, 10:39 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Use code tags to make your script easier to read by others.
You can also look at the httpd logs for PHP errors. Typically /var/log/httpd/error_log

I do not see any obvious errors in your method but since it is somewhat difficult to read you might have PHP syntax errors. Again check the error_log.

Does the echo $bankname statement work i.e. do you see the variable you entered in form A?
 
Old 09-02-2005, 08:43 AM   #3
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Rep: Reputation: 30
on the second form you can print all the POST variables out like so :
PHP Code:
<?php
       
foreach($_POST as $k=>V) {
              print 
"<h1>POST[$k]: $v</h1>";
       }
then see what variables are getting posted and which one aren't

-djgerbavore
 
Old 09-04-2005, 03:28 AM   #4
AskMe
Member
 
Registered: Jul 2003
Posts: 123

Original Poster
Rep: Reputation: 15
When I pass from form A to Form B it passes correct values, but when I pass from form B to Form C, I get the following value
Code:
\\'\\'Alam
where Alam come from form B but form A value has changed to slashes only. Please advice me how to fix.

Thanks
 
Old 09-05-2005, 01:00 PM   #5
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Rep: Reputation: 30
when passing to B to C, You might have to make hidden values from the post of form A. OR another way is to start a session with session_start(); and use the $_SESSIO[] to pass between forms. If you go to php.net and lookup sessions there is tons of info about it. Good luck, let me know if this makes sense

djgerbavor3
 
Old 09-07-2005, 07:44 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Code:
<input type="hidden" name="bankname" value="'<?php $bankname ?>'">
You need to print the variable:
Code:
<input type="hidden" name="bankname" value="'<?php echo $bankname; ?>'">
BTW with your code bankname='$bankname'. Do you really need the '''?

Last edited by michaelk; 09-07-2005 at 07:58 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
command to resize forms contents when form is resized vb.net mrobertson Programming 1 07-14-2005 10:39 AM
passing an array from html-forms to php prabhatsoni Linux - Software 2 06-04-2005 12:11 AM
Sed Command & Passing Values joey52 Linux - Newbie 4 12-27-2004 07:46 PM
passing values in shell pantera Programming 1 05-20-2004 09:01 AM
Multiple Forms in Qt Application 00it45 Programming 9 02-17-2004 01:41 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration