Web Hosting Talk







View Full Version : Agreement / PHP Variables


BrandonSCSN
05-06-2006, 10:59 PM
Hello,

I am looking for a method which will allow me to do the following.

On a site, a client will click a "Order Now" button. This button would typically go to ModernBill, and includes in its link the extra variables needed to perform order group selection and package selection.

However, I want the client to hit a "Order Now" button and then be redirected to a agree.php page. The extra variables would also be directed towards this page. Upon agreeing to this page, they would then be redirected to orderwiz.php and all of the extra variables would add themselves to the address.

Is there any easy way to accomplish this?

Thanks

BrandonSCSN
05-07-2006, 01:52 AM
For reference, here is how I did it

<a href="http://ordersitehere/orderwiz.php?v=<?php
$order = $_GET['order'];
echo $order;
?>&submit_package=<?php
$pack = $_GET['pack'];
echo $pack;
?>&type3_package=<?php
$packid = $_GET['packid'];
echo $packid;
?>">I agree</a>

BETIServices
05-07-2006, 03:22 AM
For reference, here is how I did it

<a href="http://ordersitehere/orderwiz.php?v=<?php
$order = $_GET['order'];
echo $order;
?>&submit_package=<?php
$pack = $_GET['pack'];
echo $pack;
?>&type3_package=<?php
$packid = $_GET['packid'];
echo $packid;
?>">I agree</a>

How and where do you insert that code, interesting topic :)

error404
05-07-2006, 03:31 AM
Just store the state in a session:

// Before headers are sent (on all pages reading/writing the data):
session_start();

// Save the state
$_SESSION['var1'] = $var1;
$_SESSION['var2'] = $var2;

// Read the state.
$var1 = $_SESSION['var1'];
$var2 = $_SESSION['var2'];


See: http://www.php.net/manual/en/ref.session.php

Better than passing it somewhere that it's exposed to the user, especially if you're not doing sanity checks on the data. Simpler too. Just make sure to clear the data (unset($_SESSION['var1']) etc.) when you're done with it in case the user navigates again to the intermediate page.

gedevelopment
05-07-2006, 06:16 AM
<a href="http://ordersitehere/orderwiz.php?v=<?php
$order = $_GET['order'];
echo $order;
?>&submit_package=<?php
$pack = $_GET['pack'];
echo $pack;
?>&type3_package=<?php
$packid = $_GET['packid'];
echo $packid;
?>">I agree</a>

I would say you dont need the "echo" statement in there. Should work with just $_GET['var'];

BrandonSCSN
05-07-2006, 10:05 AM
Just store the state in a session:

// Before headers are sent (on all pages reading/writing the data):
session_start();

// Save the state
$_SESSION['var1'] = $var1;
$_SESSION['var2'] = $var2;

// Read the state.
$var1 = $_SESSION['var1'];
$var2 = $_SESSION['var2'];


See: http://www.php.net/manual/en/ref.session.php

Better than passing it somewhere that it's exposed to the user, especially if you're not doing sanity checks on the data. Simpler too. Just make sure to clear the data (unset($_SESSION['var1']) etc.) when you're done with it in case the user navigates again to the intermediate page.

This would require modification however of orderwiz.php correct? I dont believe I can do that...

error404
05-07-2006, 10:26 AM
This would require modification however of orderwiz.php correct? I dont believe I can do that...

Ah yes, my mistake, I didn't notice you needed to work with ModernBill. The easiest solution is probably to use the hidden fields proposed by the other user in the other thread you created. Unfortunately you have to expose those values to the user, so make sure you can't get scammed if they get changed.

dollar
05-07-2006, 10:33 AM
Without diving into exact code, as a general idea for this I would simply create a small PHP script at the top of the agreement page to go through the entire $_POST and $_GET variables, strip them and ammend them to a form at the bottom of the agreement page.

The form at the bottom of the agreement page would POST to the orderwiz.php page with all the get variables and would have all the post variables as hidden form elements in the form.

If this isn't quite clear enough let me know.

It would end up something like:


<form method="post" action="orderwiz.php?var1=blah&var2=haha&name=dollar">
<input type="hidden" name="var5" value="something />
<input type="button" name="Submit" value="Submit" />
</form>