Conditional lodgic for form id
-
I am creating a pdf from PHP which works great, but I need to use conditional logic to print the correct fields on the pdf when the user hits submit. Right now it does not print any fields when I try to add conditional logic in. Here is the code I am using.
if ( ! is_admin() ) { // phpcs:ignore if( $form->id === 4 ){ // phpcs:ignore if ( $_POST ) { // phpcs:ignore require 'fpdf.php'; $coursename = $_POST['item_meta'][32]; // phpcs:ignore $name = $_POST['item_meta'][36]; // phpcs:ignore $doc = date( "m/d/Y" ); // phpcs:ignore $pdf = new FPDF(); $pdf->AddPage( 'L' ); $pdf->Image( 'wp-content/themes/mwp/fpdf/Yalicert.jpg', 0, 0, 300, 210, 'JPG' ); $pdf->SetFont( 'Arial', 'B', 15 ); $pdf->Cell( 0, 170, $coursename, 100, 1, 'C' ); $pdf->SetX( 55 ); $pdf->Cell( 0, -15, $doc, 0, 1, 'L' ); $pdf->Cell( 0, -50, $name, 0, 0, 'C' ); $pdf->Output(); } } elseif( $form->id === 3 ) { // phpcs:ignore if ( $_POST ) { // phpcs:ignore require 'fpdf.php'; $coursename = $_POST['item_meta'][7]; // phpcs:ignore $name = $_POST['item_meta'][10]; // phpcs:ignore $doc = 'Gre'; // phpcs:ignore $pdf = new FPDF(); $pdf->AddPage( 'L' ); $pdf->Image( 'wp-content/themes/mwp/fpdf/Yalicert.jpg', 0, 0, 300, 210, 'JPG' ); $pdf->SetFont( 'Arial', 'B', 15 ); $pdf->Cell( 0, 170, $coursename, 100, 1, 'C' ); $pdf->SetX( 55 ); $pdf->Cell( 0, -15, $doc, 0, 1, 'L' ); $pdf->Cell( 0, -50, $name, 0, 0, 'C' ); $pdf->Output(); } } if( $form->id === 2 ) { // phpcs:ignore if ( $_POST ) { // phpcs:ignore require 'fpdf.php'; $coursename = $_POST['item_meta'][20]; // phpcs:ignore $name = $_POST['item_meta'][23]; // phpcs:ignore $doc = 'Port'; // phpcs:ignore $pdf = new FPDF(); $pdf->AddPage( 'L' ); $pdf->Image( 'wp-content/themes/mwp/fpdf/Yalicert.jpg', 0, 0, 300, 210, 'JPG' ); $pdf->SetFont( 'Arial', 'B', 15 ); $pdf->Cell( 0, 170, $coursename, 100, 1, 'C' ); $pdf->SetX( 55 ); $pdf->Cell( 0, -15, $doc, 0, 1, 'L' ); $pdf->Cell( 0, -50, $name, 0, 0, 'C' ); $pdf->Output(); } } }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Conditional lodgic for form id’ is closed to new replies.