Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 22

Thread: POST Problem

  1. #1
    New Coder
    Join Date
    Jan 2012
    Location
    Hastings, East Sussex, UK
    Posts
    34
    Thanks
    21
    Thanked 0 Times in 0 Posts

    POST Problem

    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
    Code:
    <?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
    Code:
    <?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
    Code:
    <?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?

  • #2
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    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. 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() at the top of each page that will make use of the $_SESSION values.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • Users who have thanked Rowsdower! for this post:

    rockyhudson (07-27-2012)

  • #3
    New Coder
    Join Date
    Jan 2012
    Location
    Hastings, East Sussex, UK
    Posts
    34
    Thanks
    21
    Thanked 0 Times in 0 Posts

    Exclamation Using $_SESSION

    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:
    Code:
    	$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:
    Code:
    $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?

  • #4
    Regular Coder
    Join Date
    May 2011
    Posts
    124
    Thanks
    12
    Thanked 6 Times in 6 Posts
    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.

  • #5
    New Coder
    Join Date
    Jan 2012
    Location
    Hastings, East Sussex, UK
    Posts
    34
    Thanks
    21
    Thanked 0 Times in 0 Posts
    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?

  • #6
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    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:

    PHP Code:
    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
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • Users who have thanked AndrewGSW for this post:

    rockyhudson (07-29-2012)

  • #7
    New Coder
    Join Date
    Jan 2012
    Location
    Hastings, East Sussex, UK
    Posts
    34
    Thanks
    21
    Thanked 0 Times in 0 Posts
    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!

  • #8
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Sorry about the missing ).

    PHP Code:
    $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:

    PHP Code:
    $the_id mysqli_real_escape_string($mysqli$_SESSION['ID']);
    $Get_Verse_sql "SELECT ID, Event, Sub_Type, Verse FROM Verses WHERE ID=$the_id"
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • Users who have thanked AndrewGSW for this post:

    rockyhudson (07-30-2012)

  • #9
    New Coder
    Join Date
    Jan 2012
    Location
    Hastings, East Sussex, UK
    Posts
    34
    Thanks
    21
    Thanked 0 Times in 0 Posts
    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.

  • #10
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    I doubt it's the SQL itself that is the problem. Can you re-post the relevant code as it is now.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #11
    New Coder
    Join Date
    Jan 2012
    Location
    Hastings, East Sussex, UK
    Posts
    34
    Thanks
    21
    Thanked 0 Times in 0 Posts
    Showtype.php
    Code:
    <?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)
    Code:
    <?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
    Code:
    <?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:
    Code:
    <?php
    if (isset($_POST['VID']) && is_numeric($_POST['VID'])) {
    $_SESSION['VID'] = (int) $_POST['VID'];
    }
    echo ($_SESSION{VID});
    
    ?>
    It did out put the correct value!!
    Last edited by rockyhudson; 07-30-2012 at 08:00 PM. Reason: Added test script.

  • #12
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    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
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • Users who have thanked AndrewGSW for this post:

    rockyhudson (07-30-2012)

  • #13
    New Coder
    Join Date
    Jan 2012
    Location
    Hastings, East Sussex, UK
    Posts
    34
    Thanks
    21
    Thanked 0 Times in 0 Posts
    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?

  • #14
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    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!
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • Users who have thanked AndrewGSW for this post:

    rockyhudson (08-06-2012)

  • #15
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    You have this line:

    PHP Code:
    $_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!
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •