Hello fellow programmers, I have created a search form for my webpage which allows users to use three different fields to refine their search. I have been trying to align these objects with the main heading of the search page. I have tried many different methods but seems to move the objects into the centre. It's really bugging me and I have no clue in how to fix this! Any recommendations?
<p style="text-align:center">View Recipes which satisfy the following criteria:</p>
<div class="container cols justify-content center">
<div style="margin-bottom: 30px; width: 300px;">
<label for="author">By Author:</label>
<select name="author" id="author">
<option value="">Any Author</option>
<?php foreach ($authors as $author): ?>
<option value="<?php html($author['id']);?>"><?php html($author['name']);?></option>
<?php endforeach;?>
</select>
</div>
<div style="margin-bottom: 30px; width: 300px;">
<label for="category">By Category:</label>
<select name="category" id="category">
<option value="">Any Category</option>
<?php foreach ($categories as $category): ?>
<option value="<?php html($category['id']);?>"><?php html($category['name']);?></option>
<?php endforeach;?>
</select>
</div>
<div style="margin-bottom: 30px; width: 300px;">
<label for="text">Containing Text:</label>
<input type="text" name="text" id="text">
</div>
<div style="margin-bottom: 30px; width: 300px;">
<input class="btn btn-primary" type="submit" name="action" value="Search">
</div>
</div>
</form>
</div>
Change the margin-bottom: 30px; on all 4 div to margin: 30px auto;
If you want the align to centre then also add text-align:center; along with this margin: 30px auto;
Codepen: https://codepen.io/manaskhandelwal1/pen/PoGdxpa
I am trying to run a php file using xampp but I'm getting the Object not found error, I watched some videos where people say create another folder and run it under that but that is not working for me! look at the screenshot below and please if you could help me understand why this isn't working
enter image description here
Please note even if i use another file such as footer.php i get the same error.
here is the code for mens.php i didnt include it in the screenshot
<?php
session_start();
//unset($_SESSION['basket']);
?>
<!DOCTYPE html>
<html>
<head>
<!-- External Stylesheet -->
<link rel="stylesheet" href="style.css" type="text/css" />
<title>Mens</title>
</head>
<body>
<div class="bar">Sale Now On!</div>
<div id="outer">
<?php
include('header.php');
?>
<!-- All content will be wrapped insisde this container -->
<div id="container">
<!-- Page -->
<h2>Mens Clothing</h2>
<table width="100%" cellpadding="0" cellspacing="0">
<tr class="headings">
<th style="width: 20%;">Photo</th>
<th style="width: 30%;">Desciption</th>
<th style="width: 10%;">Size</th>
<th style="width: 10%;">Price</th>
<th style="width: 10%;">Qty</th>
<th style="width: 20%;">Action</th>
</tr>
<form action="addtocart.php" method="post" name="addtocart">
<tr class="datarow">
<td style="width: 20%; text-align: center; border-left:dotted
1px #333; border-bottom: dotted 1px #333; border-right:dotted 1px #333;">
<img src="img/suit.jpg" width="112px" />
</td>
<td style="width: 30%; text-align: center; border-bottom:
dotted 1px #333; border-right:dotted 1px #333;">Contempary Hugo Boss
Suit</td>
<input type="hidden" name="itemdesc" value="Contempary Hugo Boss
Suit" />
<input type="hidden" name="sku" value="100" />
<input type="hidden" name="pic" value="suit.jpg" />
<td style="width: 10%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<select name="size">
<option value="S">Small</option>
<option value="M">Medium</option>
<option value="L">Large</option>
</select>
</td>
<td style="width: 10%; text-align: center; border-bottom:
dotted 1px #333; border-right:dotted 1px #333;">£500.00</td>
<input type="hidden" name="price" value="500.00" />
<td style="width: 10%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<select name="qty">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</td>
<td style="width: 20%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<input type="submit" name="submit" value="Add to Basket" />
</td>
</tr>
</form>
<form action="addtocart.php" method="post" name="addtocart">
<tr class="datarow">
<td style="width: 20%; text-align: center; border-left:dotted
1px #333; border-bottom: dotted 1px #333; border-right:dotted 1px #333;">
<img src="img/suit1.jpg" width="112px" />
</td>
<td style="width: 30%; text-align: center; border-bottom:
dotted 1px #333; border-right:dotted 1px #333;">Wool Hugo Boss Suit</td>
<input type="hidden" name="itemdesc" value="Wool Hugo Boss Suit"
/>
<input type="hidden" name="sku" value="101" />
<input type="hidden" name="pic" value="suit1.jpg" />
<td style="width: 10%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<select name="size">
<option value="S">Small</option>
<option value="M">Medium</option>
<option value="L">Large</option>
</select>
</td>
<td style="width: 10%; text-align: center; border-bottom:
dotted 1px #333; border-right:dotted 1px #333;">£450.00</td>
<input type="hidden" name="price" value="450.00" />
<td style="width: 10%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<select name="qty">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</td>
<td style="width: 20%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<input type="submit" name="submit" value="Add to Basket" />
</td>
</tr>
</form>
</table>
</div>
</div>
<?php
include('footer.php');
?>
</body>
</html>
A file called ._mens.php Is NOT the same as a file called mens.php
As you are using the url localhost/example/mens.php then the file needs to be called mens.php
I have made many forms but for some unknown reason I cannot get this one to work. I hit submit and it just stays on the same page and all the inputs just go empty. Maybe a fresh pair of eyes would see something I do not. I have tried putting the PHP in a separate file, double/triple checked the input statement and everything else and just can't see it whatever it is.
This is the table:
CREATE TABLE `store_orders` (
`id` int(11) NOT NULL,
`order_date` varchar(70) NOT NULL,
`order_first_name` varchar(50) NOT NULL,
`order_last_name` varchar(50) NOT NULL,
`order_address` varchar(255) NOT NULL,
`order_city` varchar(50) NOT NULL,
`order_state` char(50) NOT NULL,
`order_zip` varchar(10) NOT NULL,
`order_tel` varchar(25) NOT NULL,
`order_email` varchar(100) NOT NULL,
`cc_type` varchar(30) NOT NULL,
`cc_number` int(16) NOT NULL,
`cc_expmonth` int(2) NOT NULL,
`cc_expyear` int(2) NOT NULL,
`cc_cvc` int(3) NOT NULL
)
Here's the PHP at the top of the page:
<?php
session_start();
//connect to database
$con = mysqli_connect("localhost", $username, #pw, $db);
$error = false;
if (isset($_POST['checkout'])) {
$datetime = mysqli_real_escape_string($con, $_POST['order_date']);
$fname = mysqli_real_escape_string($con, $_POST['order_first_name']);
$lname = mysqli_real_escape_string($con, $_POST['order_last_name']);
$address = mysqli_real_escape_string($con, $_POST['order_address']);
$city = mysqli_real_escape_string($con, $_POST['order_city']);
$state = mysqli_real_escape_string($con, $_POST['order_state']);
$zip = mysqli_real_escape_string($con, $_POST['order_zip']);
$phone = mysqli_real_escape_string($con, $_POST['order_tel']);
$email = mysqli_real_escape_string($con, $_POST['order_email']);
$cardtype = mysqli_real_escape_string($con, $_POST['cc_type']);
$cardnumber = mysqli_real_escape_string($con, $_POST['cc_number']);
$cardmonth = mysqli_real_escape_string($con, $_POST['cc_expmonth']);
$cardyear = mysqli_real_escape_string($con, $_POST['cc_expyear']);
$cardcvc = mysqli_real_escape_string($con, $_POST['cc_cvc']);
$fname = stripslashes($fname);
$lname = stripslashes($lname);
$address = stripslashes($address);
$city = stripslashes($city);
$zip = stripslashes($zip);
$phone = stripslashes($phone);
$email = stripslashes($email);
$cardtype = stripslashes($cardtype);
$cardnumber = stripslashes($cardnumber);
$cardmonth = stripslashes($cardmonth);
$cardmonth = stripslashes($cardmonth);
$cardyear = stripslashes($cardyear);
$cardcvc = stripslashes($cardcvc);
if (!preg_match("/^[a-zA-Z ]+$/",$fname)) { /* name can contain only alpha characters and space */
$error = true;
$name_error = "Name must contain only letters"; }
if (!preg_match("/^[a-zA-Z ]+$/",$lname)) { /* name can contain only alpha characters and space */
$error = true;
$name_error = "Name must contain only letters"; }
if (!preg_match("/^[a-zA-Z-0-9 ]+$/",$address)) { /* letters and numbers */
$error = true;
$user_name_error = "Address can contain only letters and numbers"; }
if (!preg_match("/^[a-zA-Z-0-9 ]+$/",$city)) { /* letters and numbers */
$error = true;
$user_name_error = "City can contain only letters and numbers"; }
if(!filter_var($email,FILTER_VALIDATE_EMAIL)) { /* will accept only email addresses */
$error = true;
$email_error = "Please Enter Valid Email ID"; }
if (!$error) {
if(mysqli_query($con, "INSERT INTO store_orders(order_date, order_first_name, order_last_name, order_address, order_city , order_state, order_zip, order_tel, order_email, cc_type, cc_number, cc_expmonth, cc_expyear, cc_cvc ) VALUES('".$datetime."','".$fname."','".$lname."','".$address."','".$city."','".$state."','".$zip."','".$phone."','".$email."','".$cardtype."','".$cardnumber."','".$cardmonth."','".$cardyear."','".$cardcvc."')"));
header('Location: checkout-view.php');
} else {
$errormsg = "Error completing form...Please try again!"; /* if register is not successful */
}
}
?>
This is the form... on the same page...
<!doctype html>
<html>
<!-- InstanceBegin template="/Templates/index.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
</head>
<body style="background-color: #f9ecf2;">
<div class="container">
<div class="col-md-8 col-sm-8 grad" style="background-color: ; margin-right: 0px; margin-left: 0px; border-bottom-style: solid; border-bottom-color: #4d004d; border-bottom-width: 1px; padding-left: 0px;">
<!-- begin middle column -->
<!-- InstanceBeginEditable name="EditRegion3" -->
<div style='width: 85%; margin-left: auto; margin-right: auto;'>
<br>
<br>
<br>
<form role="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="checkout">
<table width="100%" border="0" class="responsive">
<tr>
<td align="right" valign="top" width="30%" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Date - Time</b5>
</td>
<td>
<b3 style="font-size: 12pt;">
<input name="order_date" id="order_date" type="text" value="<?php echo date('m/d/y');?>" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" width="30%" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">First Name:</b5>
</td>
<td>
<b3 style="font-size: 12pt;">
<input name="order_first_name" id="order_first_name" type="text" size="50" maxlength="50" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" width="30%" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Last Name:</b5>
</td>
<td>
<b3 style="font-size: 12pt;">
<input name="order_last_name" id="order_last_name" type="text" size="50" maxlength="40" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" width="30%" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Address:</b5>
</td>
<td>
<b3 style="font-size: 12pt;">
<input name="order_address" id="order_address" type="text" size="50" maxlength="255" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" width="30%" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">City:</b5>
</td>
<td>
<b3 style="font-size: 12pt;">
<input name="order_city" id="order_city" type="text" size="50" maxlength="50" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" width="30%" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Select State:</b5>
</td>
<td style=" padding-top: 5px;">
<b3 style="font-size: 12pt;">
<select name="order_state" id="order_state">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Zip Code:</b5>
</td>
<td style=" padding-top: 5px;">
<b3 style="font-size: 12pt;">
<input name="order_zip" id="order_zip" type="text" size="50" maxlength="10" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Phone:</b5>
</td>
<td style=" padding-top: 5px;">
<b3 style="font-size: 12pt;">
<input name="order_tel" id="order_tel" type="text" size="50" maxlength="25" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Email Address:</b5>
</td>
<td style=" padding-top: 5px;">
<b3 style="font-size: 12pt;">
<input name="order_email" type="email" id="order_email" size="50" maxlength="100" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Select Card Type:</b5>
</td>
<td style=" padding-top: 5px; font-size: 24pt; color: #4d004d">
<p>
<b5>
<img src="img/cc-mastercard.png" width="75" height="49" alt="" />
<input type="radio" name="cc_type" value="Mastercard">
<img src="img/cc-visa.png" width="75" height="49" alt="" />
<input type="radio" name="cc_type" value="Visa">
<img src="img/cc-american-express.png" width="75" height="49" alt="" />
<input type="radio" name="cc_type" value="American Express">
<img src="img/cc-paypal.png" width="75" height="49" alt="" />
<input type="radio" name="cc_type" value="PayPal">
</b5>
</p>
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Card Number:</b5>
</td>
<td style=" padding-top: 5px;">
<b3 style="font-size: 12pt;">
<input name="cc_number" type="integer" id="cc_number" size="50" maxlength="16" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Expiration:</b5>
</td>
<td style=" padding-top: 5px;">
<b3 style="font-size: 12pt;">
<input name="cc_expmonth" type="integer" id="cc_expmonth" size="2" maxlength="2" required="required" /><span Style='font-size: 18pt; color: #4d004d'><b3> / </span>
</b3>
<input name="cc_expyear" type="integer" id="cc_expyear" size="2" maxlength="2" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">CVC Code:</b5>
</td>
<td style=" padding-top: 5px;">
<b3 style="font-size: 12pt;">
<input name="cc_cvc" type="integer" id="cc_cvc" size="3" maxlength="3" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;"></td>
<td style=" padding-top: 5px;">
<b5 style="font-size: 12pt;">
<input name="submit" type="submit" value="Submit" /><span>   </span>
<input name="reset" type="reset" value="Reset" />
</b5>
</td>
</tr>
</table>
</form>
</div>
<br>
<br>
<br>
<!-- InstanceEndEditable -->
</div>
<!-- end middle column -->
</body>
<!-- InstanceEnd -->
</html>
The connection is right. I've got about an hour to turn this assignment in so, at midnight (EST), the semester is over. Good thing I made 100's on everything else this Fall...... I have made countless forms over the past year or more and never had a problem.....
Change the name of the submit button to "checkout" and remove the name="checkout" from the form.
I am working on a form for a newsletter questionairy. There I have some trouble with some selected statements. The statements which can be selected (value="f" and value "m") will not be uploaded onto the mail server. Maybe someone of you has a solution. The FirstNAme, LAstName and EMail are working.
Here is the code:
<div style="margin-right:auto;margin-left:auto;width:720px">
<form id="nl2go--form" action="https://app.newsletter.com/de/recipients/index/subscribe/" method="post" accept-charset="utf-8">
<table border="0" align="center">
<tr>
<td><select name="n1go-gender" style="font-size:9pt; background:border: 1px solid #181717; padding: 2px; width: 45pt;" onchange="alert(this.form.n1go-gender.options[this.form.n1go-gender.selectedIndex].value)">
<option value="f" selected>Woman</option>
<option value="m">Mister</option>
</select> <input type="text" name="nl2go-firstname" id="nl2go--firstname" style="font-size:9pt; color:#181717; background:border: 1px solid #181717; padding: 2px; width: 107pt;" placeholder="FirstName"/> <input type="text" name="nl2go--lastname" id="nlgo-lastname" style="color:#181717; font-size:9pt; width:107pt; background border: 1px solid #181717; padding: 2px;" placeholder="LastName"/></td>
<tr>
<td><input type="text" name="nl2go-mail" id="nlgo--mail" style="font-size:9pt; width:272pt; background border: 1px solid #cccccc; padding: 2px;" placeholder="Your E-Mail"></td>
<tr>
<td align="center"><input type="submit" value="Senden" name="nlgo-submit" id="nlgo-submit" class="jfk-button jfk-button-action">
<input type="hidden" name="nl2go--key" id="nl2go--key" value="dfdfdfdf....."></div></td></tr></table></div></ol>
</form
cheers
Vrede
Ugly. You have syntax issues on this line:
</div></td></tr></table></div></ol>
Thus, breaking your code/form.
Also, try using classes for styling opposed to inline styles.
I'm a novice when it comes to generating pdf files
I've tried tcpdf and mpdf but not getting the format the way i want it be.
Here's my mpdf code
include('./mpdf.php');
$mpdf=new mPDF();
$html = '<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="cssForTable.css">
</head>
<body>
<table>
<thead>
<tr>
<th width="25%">Client Details</th>
<th colspan="2" width="50%"><h2 style="padding-top: 0; margin-bottom: 0; margin-top: 0;text-align: center"><strong>ROAD TRAFFIC ACCIDENT</strong></h2></th>
<th width="25%">Legal HQ</th>
</tr>
</thead>
<tbody>
<tr>
<td width="50%" colspan="2">
<strong>Instructed Another Solicito?</strong>
Yes <input type="checkbox" /> No <input type="checkbox" />
</td>
<th width="50%" colspan="2" rowspan="3">
Claiming For:<br />
Personal Injury Yes <input type="checkbox" style="margin-bottom: 7px;" />
No <input type="checkbox" style="margin-bottom: 7px;" /><br />
Vehicle Damage Yes <input type="checkbox" style="margin-bottom: 7px;" />
No <input type="checkbox" style="margin-bottom: 7px;" /><br />
Loss of Earnings Yes <input type="checkbox" />
No <input type="checkbox" />
</th>
</tr>
<tr><th colspan="2"><h3 style="padding-top: 0; margin-bottom: 0; margin-top: 0;">ACCIDENT DETAILS</h3></th></tr>
<tr>
<th width="25%">Date of Accident</th>
<td width="25%"> </td>
</tr>
<tr>
<th width="25%">Time of Accident</th>
<td width="25%"> </td>
<th width="25%">No of Occupants (inc driver)</th>
<td width="25%"> </td>
</tr>
<tr>
<th width="25%">Location of Accident</th>
<td width="25%"> </td>
<td width="50%" colspan="2" rowspan="2" valign="top" >
<strong>Were Police Involved?
Yes <input type="checkbox" />
No <input type="checkbox" />
<br />
<br />If so, Police No/Station: </strong>
</td>
</tr>
<tr>
<td width="25%" colspan="2" rowspan="2" valign="top"><strong>Accident Circumstances</strong><br /><br /></td>
</tr>
<tr>
<th width="25%" colspan="2">
Is Client:<br />
Owner <input type="checkbox" style="margin-left: 15em; margin-bottom: 7px;" /><br />
Driver <input type="checkbox" style="margin-left: 15em; margin-bottom: 7px;" /><br />
Passenger <input type="checkbox" style="margin-left: 13em;" />
</th>
</tr>
<tr>
<th width="25%">Weather Conditions</th>
<th width="75%" colspan="3">
<label style="margin-left: 2em; margin-bottom: 7px;" > Sunny <input type="checkbox" /></label>
<label style="margin-left: 8em; margin-bottom: 7px;" > Rain <input type="checkbox" /></label>
<label style="margin-left: 8em; margin-bottom: 7px;" > Snow <input type="checkbox" /></label><br />
<label style="margin-left: 2em; margin-bottom: 7px;" > Ice <input type="checkbox" /></label>
<label style="margin-left: 8em; margin-bottom: 7px;" > Fog <input type="checkbox" /></label>
<label style="margin-left: 8em; margin-bottom: 7px;" > Dark <input type="checkbox" /></label>
</th>
</tr>
</tbody>
</table>
</body>
</html>';
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;
The above code generates the following PDF file (screen shot)
Where as it should look like the following
My question is, is there a way to generate PDF as we generate HTML I mean is there a way to print whatever html+PHP has generated on client side?
Any Idea?
HTML2PDF converters may be overstrained with that layout. You may should consider PDF-Generators with more powerful layout-options.
The downside is, that you have to define your layout in another layout-language, but this will guarantee a satisfying output.
Have you considered to use XSL/FO with a suitable generator like PDFnow?
Yes, you can do this. Here is the complete code.
It works perfectly.
You can get value from another page using post method also. Your choice.
<?php $student_id = $_GET['student_id']; ?>
<?php
include("mpdf/mpdf.php");
$html .= "
<html>
<head>
<style>
body {font-family: sans-serif;
font-size: 10pt;
background-image: url(\"images/ok.jpg\");
background-repeat: no-repeat;
padding-top:10pt;
margin-top: 100px;
padding-top: 50px;
}
td { vertical-align: top;
border-left: 0.6mm solid #000000;
border-right: 0.6mm solid #000000;
align: center;
}
p.student_id{
padding-left : 140px;
padding-top : -27px;
}
</style>
</head>
<body>
<!--mpdf
<p class=\"student_id\">$student_id</p>
<sethtmlpageheader name='myheader' value='on' show-this-page='1' />
<sethtmlpagefooter name='myfooter' value='on' />
mpdf-->
</body>
</html>
";
$mpdf=new mPDF();
$mpdf->WriteHTML($html);
$mpdf->SetDisplayMode('fullpage');
$mpdf->Output();
?>