Jump to content

Sending data between forms


crooksey

Recommended Posts

I have two forms that I have created.

 

I wonder if someone could point out where I am going wrong, all data is commented so it should be easier to understand.

 

form1.php

 

<?php     $digest = 0;    $amount = 0;$trans_id = 0;$merchant = "so";    $remotepassword = "s0";        if ($_POST) {        $digest_this = $_POST['trans_id'] + $_POST['amount'] + $remotepassword; //combine all my values to be md5'd        $digest = md5($digest_this); //generate the md5 hash	$amount = $_POST['amount']; //what I think I am doing here is posting the data so it can be retrived 	$trans_id = $_POST['trans_id']; //by a get request on from 2, this is where I need help	$merchant = $_POST['merhcant'];	$remotepassword = $_POST['remotepassword'];    } // end $_POST?>      <form action="part2.php" method="post">    <p>    <label for="trans_id">Invoice Number(s): </label>              <input id="trans_id" type="text" name="trans_id" /><br />    <label for="amount">Amount Paying: </label>              <input id="amount" type="text" name="amount" /><br />		  		  		  		  <input value="Send" type="submit" /> <input type="reset" /> </p></form>

 

 

form2.php

 

<?php if ($_GET) {	$digest = $_GET['digest'];  //here I think I am retriving the data I sent with a post request	$merchant = $_GET['merhcant']; //and then storing it in variables	$remotepassword = $_GET['remotepassword'];	$amount = $_GET['amount'];	$trans_id = $_GET['trans_id'];	} // end $_GET?><form action="https://www.secpay.com/java-bin/ValCard" method="post">    <p>    <label for="firstname">First Name: </label>              <input id="firstname" type="text" name="firstname" /><br />    <label for="lastname">Last Name: </label>              <input id="lastname" type="text" name="lastname" /><br />    <label for="account">Account Number: </label>              <input id="account" type="text" name="account" /><br />    <label for="housenumber">House Number/Name: </label>              <input id="housenumber" type="text" name="housenumber" /><br />          <label for="postcode">Postcode: </label>              <input id="postcode" type="text" name="postcode" /><br />        <label for="email">Email: </label>              <input id="email" type="text" name="email" /><br />    <label for="notes">Notes: </label>              <input id="notes" type="text" name="notes" /><br /><!-- Here I have taken all the inputs from the form that are required to be sent --><!-- and given the input_id names as the values required by the pay point servers -->        <input name="callback" value="http://www.sol.co.uk/authorised;http://www.sol.co.uk/declined" type="hidden" />    <input name="merchant" value="<?php echo "$merhcant"; ?>" type="hidden" /> <!--here I am populating hidden fields with php script data-->    <input name="remotepassword"  value="<?php echo "$remotepassword"; ?>" type="hidden" />    <input name="req_cv2" value="true" type="hidden" />    <input name="options" value="test_status=true" type="hidden" />        <input name="digest" value="<?php echo "$digest"; ?>" type="hidden" />    <!-- Here I have defined all of the constant hidden values that never change --> <!-- Now in this section of the form I have defined the value that will change, combining the three fields --> <!-- that are required in order to create the digest value -->    <input value="Send" type="submit" /> <input type="reset" /> </p></form>

 

 

Thanks for looking, I think its something basic im missing, first time doing this if you hadnt of guessed :)

Link to comment
Share on other sites

Perhaps you could explain the actual problem you are having?

 

It looks like the first form is receiving data via POST and you are using it to create variables - but you aren't doing anything with the data. But, there is a form created on that page. I *guess* that the form on the first page is POSTING to form 2. Form 2 is apparently checking for GET data, but no GET values were defined/set in the previous form. Try taking the values in FORM 1 and setting them as hidden fields as you did in form 2. Then those values will be available on form 2 from the POST values.

Link to comment
Share on other sites

What I am trying to do in form 1 is..

 

 

        $digest = md5($digest_this); //generate the md5 hash$amount = $_POST['amount']; //what I think I am doing here is posting the data so it can be retrived $trans_id = $_POST['trans_id']; //by a get request on from 2, this is where I need help$merchant = $_POST['merhcant'];$remotepassword = $_POST['remotepassword'];[code]I need to work out how to send this data to form two, thats all  So the data thats stored insinde these variables can then be passed to another website

 

Link to comment
Share on other sites

As I already stated. In the form 1 script all you are doing is creating variables which are not used on that page. As soon as that script completes execution those variables are lost. You should create hidden fields in form 1 with those values so they will be sent to form 2.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.