Problems with php code within a php code...
Posted: Sun Feb 19, 2006 7:16 pm
Hey guys sorry for another question i keep running into issues...
Right now im building a form validator, a javascript one reads the forms first and if it works it loads a php code to check them.
I tested it and it works pretty good, however it is a seperate file named...shipping.php. Now it is a mix of html and php for example most of the start is html but the php code is at the end when the submit button is pressed. however i want to include this into my main layout code which is all php. This is the issue...
as you can see the single quotes won't work in the php file but if i add slashes, the php code won't work....what do i do to fix this?
Right now im building a form validator, a javascript one reads the forms first and if it works it loads a php code to check them.
I tested it and it works pretty good, however it is a seperate file named...shipping.php. Now it is a mix of html and php for example most of the start is html but the php code is at the end when the submit button is pressed. however i want to include this into my main layout code which is all php. This is the issue...
Code: Select all
$add_end = '<?php {
$_SESSION['session_page_error'] = ""
include 'includes/cart_functions.php';
$size_select = $_POST['size'];
$quantity_select = $_POST['quantity'];
switch ($size_select) {
case 'small':
$quantity_max = $small_stock;
$small_up = $quantity_select;
break;
case ' medium';
$quantity_max = $medium_stock;
$medium_up = $quantity_select;
break;
case 'large';
$quantity_max = $large_stock;
$large = $quantity_select;
break;
case 'xlarge';
$quantity_max = $xlarge_stock;
$xlarge = $quantity_select;
break;
}
if ($quantity_max < $quantity_select) {
$_SESSION['session_page_error'] = "Quantity selected is larger then stock.";
}
else if ($quantity_select == '') {
$_SESSION['session_page_error'] = "Please enter a quantity.";
}
else if ($quantity_select == '0') {
$_SESSION['session_page_error'] = "Please enter a quantity greater then 1.";
}
else {
AddToCart($sid,$directory,$small_up,$medium_up,$large_up,$xlarge_up);
}
}
?>';