Jump to content

Session not passing data!


rocky48

Recommended Posts

I have screwed up my code, was working but copied wrong file and was running incorrect file.

Basically it appears to work and runs without error, but it should print the verse I have chosen but prints 'You have selected an invalid Verse. Please try again' which is an error message in the file Prnpdf.php.

My conclusion is therefore that the session is not passing the data from the previous file, varinput.pdf, but the file that I messed up as the one called varinput.php and all the other files are the original files, so I can't see why it is not working!  Is there something wrong with the session in that file?

The sequence of the files running is as follows:

vinput.php -> vquery.php -> varinput.php -> prnpdf.php -> fpdf.php

vinput.php

<!DOCTYPE html>
<html lang="en-GB">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <meta name="generator" content="RSD 5.0.3519">
  <meta name="description" content="Created by Inger Eik, Dec. 2021">
  <title>Verse Input</title>
  <link rel="stylesheet" href="css/bootstrap4.min.css">
  <link rel="stylesheet" href="css/wireframe-theme.min.css">
  <script>document.createElement( "picture" );</script>
  <script class="picturefill" async="async" src="js/picturefill.min.js"></script>
  <link rel="stylesheet" href="css/main.css">
    <style>
    /* Interaction Elements */

a.link-button.button-link-1 {
  margin-right: 5px;
  margin-bottom: 5px;
  margin-left: 5px;
  padding-top: 4px;
  width: 120px;
  height: auto;
  border: .0625rem solid rgba(255, 255, 255, .5);
  background-color: #0f0e14;
  color: #fff;
  text-align: center;
  text-decoration: none;
  line-height: 22px;
}

select.select.dd-fc {
  margin-right: 5px;
  margin-bottom: 5px;
  margin-left: 5px;
  padding-top: 5px;
  padding-bottom: 3px;
  width: 120px;
  border-color: rgba(255, 255, 255, .5);
  background-color: #0f0e14;
  color: #fff;
  opacity: .98;
}

.container-grid.dropdown-menubar {
  position: absolute;
  top: auto;
  bottom: 0;
  display: -webkit-box;
  display: -webkit-flex;
  display:    -moz-box;
  display: -ms-flexbox;
  display:         flex;
  -ms-flex-pack: center;
  margin-right: 0;
  margin-left: 0;
  padding-top: 10px;
  padding-bottom: 5px;
  max-width: 1200px;
  width: 100%;
  background-color: #0f0e14;

  -webkit-box-pack: center;
  -webkit-justify-content: center;
     -moz-box-pack: center;
          justify-content: center;
  -webkit-flex-wrap: wrap;
      -ms-flex-wrap: wrap;
          flex-wrap: wrap;
}

@media screen and (min-width: 75rem) {
  /* Interaction Elements */

  a.link-button.button-link-1 {
    height: auto;
  }
}
option:first-child {
display:none;
  }


    </style>
</head>

<body>
  <div class="outer-limit container-grid">
    <div class="header container-grid">
      <div class="header-inner container-grid"></div>
      <div class="dropdown-menubar container-grid">
        <?php include("inc/menu.php"); ?>
      </div>
    </div>
    <h1 class="heading-5">1066 Card Craft</h1>
    <div class="content container-grid">
      <div class="aside container-grid">
        <div class="responsive-picture">
	 <picture>
            <img alt="Placeholder Picture" width="485" height="477" src="./img/writing.jpg" loading="lazy">
          </picture>

        <?php
        
        include("inc/aside-verse.php");   ?>
</div>      
</div>
      <div class="main container-grid">
        <?php
     

include ("cons/connect_Verses4Cards.php");
$conn = get_db_conn_verse();
//Function to build select options based on passed array
function buildSelectOptions($name, array $options, $current=null){
	$htmlString  = "<select name='{$name}' id='{$name}'>\n";
	
	foreach($options as $value=>$option){
		$htmlString .= "\t<option value='{$value}'";
		if($value == $current){
		$htmlString .= " selected";
		}
		$htmlString .= ">{$option}</option>\n";
		}
		$htmlString .= "</select>\n";
		return $htmlString;
		}
		
function getEvents($conn){
		$qry = "SELECT id ,Event_Type FROM Events ORDER BY id";
		$sql = mysqli_query($conn, $qry)or die(mysqli_error($conn));
		if(mysqli_num_rows($sql) < 1){
		return array();
		}
		while($res1 = mysqli_fetch_array($sql)){
		$ret1[$res1['id']] = $res1['Event_Type'];
		
		}
		
		return $ret1;
		}
		
function getMoods($conn){
		$qry = "SELECT id ,Event_Sub_Type FROM Event_Sub ORDER BY id";
		$sql = mysqli_query($conn, $qry)or die(mysqli_error($conn));
		if(mysqli_num_rows($sql) < 1){
		return array();
		}
		while($res2 = mysqli_fetch_array($sql)){
		$ret2[$res2['id']] = $res2['Event_Sub_Type'];
		}
		
		return $ret2;
		}
		
?>
 
      
<h3>Choose Your Verse Options</h3>
<br></br>
<!-- Start of FORM -->
        <form action="vquery.php" method="post">


          <?php echo buildSelectOptions('event', getEvents($conn), 1);?>



          <?php echo buildSelectOptions('mood', getMoods($conn), 1);?>

          <input type="submit" value="submit" />
        </form>
        <!-- End of FORM -->
       
  </div>
  </div>
    <div class="footer container-grid">
      

      <?php   include("inc/footer.php");   ?>
    </div>
  </div>
  <script src="js/jquery.min.js"></script>
  <script src="js/outofview.js"></script>
  <script src="js/popper.min.js"></script>
  <script src="js/bootstrap.min.js"></script>
</body>

</html>

vquery.php

<!DOCTYPE html>
<html lang="en-GB">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <meta name="generator" content="RSD 5.0.3519">
  <meta name="description" content="Created by Inger Eik, Dec. 2021">
  <title>Verse Query</title>
  <link rel="stylesheet" href="css/bootstrap4.min.css">
  <link rel="stylesheet" href="css/wireframe-theme.min.css">
  <script>document.createElement( "picture" );</script>
  <script class="picturefill" async="async" src="js/picturefill.min.js"></script>
  <link rel="stylesheet" href="css/main.css">
   <?php
include_once("cons/connect_Verses4Cards.php");
$conn=get_db_conn_verse();

$display_block ="";
//check for required info from the query string


//verify the Event exists
$verify_Event_sql = "SELECT ID, Event_Type FROM Events WHERE ID = '".$_POST["event"]."'";
$verify_Event_res =  mysqli_query($conn, $verify_Event_sql) or die(mysqli_error($conn));



if (mysqli_num_rows($verify_Event_res) < 1) {
	//this Event does not exist
	$display_block = "<p><em>You have selected an invalid Event.<br/>
	Please try again.</em></p>";

} else {
//get the Event ID
	while ($Event_info = mysqli_fetch_array($verify_Event_res)) {
		$Event_ID = stripslashes($Event_info['ID']);
		$Event_Name = ($Event_info['Event_Type']);
	}

$verify_Mood_sql = "SELECT ID, Event_Sub_Type FROM Event_Sub WHERE ID = '".$_POST["mood"]."'";
$verify_Mood_res =  mysqli_query($conn, $verify_Mood_sql) or die(mysqli_error($conn));

if (mysqli_num_rows($verify_Mood_res) < 1) {
	//this Event does not exist
	$display_block = "<p><em>You have selected an invalid Mood.<br/>
	Please try again.</em></p>";
}

	while($Mood_info = mysqli_fetch_array($verify_Mood_res)) {
		$Mood_ID = ($Mood_info['ID']);
		$Mood_Name = ($Mood_info['Event_Sub_Type']);
	}
	//gather the Events
	$get_Event_sql  = "SELECT verses.ID AS versesID, verses.Verse, verses.Sub_Type, verses.Event, Events.ID AS eventsID, Events.Event_Type, Event_Sub.ID AS event_SubID, Event_Sub.Event_Sub_Type
	FROM verses
	LEFT JOIN Events
	ON verses.Event = Events.ID
	LEFT JOIN Event_Sub
	ON verses.Sub_Type = Event_Sub.ID
	WHERE verses.Event = '".$_POST["event"]."' And verses.Sub_Type = '".$_POST["mood"]."'
	ORDER BY verses.ID ASC";


	$get_Event_res = mysqli_query($conn, $get_Event_sql) or die(mysqli_error($conn));

	//create the display string
	$display_block .= "

<table width=\"90%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"white\" >
	<tr>
	<th>ID</th>
	<th>VERSE</th>
	<th>MOOD/SUB TYPE</th>
	<th>CHOOSE</th>
	</tr>";	

	while ($Verse_info = mysqli_fetch_array($get_Event_res)) {
		$Verse_id = $Verse_info['versesID'];
		$Verse_text = nl2br(stripslashes($Verse_info['Verse']));
		$Mood_info = $Verse_info['Event_Sub_Type'];
		$VID = $Verse_id;
		//add to display
$display_block .= "
<tr>
<td width=\"1%\" valign=\"top\">".$Verse_id."<br/></td>
<td width=\"55%\" valign=\"top\">".$Verse_text."<br/></td>
<td width=\"35%\" valign=\"top\">" .$Mood_info."<br/></td>
<td width=\"35%\" valign=\"middle\">
<form METHOD=\"POST\" ACTION=\"varInput.php\">
<input type=\"Radio\" name=\"VID\" value=$VID ></td>
</tr>";
}

$display_block.="<input type=submit value=Submit>
</form>";


//free results
	mysqli_free_result($get_Event_res);
	mysqli_free_result($verify_Event_res);	
//close up the table
$display_block .="</table>";	
}
?>
 <style>
    /* Interaction Elements */

a.link-button.button-link-1 {
  margin-right: 5px;
  margin-bottom: 5px;
  margin-left: 5px;
  padding-top: 4px;
  width: 120px;
  height: auto;
  border: .0625rem solid rgba(255, 255, 255, .5);
  background-color: #0f0e14;
  color: #fff;
  text-align: center;
  text-decoration: none;
  line-height: 22px;
}

select.select.dd-fc {
  margin-right: 5px;
  margin-bottom: 5px;
  margin-left: 5px;
  padding-top: 5px;
  padding-bottom: 3px;
  width: 120px;
  border-color: rgba(255, 255, 255, .5);
  background-color: #0f0e14;
  color: #fff;
  opacity: .98;
}

.container-grid.dropdown-menubar {
  position: absolute;
  top: auto;
  bottom: 0;
  display: -webkit-box;
  display: -webkit-flex;
  display:    -moz-box;
  display: -ms-flexbox;
  display:         flex;
  -ms-flex-pack: center;
  margin-right: 0;
  margin-left: 0;
  padding-top: 10px;
  padding-bottom: 5px;
  max-width: 1200px;
  width: 100%;
  background-color: #0f0e14;

  -webkit-box-pack: center;
  -webkit-justify-content: center;
     -moz-box-pack: center;
          justify-content: center;
  -webkit-flex-wrap: wrap;
      -ms-flex-wrap: wrap;
          flex-wrap: wrap;
}

@media screen and (min-width: 75rem) {
  /* Interaction Elements */

  a.link-button.button-link-1 {
    height: auto;
  }
}
option:first-child {
display:none;
  }


    </style>
</head>

<body>
  <div class="outer-limit container-grid">
    <div class="header container-grid">
      <div class="header-inner container-grid"></div>
      <div class="dropdown-menubar container-grid">
        <?php include("inc/menu.php"); ?>
      </div>
    </div>
    <h1 class="heading-5">1066 Card Craft</h1>
    <div class="content container-grid">
      <div class="aside container-grid">
       <div class="responsive-picture">
       <picture>
            <img alt="Placeholder Picture" width="485" height="477" src="./img/writing.jpg" loading="lazy">
          </picture>
    
        <?php   include("inc/aside-verse.php");   ?>
	</div>
      </div>
      <div class="main container-grid">
        <h2 class="heading-2">Your Verse Query</h2>
        
        <main class="container-grid">
          <?php if(isset($display_block)){
            echo $display_block;}?>
        </main>
      </div>
    </div>
    <div class="footer container-grid">
      <?php   include("inc/footer.php");   ?>
    </div>
  </div>
  <script src="js/jquery.min.js"></script>
  <script src="js/outofview.js"></script>
  <script src="js/popper.min.js"></script>
  <script src="js/bootstrap.min.js"></script>
</body>

</html>

varinput.php

<!DOCTYPE html>
<html lang="en-GB">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <meta name="generator" content="RSD 5.0.3528">
  <meta name="description" content="Created by Inger Eik, Dec. 2021">
  <title>Input Page</title>
  <link rel="stylesheet" href="css/bootstrap4.min.css">
  <link rel="stylesheet" href="css/wireframe-theme.min.css">
  <script>document.createElement( "picture" );</script>
  <script class="picturefill" async="async" src="js/picturefill.min.js"></script>
  <link rel="stylesheet" href="css/main.css">
    <style>
    /* Interaction Elements */

a.link-button.button-link-1 {
  margin-right: 5px;
  margin-bottom: 5px;
  margin-left: 5px;
  padding-top: 4px;
  width: 120px;
  height: auto;
  border: .0625rem solid rgba(255, 255, 255, .5);
  background-color: #0f0e14;
  color: #fff;
  text-align: center;
  text-decoration: none;
  line-height: 22px;
}

select.select.dd-fc {
  margin-right: 5px;
  margin-bottom: 5px;
  margin-left: 5px;
  padding-top: 5px;
  padding-bottom: 3px;
  width: 120px;
  border-color: rgba(255, 255, 255, .5);
  background-color: #0f0e14;
  color: #fff;
  opacity: .98;
}

.container-grid.dropdown-menubar {
  position: absolute;
  top: auto;
  bottom: 0;
  display: -webkit-box;
  display: -webkit-flex;
  display:    -moz-box;
  display: -ms-flexbox;
  display:         flex;
  -ms-flex-pack: center;
  margin-right: 0;
  margin-left: 0;
  padding-top: 10px;
  padding-bottom: 5px;
  max-width: 1200px;
  width: 100%;
  background-color: #0f0e14;

  -webkit-box-pack: center;
  -webkit-justify-content: center;
     -moz-box-pack: center;
          justify-content: center;
  -webkit-flex-wrap: wrap;
      -ms-flex-wrap: wrap;
          flex-wrap: wrap;
}

@media screen and (min-width: 75rem) {
  /* Interaction Elements */

  a.link-button.button-link-1 {
    height: auto;
  }
}
option:first-child {
display:none;
  }


    </style>
</head>

<body>
  <div class="outer-limit container-grid">
    <div class="header container-grid">
      <div class="header-inner container-grid"></div>
      <div class="dropdown-menubar container-grid">
        <?php include("inc/menu.php"); ?>
      </div>
    </div>
    <h1 class="heading-5">1066 Cards 4 U</h1>
    <div class="content container-grid">
      <div class="aside container-grid">
        <?php   include("inc/aside.php");   ?>
      </div>
      <div class="main container-grid">
        <!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="generator" content="RSD 5.0.3519">
  <title>VInput1</title>
  <link rel="stylesheet" href="css/bootstrap4.min.css">
  <link rel="stylesheet" href="css/wireframe-theme.min.css">
  <script>document.createElement( "picture" );</script>
  <script class="picturefill" async="async" src="js/picturefill.min.js"></script>
  <link rel="stylesheet" href="css/main.css">
</head>

<body>
  <div class="container-grid container-2"></div>
  
  <div class="container-grid main">
  <?php
  session_start();
    $_SESSION['test']=$_POST['VID'];


include("cons/connect_Verses4Cards.php");
$conn=get_db_conn_verse();

$display_block ="";
$CardSz ="";
$Card_info['Size']="";
$Card_info['Narative']="";

//Function to build select options based on passed array
$CardSz = array($Card_info['Size'], $Card_info['Narative']); 
buildSelectOptions($CardSz);
function buildSelectOptions($options)
{
$optionsHTML = "<select name=\"CSize\">\r\n";

foreach($options as $id => $label)
{
$optionsHTML .= "<option value='{$id}'>{$label}</option>\n";
}

return $optionsHTML;
}   
 
//Run query to get the ID and Name from the table
//Then populate into an array
$clist_sql = "SELECT * FROM CSize ORDER BY GP";
$clist_res= mysqli_query($conn, $clist_sql) or die(mysqli_error($conn));
if (mysqli_num_rows($clist_res) < 1) {
	//this Card does not exist
	$display_block = "<p><em>You have selected an invalid Country.<br/>
	Please try again.</em></p>";
}
$CardSz = array();
while($Card_info = mysqli_fetch_array($clist_res)) {
       
        $CardSz[$Card_info['Size']] = $Card_info['Narative'];
}
$CardOptions = buildSelectOptions($CardSz);


?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="On this page the user choose the variables to align the verse on the paper" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>1066 Cards 4U - Variable Input Form</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="menu">
		<ul>




<div id="content">
<h1>Card Variable Input Form</h1>


<form name="Lists" action="Prnpdf.php" method="post">
   	
        <p><strong>Card Size</strong></p>
		<select name="CSize">
    <option value= "<?php echo $CardOptions;?>"  </option>
	</select>
<br/>
	
		<p><strong>Input Distance from top in mm:</strong> <input type="number" name="Top" value="50" min="20" max="200"/></p><br/>
		<p><strong>Input Font size in points:</strong> <select name="font">
		<option value="18" > 18 point</option>
		<option value="20" > 20 point</option>
		<option value="22" > 22 point</option>
		<option value="24" selected="selected" > 24 point</option>
		<option value="26" > 26 point</option>
		<option value="28" > 28 point</option>
		<option value="30"  > 30 point</option>
		<option value="32" > 32 point</option>
		</select></p><br/>
		
		<p><strong>Text Colour</strong></p>
		<select name="color">
		<option value="000000000" > Black</option>
		<option value="255215000" > Gold</option>
		<option value="192192192" > Silver</option>
		<option value="255000000" > Red</option>
		<option value="000255000" > Green</option>
		<option value="000000255" > Blue</option>
		<option value="255195203" > Pink</option>
		<option value="132112255" > Slate Blue</option>
		<option value="128000128" > Purple</option>
		<option value="168099030" > Brown</option>
		</select><br/>
		
		<p><strong>Text Font</strong></p>
		<select name="fontface">
		<option value="French Script MT" > French Script MT</option>
		<option value="Batavia" > Batavia </option>
		<option value="Algerian" > Algerian </option>
		<option value="Bladerunner" > Bladerunner </option>
		<option value="Brush Script" > Brush Script</option>
		<option value="Helterskelter" > Helterskelter</option>	
		<option value="Justice" > Justice</option>
		<option value="Magneto" > Magneto</option>
		<option value="Old English" > Old English</option>
		<option value="Sneakerhead Outline" > Sneakerhead Outline</option>
		<option value="Trendy" > Trendy</option>
		<option value="Vladimir Script" > Vladimir Script</option>
		</select><br/>
		
	
		
		<p><strong>Border Images </strong></p>
		<select name="image">
		<option value="images/empty.jpg" selected="selected"> No Border</option>
		<option value="images/Border10p.jpg" > Rose Border - Portrait</option>
		<option value="images/Border2p.jpg" > Chequered Border - Portrait</option>
		<option value="images/Border11p.jpg" > Ribbon Border - Portrait</option>
		<option value="images/Border5p.jpg" > Yellow Border - Portrait</option>
		<option value="images/Corner2p.jpg" > Leaf Corners - Portrait</option>
		<option value="images/corner1p.jpg" > Laurel Corners - Portrait</option>
		<option value="images/Border12P.jpg" > Holly Corner - Portrait</option>
		<option value="images/116070.jpg" > Ornate -Portrait</option>
		<option value="images/116122.jpg" > Ornate2 -Portrait</option>
		<option value="images/Border10l.jpg" > Rose Border -Landscape </option>
		<option value="images/Border2l.jpg" > Chequered Border -Landscape</option>
		<option value="images/Border11l.jpg" > Ribbon Border -Landscape</option>
		<option value="images/Border5l.jpg" > Yellow Border -Landscape</option>
		<option value="images/Corner2l.jpg" > Leaf Corners -Landscape</option>
		<option value="images/corner1l.jpg" > Holly Corner -Landscape</option>
		<option value="images/Border12L.jpg" > Yellow Border -Landscape</option>
		<option value="images/Holly1.jpg" > Holly-Landscape</option>
		<option value="images/Xmastree2.jpg" > Xmas Tree - Landscape</option>
		<option value="images/Decoborder1.png" > Art Deco Border - Portrait</option>
		</select><br /><br />
		

				
		<input type="submit" value="Submit"/>
		</form>

	</div><!-- end #content -->


</body>

</html>
</div>
<div class="container-grid footer">
  <?php include("inc/footer.php"); ?>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/outofview.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</div>
</body>
</html>

prnpdf.php

<?php
session_start();
include("cons/connect_Verses4Cards.php");
$conn=get_db_conn_verse();

$display_block ="";

$color="";
$r ="";
$g ="";
$b ="";
$image ="";
//echo $r,$g,$b;
//Get the Card Variables
$Get_Size_sql = "SELECT * FROM `CSize` WHERE `Size` ='".$_POST["CSize"]."'";
$Get_Size_res =  mysqli_query($conn, $Get_Size_sql) or die(mysqli_error($conn));

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 print variables
	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
//$the_id = mysqli_real_escape_string($mysqli, $_SESSION[VID]);
$Get_Verse_sql = "SELECT id, Event, Sub_Type, Verse FROM verses WHERE id='".$_SESSION['Test']."'";  
$Get_Verse_res =  mysqli_query($conn, $Get_Verse_sql) or die(mysqli_error($conn));


if (mysqli_num_rows($Get_Verse_res) < 1) {
	//this Event does not exist
	$display_block = "You have selected an invalid Verse.
	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($conn);


require('fpdf.php');

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

function __construct($orientation='P', $unit='mm', $size='A4')
{
    // Call parent constructor
   parent::__construct($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);
}

}
$color = $_POST['color'];
           
//$r = substr($color,0,3);
//$b = substr($color,3,3);
//$g = substr($color,4,6);
  //**** This is what I added to make it work and commented out the original above.                  
   $r = hexdec(substr($color,0,2));
   $g = hexdec(substr($color,2,2));
   $b = hexdec(substr($color,4,2));



 //echo $r.'r<br>';
 //echo $g.'g<br>';
 //echo $b.'b<br>';
 //exit();

$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->SetLeftMargin('float0');
$pdf->SetTextColor($r,$g,$b);
$pdf->SetFont($_POST['fontface'],'',$_POST['font']);
$pdf->SetXY($BoxX, $_POST['Top']);
$pdf->Image($image,$floatx,$floaty,$floatw,$floath,'','');
$pdf->MultiCell($Cellw,$Cellh,$display_block,'' ,'C');
//$pdf->SetDisplayMode('fullpage','');
$pdf->SetFont('');
$pdf->Output('verse.pdf','D');
//end:
?>

 

Link to comment
Share on other sites

php variables are case sensitive. $_SESSION['test'] is not the same as $_SESSION['Test']. you would have been getting a php error to alert you to the problem. do you have php's error_reporting set to E_ALL and display_errors set to ON, preferably in the php.ini on your development system, so that php will help you by reporting and displaying all the errors it detects? you will save a ton of time.

most of the form markup is broken, and it's doubtful that you even have some of the shown input data. you need to trim, then validate all inputs before using them. if a 'required' input is not valid, that's an error and you should setup and display a user message rather then blindly attempting to use non-existent data. you should validate the resulting web pages at validator.w3.org to help find the mistakes in the markup.

the user errors you do have are also not preventing the code needing the inputs from running, likely producing php errors and no result. $display_block is being overwritten by later code, so any user errors you may have setup are being lost. you need to store user/validation errors in an array, using the field name as the array index, then only use the input data if the array holding the errors is empty.

  • Like 1
Link to comment
Share on other sites

DanRz - I had forgotten about that thanks!

I have now added Error reporting and corrected the capitalisation issue with the session name.

It now reports a warning on the line where I corrected the session name: 

Warning: Undefined array key "test" in /homepages/39/d922140697/htdocs/1066cardcraft/Prnpdf.php on line 42
The fatal error is on this line:
Fatal error: Uncaught Exception: FPDF error: Some data has already been output, can't send PDF file (output started at /homepages/39/d922140697/htdocs/1066cardcraft/Prnpdf.php:42) in /homepages/39/d922140697/htdocs/1066cardcraft/fpdf.php:271 Stack trace: #0 /homepages/39/d922140697/htdocs/1066cardcraft/fpdf.php(1049): FPDF->Error('Some data has a...') #1 /homepages/39/d922140697/htdocs/1066cardcraft/fpdf.php(1012): FPDF->_checkoutput() #2 /homepages/39/d922140697/htdocs/1066cardcraft/Prnpdf.php(145): FPDF->Output('D', 'verse.pdf') #3 {main} thrown in /homepages/39/d922140697/htdocs/1066cardcraft/fpdf.php on line 271

What is being output?

What baffles me is that these files were working before I miss copied the wrong Vinput file ( I had one file vinput.php and the other vinput1.php and over wrote the second file with the same code as the first file. So the only one that has been changed is the file varinput.php ( I renamed it to stop the confusion).

I can't even think about some of the suggestions Mac_gyver made until I resolve why this is not working. All of the choices are in option lists so I can't see that over complicating the code with input checks would achieve anything!

Link to comment
Share on other sites

Fix What?  I know that it is not passing the data via the session, but I can't see why?
This code has worked for me since 2012 and it only seems to have gone wrong since I messed up a file.

I can't see why that any data has already been output. Nothing should be output until you submit on the varinput.php page.

Please can anyone spot why this is happening, because I am stumped!

Link to comment
Share on other sites

Fix What you ask.  Correct that error message as it tells you.  You are referencing an element named 'test' in an array somewhere.  It says line 271 so find that line and make a change and that will stop that message.  Then see how far your code makes it before it shows us any other error.  

It's called debugging.  Try this out too.  Find the spot in your code where you think that some SESSION values should be getting used.  Add an echo statement or two to display  the values you think are being missed and see what comes out.  At least you will know that the code is being hit.

Edited by ginerjm
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.