...

View Full Version : POST Problem



rockyhudson
07-26-2012, 12:35 PM
I am having problem with POST which I am trying to pass a variable from a script which is 2 scripts away from the script that needs this variable.
Here is the order that the scripts run:
showtype.php
VInput.html
Prnpdf.php

The Showtype.php script queries my database to filter verses of a particular type (e.g. Birthday). A choice is made and the user clicks the Submit button.
The VInput.html is now run which clears up the rest of the variables needed for the output script - Prnpdf.php is then run when the user clicks the Submit button and a PDF file is produced, which can be printed.

Here are the scripts:
showtype.php

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

//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_Type"]."'";
$verify_Event_res = mysqli_query($mysqli, $verify_Event_sql) or die(mysqli_error($mysqli));

//echo $_POST["Event_Type"];

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']);
}


//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_Type"]."'
ORDER BY Verses.ID ASC";


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

//create the display string
$display_block = "
<p> The Event Type is <b>
'".$Event_Name."'</b> </p>

<table width=\"70%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" >
<tr>
<th>ID</th>
<th>VERSE</th>
<th>MOOD/SUB TYPE</th>
<th>Link</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'];

//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=\"9%\" valign=\"top\">
<form action=\"VInput2.html\" ".method."=\"post\">
<input type=\"Radio\" name=\"ID\" value=\"".$Verse_id."\"/>


</td>
</tr>";
}

//free results
mysqli_free_result($get_Event_res);
mysqli_free_result($verify_Event_res);

//close connection to MySQL
mysqli_close($mysqli);

//close up the table
$display_block .= "
<input type=\"submit\" value=\"SUBMIT\">
</form>
</table>";


}

?>
<html>
<head>

<title> List of Verses</title>
</head>
<body BGCOLOR="#87CEEB">
<h1>Verses</h1>

<?php echo $display_block; ?>

</body>
</html>


VInput.html

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

//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_Type"]."'";
$verify_Event_res = mysqli_query($mysqli, $verify_Event_sql) or die(mysqli_error($mysqli));

//echo $_POST["Event_Type"];

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']);
}


//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_Type"]."'
ORDER BY Verses.ID ASC";


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

//create the display string
$display_block = "
<p> The Event Type is <b>
'".$Event_Name."'</b> </p>

<table width=\"70%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" >
<tr>
<th>ID</th>
<th>VERSE</th>
<th>MOOD/SUB TYPE</th>
<th>Link</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'];

//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=\"9%\" valign=\"top\">
<form action=\"VInput2.html\" ".method."=\"post\">
<input type=\"Radio\" name=\"ID\" value=\"".$Verse_id."\"/>


</td>
</tr>";
}

//free results
mysqli_free_result($get_Event_res);
mysqli_free_result($verify_Event_res);

//close connection to MySQL
mysqli_close($mysqli);

//close up the table
$display_block .= "
<input type=\"submit\" value=\"SUBMIT\">
</form>
</table>";


}

?>
<html>
<head>

<title> List of Verses</title>
</head>
<body BGCOLOR="#87CEEB">
<h1>Verses</h1>

<?php echo $display_block; ?>

</body>
</html>


Prnpdf.php

<?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 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";
}

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


//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);
}

}

$color = $_POST[color];
$r = substr($color,0,3);
$g = substr($color,3,3);
$b = substr($color,6,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');

?>
Please can anyone help to solve this issue?

Rowsdower!
07-26-2012, 01:25 PM
You've posted this question in the HTML section of the forum so the number of responses you will receive is likely to be less than average given the nature of your problem. You should ask a moderator to move your thread to the PHP section (do not cross-post) for best results.

That said, you should look into PHP's $_SESSION variable (http://php.net/manual/en/reserved.variables.session.php). You can store data there and call it up later, as long as the user is still in their current session with your website. Just remember to use session_start() (http://php.net/manual/en/function.session-start.php) at the top of each page that will make use of the $_SESSION values.

rockyhudson
07-28-2012, 05:53 PM
I have opened a session on showtype.php and added:
$_SESSION[ID]=".$_POST.";
Is this the correct way to do this?
Also not sure where to put it.
I tried putting it after the submit, but it did not work and displayed : = 289 along side of the button. This was the last item in the query.
I guessed it had to be outside the loop, so put it after the </form> tag and after the closing brace.
Still does not pass the variable!
This is how I did it:

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

//create the display string
$display_block = "
<p> The Event Type is <b>
'".$Event_Name."'</b> </p>

<table width=\"70%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" >
<tr>
<th>ID</th>
<th>VERSE</th>
<th>MOOD/SUB TYPE</th>
<th>Link</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'];

//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=\"9%\" valign=\"top\">
<form action=\"VInput2.html\" ".method."=\"post\">
<input type=\"Radio\" name=\"ID\" value=\"".$Verse_id."\"/>


</td>
</tr>";
}

//free results
mysqli_free_result($get_Event_res);
mysqli_free_result($verify_Event_res);

//close connection to MySQL
mysqli_close($mysqli);

//close up the table
$display_block .= "
<input type=\"submit\" value=\"SUBMIT\">

</form>
</table>";


}
$_SESSION[ID]=".$_POST.";
?>
<html>
<head>

<title> List of Verses</title>
</head>
<body BGCOLOR="#87CEEB">
<h1>Verses</h1>

<?php echo $display_block; ?>

</body>
</html>

Here is the way I used $_SESSION:

$Get_Verse_sql = "SELECT ID, Event, Sub_Type, Verse FROM Verses WHERE ID = '".$_SESSION["ID"]."'";
$Get_Verse_res = mysqli_query($mysqli, $Get_Verse_sql) or die(mysqli_error($mysqli));


Where am I going wrong?

HDRebel88
07-28-2012, 09:41 PM
If you use a non-numeric key for your session name you have to put quotes around it just like using $_POST or $_GET, and you need to identify what element in POST variable you want to assign to the session.

So try this:

session_start();
$_SESSION['ID']=$_POST['ID'];


or change the POST element name to what every you need it to be.

rockyhudson
07-29-2012, 10:00 AM
Thanks for that, but it still does not work.
Is my syntax correct in the final script or is the $_SESSION in the wrong place?

AndrewGSW
07-29-2012, 02:57 PM
If your ID is numerical then it needs to be cast from a string, but you also need to check first if the post data exists:


if (isset($_POST['ID'] && is_numeric($_POST['ID'])) {
$_SESSION['ID'] = (int) $_POST['ID'];
}

in which case you wouldn't surround ID with apostrophes in the sql statement.

Don't forget that session_start() must be the very first statement in your code - before any output/echos.

I wouldn't use name="ID" - I would prefer "VID" or "verseID".

In principle, it is possible to post data to an .HTML file, but I find this unreliable. I would rename the file to "VInput2.php".

And BGCOLOR has been deprecated for a long time :eek:

rockyhudson
07-29-2012, 11:15 PM
I have pasted your code into final php script, which outputs verse as PDF file.
There was a mistake in the code, missing ) after first $_POST[ID].
I added it just before the $Get_Verse_sql line.
It still does not apparently pass a value to the query, as I get the 'You have selected an invalid Event. Please try again.' text in the output file.
Have I put the code in the right place?

This is the last hurdle in the redevelopment of my coding for my website, so I am desparate to get this fixed ASAP.

Please help!

AndrewGSW
07-30-2012, 12:42 AM
Sorry about the missing ).


$Get_Verse_sql = "SELECT ID, Event, Sub_Type, Verse FROM Verses WHERE ID = '".$_SESSION["ID"]."'";

You still haven't said if ID is a number, which my code assumes it is(?). If so, you should remove the apostrophes from your sql statement. But you should also escape the session value before using it in the sql:


$the_id = mysqli_real_escape_string($mysqli, $_SESSION['ID']);
$Get_Verse_sql = "SELECT ID, Event, Sub_Type, Verse FROM Verses WHERE ID=$the_id";

rockyhudson
07-30-2012, 04:54 PM
Hi
ID is a number!

Pasted in the code but igives this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Does not appear to have any mistakes!
I am using version 5.0.8dev MYSQL.

AndrewGSW
07-30-2012, 07:16 PM
I doubt it's the SQL itself that is the problem. Can you re-post the relevant code as it is now.

rockyhudson
07-30-2012, 07:56 PM
Showtype.php

<?php
include("Loc_cverse_connect.php");
doDB();
session_start();

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

//echo $_POST["Event_Type"];

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 = ($Event_info['ID']);
$Event_Name = ($Event_info['Event_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_Type"]."'
ORDER BY Verses.ID ASC";


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

//create the display string
$display_block = "
<p> The Event Type is <b>
'".$Event_Name."'</b> </p>

<table width=\"70%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" >
<tr>
<th>ID</th>
<th>VERSE</th>
<th>MOOD/SUB TYPE</th>
<th>Link</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'];

//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=\"9%\" valign=\"top\">
<form action=\"VInput2.php\" method=\"post\">
<input type=\"Radio\" name=\"VID\" value=\"".$Verse_id."\"/>


</td>
</tr>";
}

//free results
mysqli_free_result($get_Event_res);
mysqli_free_result($verify_Event_res);

//close connection to MySQL
mysqli_close($mysqli);

//close up the table
$display_block .= "
<input type=\"submit\" value=\"SUBMIT\">

</form>
</table>";

$_SESSION['VID']=$_Event_info['ID'];
}

?>
<html>
<head>

<title> List of Verses</title>
</head>
<body BGCOLOR="#87CEEB">
<h1>Verses</h1>

<?php echo $display_block; ?>

</body>
</html>


VInput2.php (changed it as suggested)

<?php
include("Loc_cverse_connect.php");
doDB();
session_start();

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

//echo $_POST["Event_Type"];

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 = ($Event_info['ID']);
$Event_Name = ($Event_info['Event_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_Type"]."'
ORDER BY Verses.ID ASC";


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

//create the display string
$display_block = "
<p> The Event Type is <b>
'".$Event_Name."'</b> </p>

<table width=\"70%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" >
<tr>
<th>ID</th>
<th>VERSE</th>
<th>MOOD/SUB TYPE</th>
<th>Link</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'];

//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=\"9%\" valign=\"top\">
<form action=\"VInput2.php\" method=\"post\">
<input type=\"Radio\" name=\"VID\" value=\"".$Verse_id."\"/>


</td>
</tr>";
}

//free results
mysqli_free_result($get_Event_res);
mysqli_free_result($verify_Event_res);

//close connection to MySQL
mysqli_close($mysqli);

//close up the table
$display_block .= "
<input type=\"submit\" value=\"SUBMIT\">

</form>
</table>";

$_SESSION['VID']=$_Event_info['ID'];
}

?>
<html>
<head>

<title> List of Verses</title>
</head>
<body BGCOLOR="#87CEEB">
<h1>Verses</h1>

<?php echo $display_block; ?>

</body>
</html>


Prnpdf.php

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

//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));

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='".$the_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);
}

}

$color = $_POST[color];
$r = substr($color,0,3);
$g = substr($color,3,3);
$b = substr($color,6,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');
//end:
?>
That's all of the scripts!
Thanks for your help!

Did test the output by using this script:

<?php
if (isset($_POST['VID']) && is_numeric($_POST['VID'])) {
$_SESSION['VID'] = (int) $_POST['VID'];
}
echo ($_SESSION{VID});

?>
It did out put the correct value!!

AndrewGSW
07-30-2012, 08:41 PM
You still appear to have the apostrophes around the id in your sql statement. [Although this might not cause it to fail..]

I'm not sure of the order your code is running, but check that the connection is not closed earlier in the code.

And, of course, there should be data in your verses tables with this id :)

Other than this I dunno

rockyhudson
07-30-2012, 10:50 PM
Hi

Order is as listed!
Code works when I input via an input form text box in the VInput.php file. I am trying to make the scripts more user friendly, but this one is giving me a headache!

I guess that I will have to rethink the way I do it!

I am wondering if I could merge the showtype.php and the INput.php scripts.
Have the list on the left and put the rest of the input forms on the right.
Where would the Submit button have to be to POST the table and the input form?

AndrewGSW
07-30-2012, 11:44 PM
I don't quite follow how the files could run in this order, as you would end up with multiple <html>, <head> etc., tags and session_start().

Make use of things like print_r($_POST) to check the posted values..

BTW you can't POST a table :)

Good luck!

AndrewGSW
07-30-2012, 11:54 PM
You have this line:


$_SESSION['VID']=$_Event_info['ID'];

so it appears you're not setting this value from the posted data. Confused.. I'll leave you to it!

rockyhudson
07-31-2012, 05:11 PM
Thanks for the input!

Using Post a table was a poor choice of words. What I meant is having made a choice by clicking on the radio button and entering the other variables I would want to submit these values to be used in the final script Prnpdf.php.

Not sure what you meant by the last post about setting the value, in what script?

rockyhudson
08-03-2012, 11:27 PM
Hi Andrew

That was me just trying about every thing I could think of, obviously should be:

$_SESSION[VID]=$_POST[VID];
Even with the correct line it does not work.
Used your suggestion regarding print_r, but modified it to:

print_r($_SESSION)
All I get printed out is: Array()
I have even looked and change my php.ini file, as I pick up on another forum that I should check the session path, which I have now set to C:/php/session.

AndrewGSW
08-04-2012, 02:05 AM
You may have already done so, but test your SQL in phpMyAdmin


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_Type"]."'
ORDER BY Verses.ID ASC

Replace $_POST['Event_Type'] with a specific value.

AndrewGSW
08-04-2012, 02:07 AM
Try


$_SESSION['VID']=$_POST['VID'];

Arcticwarrio
08-04-2012, 08:40 AM
re you using session_start() ?

rockyhudson
08-06-2012, 09:00 PM
Tested MYSQL in phpmyadmin and works OK. Thought it would be as at present on my live site you manually enter the ID.

Since I changed php.ini to add a session path I get Array(), but before I altered I was getting Array([VID]=>).

Arcticwarrio - Yes I am using session_start() on all of the scripts involved.

This is 'doing my head in', surely there must be an answer to this problem!

Any more suggestion would be welcome!

AndrewGSW
08-06-2012, 09:21 PM
I would throw a load of echo's, print_r($_SESSION), and echo $yoursql at several points in the code. If $_SESSION never shows anything other than Array() then that would seem to be the focus of your issues.

I don't personally know how setting a location for session data impacts the code: not a lot I would have thought. Perhaps check the connection as well; something like


if (mysqli_connect_error()) {
echo "Failed to connect to MySQL: (" . mysqli_connect_errno() . ") " . mysqli_connect_error();
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum