I’m trying to get a form to work correctly in modx, but i’m having some trouble. Maybe someone can help.
I have an inventory list that I’m trying to pass some of the info off to a bill of sale form, that then sends the info to a printable page.
I have a page that has this ditto call:
[!Ditto? &parents=`1` &tpl=`bos_inventory` !]
This is the bos_inventory template:
<p><a href="[~6~]&var1=[+id+]"><strong>[+year+] [+make+]</strong> $[+price+] VIN: [+vin+]</a></p>
When the user clicks that link, it takes them to a page that has
[!Ditto? &documents=`[[get_passed_variables]]` &tpl=`MM_BOS_Form_Template` !]
get_passed_variables is simply:
<?php
$var1=$_GET[’var1’];
echo $_GET[’var1’];
?>
The MM_BOS_Form_Template is simply a long form that fills in a few of the fields with values from the ID that was passed to it. I want the user to be able to fill in/edit whatever fields they want, and hit submit to send it to a printer friendly, nicely formatted page.
I’ve tried to add PHP to the top of this template, but haven’t had any luck.
---
[[form_sending]]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Marshal’s Motors Bill of Sale Form</title>
<link href="[(base_url)]assets/templates/bill_of_sale/bill-of-sale-form.css" rel="stylesheet" type="text/css" />
</head>
<body>
[*#content*]
</body>
</html>
the form sending snippet has this php in it:
<?php
if (array_key_exists(’submit’, $_POST)) {
session_start();
$_SESSION = array();
$_SESSION[’formStarted’] = true;
$required = array(’make’);
$missing = array();
foreach ($_POST as $key => $value) {
$temp = is_array($value) ? $value : trim($value);
if (empty($temp) && in_array($key, $required)) {
array_push($missing, $key);
}
else {
$_SESSION[$key] = $temp;
}
}
if (!$missing) {
header(’Location: http://localhost:8888/modx/assets/templates/bill_of_sale/page_2.php’);
exit;
}
}
?>
Is that clear as mud? Everything works until I try to click the submit button. Any ideas?
Thanks a lot!!!