Jump to content

Problem with Forms!


rocky48

Recommended Posts

I have scripted an input form which outputs using POST method and all of the posts work bar one!

I am using FPDF and want to change the font colour, so I have devised a method where I have created a string for the RGB values, like so: 255000000 = Red and so on.  This method worked previously, but I am trying to streamline the scripts to make it easier to maintain.  In the latest version of the script it does not work since I added the Select input method.  I added a SELECT list in front of the previous script to enable the user to select a card size.

I am puzzled why only this part does not work and the rest does?

Here is the script for the form:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- Generated by Avanquest Technology v:8.0. For information please visit: http://www.avanquestusa.com/ -->
<html lang="en">
<head>
<title> Verses - A5 Portrait </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css;">
<link rel="stylesheet" href="1066mk2_g.css" type="text/css" media="screen,projection,print">	<!--// Document Style //-->
<link rel="stylesheet" href="Vinput_p.css" type="text/css" media="screen,projection,print">	<!--// Page Style //-->
<script src="cverses_g.js" type="text/javascript"></script>	<!--// Document Script //-->
</head>

<body BGCOLOR="#00ff66">

<span id="e11"></span>
<span id="e12"></span>
<span id="e13"></span>
<span id="e14"></span>
<span id="e15"></span>
<span id="e16"></span>
<div id="e3" class="navigation">
	<a id="a3" class="navigation" href="index.html" target="Vframe5>index">
	Home</a>
</div>
<div id="e4" class="navigation">
	<a id="a4" class="navigation" href="1066mk2_002.htm" target="Vframe5>1066mk2_002">
	Links</a>
</div>
<div id="e5" class="navigation">
	<a id="a5" class="navigation" href="1066mk2_003.htm" target="Vframe5>1066mk2_003">
	Techniques</a>
</div>
<div id="e6" class="navigation">
	<a id="a16" class="navigation" href="topiclist_frame.html" target="Vframe5>topiclist_frame">
	Forum</a>
</div>
<div id="e7" class="navigation">
	<a id="a7" class="navigation" href="1066mk2_004.htm" target="Vframe5>1066mk2_004">
	Contact Us</a>
</div>
<div id="e8" class="navigation">
	<a id="a8" class="navigation" href="1066mk2_006.htm" target="Vframe5>1066mk2_006">
	Gallery</a>
</div>

<div id="e31" class="cc03">

	 <form NAME=Lists action="Prnpdf.php" method="post">
   	<Table>
            <tr>
                <th>Card Size</th>
            </tr>
            
                <td>
                    <select name="CSize">
  <option value="A5P"> A5 Portrait</option>
  <option value="A5L"> A5 Landscape</option>
  <option value="A5PS"> A5 Portrait (single)</option>
  <option value="A6P"> A6 Portrait</option>
  <option value="A6L"> A6 Landscape</option>
  <option value="A6PS"> A6 Portrait (Single)</option>
  <option value="7x5P"> 7" x 5" Portrait</option>
  <option value="7x5L"> 7" x 5" Landscape</option>
  <option value="6x4P"> 6" x 4" Portrait</option>
  <option value="6x4L"> 6" x 4" Landscape</option>
  <option value="DLP"> DL Portrait</option>
  <option value="DLL"> DL Landscape</option>
  <option value="120SQP"> 120mm Square Portrait</option>
  <option value="120SQL"> 120mm Square Landscape</option>
  <option value="125SQP"> 125mm Square Portrait</option>
  <option value="125SQL"> 125mm Square Landscape</option>
  <option value="130SQP"> 130mm Square Portrait</option>
  <option value="130SQL"> 130mm Square Landscape</option>
  <option value="135SQP"> 135mm Square Portrait</option>
  <option value="135SQL"> 135mm Square Landscape</option>
  <option value="145SQP"> 145mm Square Portrait</option>
  <option value="145SQL"> 145mm Square Landscape</option>
  <option value="150SQP"> 150mm Square Portrait</option>
  <option value="150SQL"> 150mm Square Landscape</option>
  <option value="160SQS"> 160mm Square (Single)</option>
  <option value="190SQS"> 190mm Square (Single)</option>
  <option value="200SQS"> 200mm Square (Single)</option>
  <option value="210SQS"> 210mm Square (Single)</option>  
                    </select>
	<p><strong>Input Verse ID:</strong><br/> <input type="text" size="10" name="ID"/></p>
	<p><strong>Input Distance from top in mm:</strong><br/> <input type="text" size="10" name="Top"/></p>
	<p><strong>Input Font size in points:</strong><br/> <input type="text" size="10" name="font"/></p>
	<p><strong>Check only ONE Tick Box in each section!</strong></p>
	<p><strong>Text Colour</strong></p>
	<input type="checkbox" name="txtcolor" value="000000000" /> Black<br />
	<input type="checkbox" name="txtcolor" value="255215000" /> Gold<br />
	<input type="checkbox" name="txtcolor" value="192192192" /> Silver<br />
	<input type="checkbox" name="txtcolor" value="255000000" /> Red<br />
	<input type="checkbox" name="txtcolor" value="000255000" /> Green<br />
	<input type="checkbox" name="txtcolor" value="000000255" /> Blue<br /><br />

	<p><strong>Text Font</strong></p>
	<input type="checkbox" name="fontface" value="French Script MT" /> French Script MT<br />
	<input type="checkbox" name="fontface" value="Batavia" /> Batavia <br />
	<input type="checkbox" name="fontface" value="Algerian" /> Algerian <br />
	<input type="checkbox" name="fontface" value="Bladerunner" /> Bladerunner <br />
	<input type="checkbox" name="fontface" value="Brush Script" /> Brush Script<br />
	<input type="checkbox" name="fontface" value="Helterskelter" /> Helterskelter<br />	
	<input type="checkbox" name="fontface" value="Justice" /> Justice<br />
	<input type="checkbox" name="fontface" value="Magneto" /> Magneto<br />
	<input type="checkbox" name="fontface" value="Old English" /> Old English<br />
	<input type="checkbox" name="fontface" value="Sneakerhead Outline" /> Sneakerhead Outline<br />
	<input type="checkbox" name="fontface" value="Trendy" /> Trendy<br />
	<input type="checkbox" name="fontface" value="Vladimir Script" /> Vladimir Script<br />


</div>	
<div id="e32" class="cc03">	
	<p><strong>Border Images (PORTRAIT)</strong></p>
	<input type="checkbox" name="image" value="empty.jpg" /> No Border<br />
	<input type="checkbox" name="image" value="Border10p.jpg" /> Rose Border<br />
	<input type="checkbox" name="image" value="Border2p.jpg" /> Chequered Border<br />
	<input type="checkbox" name="image" value="Border11p.jpg" /> Ribbon Border<br />
	<input type="checkbox" name="image" value="Border5p.jpg" /> Yellow Border<br />
	<input type="checkbox" name="image" value="Corner2p.jpg" /> Leaf Corners<br />
	<input type="checkbox" name="image" value="corner1p.jpg" /> Laurel Corners<br /><br />
	<p><strong>Border Images (LANDSCAPE)</strong></p>
	<input type="checkbox" name="image" value="empty.jpg" /> No Border<br />
	<input type="checkbox" name="image" value="Border10l.jpg" /> Rose Border<br />
	<input type="checkbox" name="image" value="Border2l.jpg" /> Chequered Border<br />
	<input type="checkbox" name="image" value="Border11l.jpg" /> Ribbon Border<br />
	<input type="checkbox" name="image" value="Border5l.jpg" /> Yellow Border<br />
	<input type="checkbox" name="image" value="Corner2l.jpg" /> Leaf Corners<br />
	<input type="checkbox" name="image" value="corner1l.jpg" /> Laurel Corners<br /><br />

	<input type="submit" value="Submit"/>
	</form>
</div>
</body>
</html>

Here is the output script:

<?php
include("loc_cverse_connect.php");
doDB();


//Get the Card Variables
$Get_Size_sql = "SELECT * FROM csize WHERE Size ='".$_POST["CSize"]."'";
$Get_Size_res =  mysqli_query($mysqli, $Get_Size_sql) or die(mysqli_error($mysqli));

//$sql = "SELECT * FROM `csize` WHERE Size=\"A5P\"";

if (mysqli_num_rows($Get_Size_res) < 1) {
//this Card does not exist
$display_block = "You have selected an invalid Card size.
Please try again.";
} else {
//get the Event ID
while ($Size_info = mysqli_fetch_array($Get_Size_res)) {
	$BoxX = stripslashes($Size_info['BoxX']);
	$Cellw = stripslashes($Size_info['Cellw']);
	$Cellh = stripslashes($Size_info['Cellh']);
	$SizeI = stripslashes($Size_info['Size']);
	$SID = stripslashes($Size_info['SID']);
	$floatx = stripslashes($Size_info['floatx']);
	$floaty = stripslashes($Size_info['floaty']);
	$floatw = stripslashes($Size_info['floatw']);
	$floath = stripslashes($Size_info['floath']);
	$ort = stripslashes($Size_info['ort']);
}
	//create the display string
	$display_block = "$ort";
}
//verify the Event exists
$Get_Verse_sql = "SELECT ID, Event, Sub_Type, Verse FROM Verses WHERE ID = '".$_POST["ID"]."'";
$Get_Verse_res =  mysqli_query($mysqli, $Get_Verse_sql) or die(mysqli_error($mysqli));



if (mysqli_num_rows($Get_Verse_res) < 1) {
//this Event does not exist
$display_block = "You have selected an invalid Event.
Please try again.";
} else {
//get the Event ID
while ($Verse_info = mysqli_fetch_array($Get_Verse_res)) {
	$Verse = stripslashes($Verse_info['Verse']);
}
	//create the display string
$display_block = "$Verse";

//free results
mysqli_free_result($Get_Verse_res);
mysqli_free_result($Get_Size_res);
//close connection to MySQL
mysqli_close($mysqli);
}

require('fpdf.php');

class PDF extends FPDF
{
var $B;
var $I;
var $U;
var $HREF;

function PDF($orientation='P', $unit='mm', $size='A4')
{
    // Call parent constructor
    $this->FPDF($orientation,$unit,$size);
    // Initialization
    $this->B = 0;
    $this->I = 0;
    $this->U = 0;
    $this->HREF = '';
}



function SetStyle($tag, $enable)
{
    // Modify style and select corresponding font
    $this->$tag += ($enable ? 1 : -1);
    $style = '';
    foreach(array('B', 'I', 'U') as $s)
    {
        if($this->$s>0)
            $style .= $s;
    }
    $this->SetFont('',$style);
}

}

$txtcolor = $POST[txtcolor];
$r = substr($txtcolor,0,3);
$g = substr($txtcolor,4,3);
$b = substr($txtcolor,7,3);
$image=$_POST[image];

$pdf = new PDF($ort,'mm','A4');
$pdf->AddPage();
$pdf->AddFont('French Script MT','','frscript.php');
$pdf->AddFont('Batavia','','Batavia_.php');
$pdf->AddFont('Algerian','','Alger.php');
$pdf->AddFont('Bladerunner','','BLADRMF_.php');
$pdf->AddFont('Brush Script','','BRUSHSCI.php');
$pdf->AddFont('Helterskelter','','Helte___.php');
$pdf->AddFont('Justice','','Justice_.php');
$pdf->AddFont('Magneto','','MAGNETOB.php');
$pdf->AddFont('Old English','','OldEngl.php');
$pdf->AddFont('Sneakerhead Outline','','Sneabo__.php');
$pdf->AddFont('Trendy','','Trendy__.php');
$pdf->AddFont('Vladimir Script','','VLADIMIR.php');
$pdf->SetTextColor($r,$g,$b);
$pdf->SetFont($_POST[fontface],'',$_POST[font]);
$pdf->SetXY($BoxX, $_POST[Top]);
$pdf->Image($image,$floatx,$floaty,$floatw,$floath,jpg,'');
$pdf->MultiCell($Cellw,$Cellh,$display_block,'' ,'C');
$pdf->SetFont('');
$pdf->Output('verse.pdf','D');
?>

Can anyone see where I have gone wrong?

 

Link to comment
https://forums.phpfreaks.com/topic/265843-problem-with-forms/
Share on other sites

//check the variable is being passed through
if (isset($_POST['CSize'])){
echo 'CSize is '.$_POST['CSize'];
}

// also your query should be quoted correctly
$Get_Size_sql = "SELECT * FROM `csize` WHERE `Size` ='".$_POST["CSize"]."'";

// try echoing out the whole query string aswell
echo $Get_Size_sql ;

 

and switch your error handling on

Link to comment
https://forums.phpfreaks.com/topic/265843-problem-with-forms/#findComment-1362387
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.