...

View Full Version : Redirection script help



Dshah
10-19-2009, 08:32 AM
Hello like always i belive this forum is the best . i hope i will get some quick help as this is my last step of this script. Here what i wants to do is i have a form which have two submit button if user will click on first the amount of his chosen detail will be added to his shopping cart, shopping cart is ready and is fully integrated with paypal but i wants to add this form in that cart too. second if they click they will be redirected to paypage . here is what i have done so far. but i am not sure what to do next please help :



<?php ob_start() ;
session_start();
//including database information
include("db_fns.php");
//including header detail
include("include_header.php");?>
<title>Payments</title>
</head>

<body>


<h2>Payment Options</h2>
<br /><br /><br />
<?php
// These are the variable coming from previouse page when user submit registration from'

$title = $_SESSION['title'];
$name = $_SESSION['name'];
$lname = $_SESSION['lname'];
$insurance = $_SESSION['insurance'];
$postal = $_SESSION['postal'];
$address =$_SESSION['address'];
$phone = $_SESSION['phone'];
$email = $_SESSION['email'];
$registration = $_SESSION['registration'];
$city = $_SESSION['city'];
$date = $_SESSION['date'];
$comments = $_SESSION['comments'];

// these are the test detail coming from database i assign to variables to use in script
$cscstest = find_product(15) ;
$cscsoperative = find_product(16) ;
$cscsmanager = find_product(17) ;
$cscssupervisor = find_product(18) ;
$cscsprofessinal =find_product(19) ;

//these are the extra language variables from databse

$english = find_product_extra(1);
$bulgraian = find_product_extra(2);
$german = find_product_extra(3);
$lithuanian = find_product_extra(4);
$polish = find_product_extra(5);
$portuguese = find_product_extra(6);
$punjabi = find_product_extra(7);
$romanian = find_product_extra(8);
$russian = find_product_extra(9);
// if user click on "Wish to Buy Revision Material" all the info will be added to shopping cart and i get email and i am not sure how to do it below now
if (isset($_POST['sub1'])) {

if(isset($_POST['cscstest'])) {



}

header('Location: index.php');
//here is when user click on payment he will be redirected to paypal with all info but stuck on this point
}elseif(isset($_POST['sub2'])) {

header('Location: http://www.paypal.com');

}

echo 'Hello '.$_SESSION['name']. ' ! Thank you for choosing to book your test with us.. Please choose a Test below: ';
?>
<div id="form">
<script>
function openPopup(url) {
window.open(url, "popup_id", "scrollbars,resizable,width=500,height=600");
return false;
}
</script>

<form action="payments.php" method="POST">
<table width="720px">


<tr>
<td align="right"><input type="checkbox" onchange = "enableAll()" id ="cscstest" name="<?php echo $cscstest['title']; ?>" value="<?php echo $cscstest['price']; ?>"></td>
<td>
<?php echo $cscsoperative['title']; ?> - &pound;<?php echo number_format($cscsoperative['price'], 2); ?> <br />
</td>
</tr>
<tr>
<td align="right">
Select Desired Test:
</td>
<td>
<select id ="multiple" name ="cscstest" disabled = "true" style="width: 200px; border:1px solid #4088b8; color:#111111; font-family:Arial; background:#ffffff;" id='test_type_id' onfocus="style.width=300" onBlur="style.width=200">
<option value="<?php echo $cscsoperative['id']; ?>"><?php echo $cscsoperative['title']; ?></option>
<option value="<?php echo $cscsmanager['id']; ?>"><?php echo $cscsmanager['title']; ?> (&pound;10 Extra) </option>
<option value="<?php echo $cscssupervisor['id']; ?>"><?php echo $cscssupervisor['title']; ?> (&pound;10 Extra) </option>
<option value="<?php echo $cscsprofessinal['id']; ?>"><?php echo $cscsprofessinal['title']; ?></option>
</select>
</td>
</tr>
<tr>
<td align="right">
Quantity for Manager/Supervisor test<br /> ( multiple bookings only):
</td>
<td>
<input style="border:1px solid #4088b8;" type="text" size="4" disabled = "true" name="multipleqty" id ="multiqty">
</td>
</tr>
<tr>
<td align="right">
Quantity for All other tests:
</td>
<td>
<input style="border:1px solid #4088b8;" type="text" size="4" disabled = "true" name="otherqty" id ="otherqty">
</td>
</tr>
<tr>
<td align="right">
Test in different Language Price &pound;7.50:
</td>
<td>
<select id ="extralan" disabled = "true" STYLE="width: 200px; border:1px solid #4088b8; color:#111111; font-family:Arial; background:#ffffff;" id='test_type_id' onfocus="style.width=300" onBlur="style.width=200">
<option value="<?php echo $english['price']; ?>"><?php echo $english['title']; ?></option>
<option value="<?php echo $bulgarian['price']; ?>"><?php echo $bulgraian['title']; ?></option>
<option value="<?php echo $german['price']; ?>"><?php echo $german['title']; ?></option>
<option value="<?php echo $lithuanian['price']; ?>"><?php echo $lithuanian['title']; ?></option>
<option value="<?php echo $polish['price']; ?>"><?php echo $polish['title']; ?></option>
<option value="<?php echo $portuguese['price']; ?>"><?php echo $portuguese['title']; ?></option>
<option value="<?php echo $punjabi['price']; ?>"><?php echo $punjabi['title']; ?></option>
<option value="<?php echo $romanian['price']; ?>"><?php echo $romanian['title']; ?></option>
<option value="<?php echo $russian['price']; ?>"><?php echo $russian['title']; ?></option>
</select>
</td>
</tr>
<tr>
<td align="right">
Language tests Quantity<br /> (only for multiple bookings):
</td>
<td>
<input name="languagetestqty" id ="languagetestqty" style="border:1px solid #4088b8;" disabled = "true" type="text" size="4" name="lname">
</td>
</tr>
<tr>
<td align="right"><input type="checkbox" id = "chk1"></td>
<td width="50" colspan="3">
In order to proceed you must check this box. By Clicking this box you are agree to our <a href="termsconditions.php" onclick="return openPopup(this.href);">Terms & Conditions</a>
</td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr>
<td>&nbsp;</td>
<td><input type="image" name="sub1" src="../images/revision.png" value="Do you wish to buy Revision Material" onClick="if(document.getElementById('chk1').checked) {this.form.action='payments.php';this.form.submit()}" />
</td><td><input type="image" name="sub2" src="../images/payment.png" value="Proceed To Payment" onClick="if(document.getElementById('chk1').checked) {this.form.action='payments.php';this.form.submit()}" /></td>
</tr>
</table>
</form>
</div>
<!-- And this script is mess could you fix it plz-->
<script type = "text/javascript">
function enableAll() {
var sel = document.getElementById("cscstest").value;
if (sel != 0) {
document.getElementById("multiple").disabled = false;
document.getElementById("multipleqty").disabled = false;
document.getElementById("otherqty").disabled = false;
document.getElementById("extralan").disabled = false;
document.getElementById("languagetestqty").disabled = false;
}
else {
document.getElementById("multiple").disabled = true;
document.getElementById("multipleqty").disabled = true;
document.getElementById("otherqty").disabled = true;
document.getElementById("extralan").disabled = true;
document.getElementById("languagetestqty").disabled = true;
}
}
</script>
<?php include_once("sidebar_reg.php");?>

<?php include_once("include_footer.php");?>

</div>
</body>
</html>
<?php ob_flush() ?>

Please any help on this point i am not sure what to do :confused:



if (isset($_POST['sub1'])) {

if(isset($_POST['cscstest'])) {



}

header('Location: index.php');
//here is when user click on payment he will be redirected to paypal with all info but stuck on this point
}elseif(isset($_POST['sub2'])) {

header('Location: http://www.paypal.com');

}

abduraooft
10-19-2009, 08:42 AM
You should move all your php code up to the header() function call to the very top of your page, to get it redirected.
<?php
// These are the variable coming from previouse page when user submit registration from'

$title = $_SESSION['title'];
$name = $_SESSION['name'];
$lname = $_SESSION['lname'];
$insurance = $_SESSION['insurance'];
$postal = $_SESSION['postal'];
$address =$_SESSION['address'];
$phone = $_SESSION['phone'];
$email = $_SESSION['email'];
$registration = $_SESSION['registration'];
$city = $_SESSION['city'];
$date = $_SESSION['date'];
$comments = $_SESSION['comments'];

// these are the test detail coming from database i assign to variables to use in script
$cscstest = find_product(15) ;
$cscsoperative = find_product(16) ;
$cscsmanager = find_product(17) ;
$cscssupervisor = find_product(18) ;
$cscsprofessinal =find_product(19) ;

//these are the extra language variables from databse

$english = find_product_extra(1);
$bulgraian = find_product_extra(2);
$german = find_product_extra(3);
$lithuanian = find_product_extra(4);
$polish = find_product_extra(5);
$portuguese = find_product_extra(6);
$punjabi = find_product_extra(7);
$romanian = find_product_extra(8);
$russian = find_product_extra(9);
// if user click on "Wish to Buy Revision Material" all the info will be added to shopping cart and i get email and i am not sure how to do it below now
if (isset($_POST['sub1'])) {

if(isset($_POST['cscstest'])) {



}

header('Location: index.php');
//here is when user click on payment he will be redirected to paypal with all info but stuck on this point
}elseif(isset($_POST['sub2'])) {

header('Location: http://www.paypal.com');

}

Dshah
10-19-2009, 04:18 PM
OK thanks now actully i am having issue to include an item in cart . here is the function which take the parameters and add to cart.


function add_to_cartt($id, $qty) {
if (isset($_SESSION['cart'][$id])) {
$_SESSION['cart'][$id] += $qty;
} else {
$_SESSION['cart'][$id] = $qty;
}
return $_SESSION['cart'][$id];
}

//which i use here

if (isset($_POST['cscstest'])) {
$id = $_POST['cscstest'];
$qty = $_POST['multiqty'];
$add_item = add_to_cartt($id, $qty);
$_SESSION['total_items'] = total_items($_SESSION['cart']);
$_SESSION['total_price'] = total_price($_SESSION['cart']);
}


but it only include the name and display the price but not include in quantitiy or in actual payment detail. any help please what i am missing.
Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum