<script>
var groupText="";
<?php
include_once ("config.php");
if($_REQUEST["state_id"]){
$state_id = htmlspecialchars(stripslashes($_REQUEST["state_id"]));
$sql = "SELECT displayPrice,displaySize,state_id FROM spa_states WHERE state_id=$state_id";
$query = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($query)) {
if ($row["displayPrice"]!="") {
print "\ngroupText='<b>$".$row["displayPrice"]." for ".$row["displaySize"]." column inche(s).</b>';";
print "\nparent.document.getElementById('GroupPrice').innerHTML=groupText;";
}
else {
print "\ngroupText='No price/data for this ID.'";
}
}
}
else{
print "\ngroupText='Must have a valid ID to continue.'";
}
?>
</script>
<script>
var groupText="";
<?php
include_once ("config.php");
if($_REQUEST["state_id"]){
$state_id = htmlspecialchars(stripslashes($_REQUEST["state_id"]));
$sql = "SELECT displayPrice,displaySize,state_id FROM spa_states WHERE state_id=$state_id";
$query = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($query)) {
if ($row["displayPrice"]!="") {
print "\ngroupText='<b>$".$row["displayPrice"]." for ".$row["displaySize"]." column inche(s).</b>';";
print "\nparent.document.getElementById('GroupPrice').innerHTML=groupText;";
}
else {
print "\ngroupText='No price/data for this ID.'";
}
}
}
else{
print "\ngroupText='Must have a valid ID to continue.'";
}
print " <input type='hidden' id='state_id' value='".$state_id."' />";
?>
<?php
if(isset($_POST['submit'])) {
$fields = array("fn"=>"First Name", "ln"=>"Last Name", "company"=>"Company Name", "email"=>"E-mail","phone"=>"Phone","date"=>"Starting Date","comments"=>"Comments");
$error_message = "<b>Please complete the following fields:</b> <br>";
$error = 0;
foreach($fields as $key=>$value){
if(!isset($_POST[$key]) || empty($_POST[$key])){
$error_message .= $value."<br>";
$error = 1;
}
}
$name = $_FILES['imagefile']['name'];
$type = strtolower($_FILES['imagefile']['type']);
if ( strlen($name) > 0 ) {
if ( $type != "image/gif" && $type != "image/jpeg" && $type != "image/png" && $type != "image/jpg" ) {
$error = 1;
$error_message .= "<p>The file type ($type) is invalid - please use jpg, png or gif</p>";
}
}
move_uploaded_file ($_FILES['imagefile']['tmp_name'], "images/imageUploads/".$name );
if(empty($error)){
$weeks = $_REQUEST["weeks"];
$fn = $_REQUEST["fn"];
$ln = $_REQUEST["ln"];
$company = $_REQUEST["company"];
$email = $_REQUEST["email"];
$phone = $_REQUEST["phone"];
$date = $_REQUEST["date"];
$comments = $_REQUEST["comments"];
$price = $_REQUEST["price"];
$size = $_REQUEST["size"];
$paper_name = $_REQUEST["paper_name"];
$params = "weeks=".urlencode($weeks)."&";
$params .= "fn=".urlencode($fn)."&";
$params .= "ln=".urlencode($ln)."&";
$params .= "company=".urlencode($company)."&";
$params .= "email=".urlencode($email)."&";
$params .= "phone=".urlencode($phone)."&";
$params .= "date=".urlencode($date)."&";
$params .= "comments=".urlencode($comments)."&";
$params .= "price=".urlencode($price)."&";
$params .= "size=".urlencode($size)."&";
$params .= "paper_name=".urlencode($paper_name)."&";
$params .= "uploadedFile=".urlencode($name);
$params .= "&p=confirm-d";
$params .= "&id=". intval($_REQUEST['id']);
$loc = "http://{$_SERVER['HTTP_HOST']}/". dirname($_SERVER['PHP_SELF']). "/index.php?$params";
echo $loc. "<br />\n";
die(1);
header("Location: $loc");
exit;
}
else
print $error_message;
}
?>
<h2>Place Ad for SPA</h2>
<span id="GroupPrice"></span><br />
<span id="WordPrice"></span><br />
<form name="calculate-spa-d" action="index.php" method="post" class="niceform" enctype="multipart/form-data">
<label for="state_id">Choose state:</label><br />
<select name="state_id" id="state_id" onChange="this.form.submit()" >
<?php
$ln = htmlspecialchars( stripslashes( $_REQUEST['ln'] ), ENT_QUOTES );
$fn = htmlspecialchars( stripslashes( $_REQUEST['fn'] ), ENT_QUOTES );
$company = htmlspecialchars( stripslashes( $_REQUEST['company'] ), ENT_QUOTES );
$email = htmlspecialchars( stripslashes( $_REQUEST['email'] ), ENT_QUOTES );
$phone = htmlspecialchars( stripslashes( $_REQUEST['phone'] ), ENT_QUOTES );
$date = htmlspecialchars( stripslashes( $_REQUEST['date'] ), ENT_QUOTES );
$comments = htmlspecialchars( stripslashes( $_REQUEST['comments'] ), ENT_QUOTES );
$imagefile = htmlspecialchars( stripslashes( $_REQUEST['imagefile'] ), ENT_QUOTES );
$state = "SELECT state_id, state_name FROM spa_states WHERE state_id<>2 AND state_id<>9 AND state_id<>11 AND state_id<>23 AND state_id<>22 AND state_id<>25 AND state_id<>26 ORDER BY state_id ASC";
$result = mysql_query($state) or die(mysql_error());
while ($row1 = mysql_fetch_array($result)){
print '<option value="'.$row1["state_id"].'">'.$row1["state_name"].'</option>'."\n";
}
print '</select><br />';
?>
<label for="weeks">Weeks to run ad:</label><br />
<select name="weeks" id="weeks">
<option value="1">1 week</option>
<option value="2">2 weeks</option>
<option value="3">3 weeks</option>
<option value="4">4 weeks</option>
</select><br />
<label for="fn">First Name:</label><br />
<input type="text" name="fn" id="fn" size="20" value="<?php echo $fn; ?>" /><br />
<label for="ln">Last Name:</label><br />
<input type="text" name="ln" id="ln" size="20" value="<?php echo $ln; ?>" /><br />
<label for="company">Company Name:</label><br />
<input type="text" name="company" id="company" size="20" value="<?php echo $company; ?>" /><br />
<label for="email">E-mail:</label><br />
<input type="text" name="email" id="email" size="20" value="<?php echo $email; ?>" /><br />
<label for="phone">Phone:</label><br />
<input type="text" name="phone" id="phone" size="20" value="<?php echo $phone; ?>" /><br />
<label for="date">Starting Date:</label><br />
<input type="text" name="date" id="date" size="20" title="Click to select date" value="<?php echo $date; ?>" /><br />
<label for="comments">Comments:</label><br />
<textarea name="comments" id="comments" rows="5" cols="20"><?php echo $comments; ?></textarea><br />
<label for="comments">Display Ad:</label><br />
<input type="file" name="imagefile" /><br /><br />
<input name="p" type="hidden" value="calc-spa-d" />
<input type="hidden" name="price" value="<?php echo $price; ?>">
<input type="hidden" name="size" value="<?php echo $size; ?>">
<input type="hidden" name="paper_name" value="<?php echo $state; ?>">
<input name="id" type="hidden" value="<?php echo intval($_REQUEST['id']); ?>" />
<input type='hidden' id='state_id_submit' value='' />
<script type='javascript' >
function setvalue(){
document.getElementById('state_id_submit').value=document.getElementById('state_id').value;
}
</script>
<input type="submit" name="Submit" value="Calculate!" />
</form>
<iframe name="if1" src="about:blank" width="1" height="1"></iframe>
<script>
tId1 = setInterval('showPriceD()',200);
</script>
<input type="hidden" name="state_id" id="state_id" value="">
<input type="hidden" name="price" id="price" value="">
<input type="hidden" name="size" id="size" value="">
<input type="hidden" name="paper_name" id="paper_name" value="">
<script type='javascript' >
function setvalue(){
document.getElementById('state_id').value=document.getElementById('state_id').value;
document.getElementById('price').value=document.getElementById('price').value;
document.getElementById('size').value=document.getElementById('size').value;
document.getElementById('paper_name').value=document.getElementById('paper_name').value;
}
</script>
<?php
if(isset($_POST['submit'])) {
$fields = array("fn"=>"First Name", "ln"=>"Last Name", "company"=>"Company Name", "email"=>"E-mail","phone"=>"Phone","date"=>"Starting Date","comments"=>"Comments");
$error_message = "<b>Please complete the following fields:</b> <br>";
$error = 0;
foreach($fields as $key=>$value){
if(!isset($_POST[$key]) || empty($_POST[$key])){
$error_message .= $value."<br>";
$error = 1;
}
}
$name = $_FILES['imagefile']['name'];
$type = strtolower($_FILES['imagefile']['type']);
if ( strlen($name) > 0 ) {
if ( $type != "image/gif" && $type != "image/jpeg" && $type != "image/png" && $type != "image/jpg" ) {
$error = 1;
$error_message .= "<p>The file type ($type) is invalid - please use jpg, png or gif</p>";
}
}
move_uploaded_file ($_FILES['imagefile']['tmp_name'], "images/imageUploads/".$name );
if(empty($error)){
$weeks = $_REQUEST["weeks"];
$fn = $_REQUEST["fn"];
$ln = $_REQUEST["ln"];
$company = $_REQUEST["company"];
$email = $_REQUEST["email"];
$phone = $_REQUEST["phone"];
$date = $_REQUEST["date"];
$comments = $_REQUEST["comments"];
$price = $_REQUEST["price"];
$size = $_REQUEST["size"];
$paper_name = $_REQUEST["paper_name"];
$params = "weeks=".urlencode($weeks)."&";
$params .= "fn=".urlencode($fn)."&";
$params .= "ln=".urlencode($ln)."&";
$params .= "company=".urlencode($company)."&";
$params .= "email=".urlencode($email)."&";
$params .= "phone=".urlencode($phone)."&";
$params .= "date=".urlencode($date)."&";
$params .= "comments=".urlencode($comments)."&";
$params .= "price=".urlencode($price)."&";
$params .= "size=".urlencode($size)."&";
$params .= "paper_name=".urlencode($paper_name)."&";
$params .= "uploadedFile=".urlencode($name);
$params .= "&p=confirm-d";
$params .= "&id=". intval($_REQUEST['id']);
$loc = "http://{$_SERVER['HTTP_HOST']}/". dirname($_SERVER['PHP_SELF']). "/index.php?$params";
echo $loc. "<br />\n";
die(1);
header("Location: $loc");
exit;
}
else
print $error_message;
}
?>
<h2>Place Ad for SPA</h2>
<span id="GroupPrice"></span><br />
<span id="WordPrice"></span><br />
<form name="calculate-spa-d" action="index.php" method="post" class="niceform" enctype="multipart/form-data">
<label for="state_id">Choose state:</label><br />
<select name="state_id" id="state_id" onChange="this.form.submit()" >
<?php
$ln = htmlspecialchars( stripslashes( $_REQUEST['ln'] ), ENT_QUOTES );
$fn = htmlspecialchars( stripslashes( $_REQUEST['fn'] ), ENT_QUOTES );
$company = htmlspecialchars( stripslashes( $_REQUEST['company'] ), ENT_QUOTES );
$email = htmlspecialchars( stripslashes( $_REQUEST['email'] ), ENT_QUOTES );
$phone = htmlspecialchars( stripslashes( $_REQUEST['phone'] ), ENT_QUOTES );
$date = htmlspecialchars( stripslashes( $_REQUEST['date'] ), ENT_QUOTES );
$comments = htmlspecialchars( stripslashes( $_REQUEST['comments'] ), ENT_QUOTES );
$imagefile = htmlspecialchars( stripslashes( $_REQUEST['imagefile'] ), ENT_QUOTES );
$state = "SELECT state_id, state_name FROM spa_states WHERE state_id<>2 AND state_id<>9 AND state_id<>11 AND state_id<>23 AND state_id<>22 AND state_id<>25 AND state_id<>26 ORDER BY state_id ASC";
$result = mysql_query($state) or die(mysql_error());
while ($row1 = mysql_fetch_array($result)){
print '<option value="'.$row1["state_id"].'">'.$row1["state_name"].'</option>'."\n";
}
print '</select><br />';
?>
<label for="weeks">Weeks to run ad:</label><br />
<select name="weeks" id="weeks">
<option value="1">1 week</option>
<option value="2">2 weeks</option>
<option value="3">3 weeks</option>
<option value="4">4 weeks</option>
</select><br />
<label for="fn">First Name:</label><br />
<input type="text" name="fn" id="fn" size="20" value="<?php echo $fn; ?>" /><br />
<label for="ln">Last Name:</label><br />
<input type="text" name="ln" id="ln" size="20" value="<?php echo $ln; ?>" /><br />
<label for="company">Company Name:</label><br />
<input type="text" name="company" id="company" size="20" value="<?php echo $company; ?>" /><br />
<label for="email">E-mail:</label><br />
<input type="text" name="email" id="email" size="20" value="<?php echo $email; ?>" /><br />
<label for="phone">Phone:</label><br />
<input type="text" name="phone" id="phone" size="20" value="<?php echo $phone; ?>" /><br />
<label for="date">Starting Date:</label><br />
<input type="text" name="date" id="date" size="20" title="Click to select date" value="<?php echo $date; ?>" /><br />
<label for="comments">Comments:</label><br />
<textarea name="comments" id="comments" rows="5" cols="20"><?php echo $comments; ?></textarea><br />
<label for="comments">Display Ad:</label><br />
<input type="file" name="imagefile" /><br /><br />
<input name="p" type="hidden" value="calc-spa-d" />
<input name="id" type="hidden" value="<?php echo intval($_REQUEST['id']); ?>" />
<input type="hidden" name="state_id" id="state_id" value="">
<input type="hidden" name="price" id="price" value="">
<input type="hidden" name="size" id="size" value="">
<input type="hidden" name="paper_name" id="paper_name" value="">
<script type='javascript' >
function setvalue(){
document.getElementById('state_id').value=document.getElementById('state_id').value;
document.getElementById('price').value=document.getElementById('price').value;
document.getElementById('size').value=document.getElementById('size').value;
document.getElementById('paper_name').value=document.getElementById('paper_name').value;
}
</script>
<input type="submit" name="Submit" value="Calculate!" />
</form>
<iframe name="if1" src="about:blank" width="1" height="1"></iframe>
<script>
tId1 = setInterval('showPriceD()',200);
</script>
<script>
var groupText="";
<?php
include_once ("config.php");
if($_REQUEST["state_id"]){
$state_id = htmlspecialchars(stripslashes($_REQUEST["state_id"]));
$sql = "SELECT displayPrice,displaySize,state_id FROM spa_states WHERE state_id=$state_id";
$query = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($query)) {
if ($row["displayPrice"]!="") {
print "\ngroupText='<b>$".$row["displayPrice"]." for ".$row["displaySize"]." column inche(s).</b>';\n";
print "\nparent.document.getElementById('GroupPrice').innerHTML=groupText;\n";
}else{
print "\ngroupText='No price/data for this ID.'";
}
}
}
else{
print "\ngroupText='Must have a valid ID to continue.'";
}
?>
</script>
<?
print "\n<input type='hidden' id='state_id_ajax' value='".$state_id_ajax."' />";
print "\n<input type='hidden' id='size_ajax' value='".$size_ajax."' />";
print "\n<input type='hidden' id='price_ajax' value='".$price_ajax."' />";
print "\n<input type='hidden' id='paper_name_ajax' value='".$paper_name_ajax."' />\n";
?>
<?php
if(isset($_POST['submit'])) {
$fields = array("fn"=>"First Name", "ln"=>"Last Name", "company"=>"Company Name", "email"=>"E-mail","phone"=>"Phone","date"=>"Starting Date","comments"=>"Comments");
$error_message = "<b>Please complete the following fields:</b> <br>";
$error = 0;
foreach($fields as $key=>$value){
if(!isset($_POST[$key]) || empty($_POST[$key])){
$error_message .= $value."<br>";
$error = 1;
}
}
$name = $_FILES['imagefile']['name'];
$type = strtolower($_FILES['imagefile']['type']);
if ( strlen($name) > 0 ) {
if ( $type != "image/gif" && $type != "image/jpeg" && $type != "image/png" && $type != "image/jpg" ) {
$error = 1;
$error_message .= "<p>The file type ($type) is invalid - please use jpg, png or gif</p>";
}
}
move_uploaded_file ($_FILES['imagefile']['tmp_name'], "images/imageUploads/".$name );
if(empty($error)){
$weeks = $_REQUEST["weeks"];
$fn = $_REQUEST["fn"];
$ln = $_REQUEST["ln"];
$company = $_REQUEST["company"];
$email = $_REQUEST["email"];
$phone = $_REQUEST["phone"];
$date = $_REQUEST["date"];
$comments = $_REQUEST["comments"];
$price = $_REQUEST["price"];
$size = $_REQUEST["size"];
$paper_name = $_REQUEST["paper_name"];
$params = "weeks=".urlencode($weeks)."&";
$params .= "fn=".urlencode($fn)."&";
$params .= "ln=".urlencode($ln)."&";
$params .= "company=".urlencode($company)."&";
$params .= "email=".urlencode($email)."&";
$params .= "phone=".urlencode($phone)."&";
$params .= "date=".urlencode($date)."&";
$params .= "comments=".urlencode($comments)."&";
$params .= "price=".urlencode($price)."&";
$params .= "size=".urlencode($size)."&";
$params .= "paper_name=".urlencode($paper_name)."&";
$params .= "uploadedFile=".urlencode($name);
$params .= "&p=confirm-d";
$params .= "&id=". intval($_REQUEST['id']);
$loc = "http://{$_SERVER['HTTP_HOST']}/". dirname($_SERVER['PHP_SELF']). "/index.php?$params";
echo $loc. "<br />\n";
die(1);
header("Location: $loc");
exit;
}
else
print $error_message;
}
?>
<h2>Place Ad for SPA</h2>
<span id="GroupPrice"></span><br />
<form name="calculate-spa-d" action="index.php" name="theForm" method="post" class="niceform" enctype="multipart/form-data">
<label for="state_id">Choose state:</label><br />
<select name="state_id" id="state_id" onChange="this.form.submit()" >
<?php
$ln = htmlspecialchars( stripslashes( $_REQUEST['ln'] ), ENT_QUOTES );
$fn = htmlspecialchars( stripslashes( $_REQUEST['fn'] ), ENT_QUOTES );
$company = htmlspecialchars( stripslashes( $_REQUEST['company'] ), ENT_QUOTES );
$email = htmlspecialchars( stripslashes( $_REQUEST['email'] ), ENT_QUOTES );
$phone = htmlspecialchars( stripslashes( $_REQUEST['phone'] ), ENT_QUOTES );
$date = htmlspecialchars( stripslashes( $_REQUEST['date'] ), ENT_QUOTES );
$comments = htmlspecialchars( stripslashes( $_REQUEST['comments'] ), ENT_QUOTES );
$imagefile = htmlspecialchars( stripslashes( $_REQUEST['imagefile'] ), ENT_QUOTES );
$state = "SELECT state_id, state_name FROM spa_states WHERE state_id<>2 AND state_id<>9 AND state_id<>11 AND state_id<>23 AND state_id<>22 AND state_id<>25 AND state_id<>26 ORDER BY state_id ASC";
$result = mysql_query($state) or die(mysql_error());
while ($row1 = mysql_fetch_array($result)){
print '<option value="'.$row1["state_id"].'">'.$row1["state_name"].'</option>'."\n";
}
print '</select><br />';
?>
<label for="weeks">Weeks to run ad:</label><br />
<select name="weeks" id="weeks">
<option value="1">1 week</option>
<option value="2">2 weeks</option>
<option value="3">3 weeks</option>
<option value="4">4 weeks</option>
</select><br />
<label for="fn">First Name:</label><br />
<input type="text" name="fn" id="fn" size="20" value="<?php echo $fn; ?>" /><br />
<label for="ln">Last Name:</label><br />
<input type="text" name="ln" id="ln" size="20" value="<?php echo $ln; ?>" /><br />
<label for="company">Company Name:</label><br />
<input type="text" name="company" id="company" size="20" value="<?php echo $company; ?>" /><br />
<label for="email">E-mail:</label><br />
<input type="text" name="email" id="email" size="20" value="<?php echo $email; ?>" /><br />
<label for="phone">Phone:</label><br />
<input type="text" name="phone" id="phone" size="20" value="<?php echo $phone; ?>" /><br />
<label for="date">Starting Date:</label><br />
<input type="text" name="date" id="date" size="20" title="Click to select date" value="<?php echo $date; ?>" /><br />
<label for="comments">Comments:</label><br />
<textarea name="comments" id="comments" rows="5" cols="20"><?php echo $comments; ?></textarea><br />
<label for="comments">Display Ad:</label><br />
<input type="file" name="imagefile" /><br /><br />
<input name="p" type="hidden" value="calc-spa-d" />
<input name="id" type="hidden" value="<?php echo intval($_REQUEST['id']); ?>" />
<input type="hidden" name="state_id_submit" id="state_id_submit" value=""/>
<input type="hidden" name="price_submit" id="price_submit" value=""/>
<input type="hidden" name="size_submit" id="size_submit" value=""/>
<input type="hidden" name="paper_name_submit" id="paper_name_submit" value=""/>
<script type='javascript' >
function setvalue(){
document.getElementById('state_id_submit').value=document.getElementById('state_id_ajax').value;
document.getElementById('price_submit').value=document.getElementById('price_ajax').value;
document.getElementById('size_submit').value=document.getElementById('size_ajax').value;
document.getElementById('paper_name_submit').value=document.getElementById('paper_name_ajax').value;
}
</script>
<input type="submit" name="Submit" value="Calculate!" />
</form>
<iframe name="if1" src="about:blank" width="1" height="1"></iframe>
<script>
tId1 = setInterval('showPriceD()',200);
</script>
<script>
// declare variables
var groupText = "";
var price = "";
var size = "";
<?php
include_once ("config.php");
if($_REQUEST["state_id"]){
$state_id = htmlspecialchars(stripslashes($_REQUEST["state_id"]));
$sql = "SELECT displayPrice,displaySize,state_id FROM spa_states WHERE state_id=$state_id";
$query = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($query)){
if ($row["displayPrice"]!=""){
print "\ngroupText='<b>$".$row["displayPrice"]." for ".$row["displaySize"]." column inche(s).</b>';\n";
print "\nparent.document.getElementById('GroupPrice').innerHTML=groupText;\n";
// set price equal to php value
print "\n price = '".$row["displayPrice"]."'";
// set size equal to php value
print "\n size = '".$row["displaySize"]."'";
print "\nparent.document.getElementById('price').value = price;\n";
}else{
print "\ngroupText='No price/data for this ID.'";
}
}
}else{
print "\ngroupText='Must have a valid ID to continue.'";
}
?>
</script>
<?
print "\n<input type='hidden' id='price' value='' />";
print "\n<input type='hidden' id='size_ajax' value='".$size_ajax."' />";
print "\n<input type='hidden' id='price_ajax' value='".$price_ajax."' />";
print "\n<input type='hidden' id='paper_name_ajax' value='".$paper_name_ajax."' />\n";
?>
When your AJAX script returns the info, put it into hidden form fields as well as your display element. Â When the form is submitted, your handler will be able to see the data in $_POST just like the 'normal' fields.