Generate PDF from HTML with Dompdf in PHP

The Pdf file creation in PHP mainly requires when need to generate the file on the basis of the available data otherwise, simply create it manually with the external applications.

For example – generating the report, the user certificate, etc.

For generating pdf file I am using Dompdf library which generates the downloadable pdf file from HTML.

Generate PDF from HTML with Dompdf in PHP

Read more

Prevent page from submit on Refresh in PHP

If the form is already submitted and the user tries to refresh the webpage then the browser will attempt to resubmit the form.

If you are allowing the user to fill and submit the form for insert data. In this case, if the user refreshes the page then the data is reinserted into the MySQL database table if some action does not perform for preventing it.

In this tutorial, I show you some ways by using which you can avoid the page resubmit.

Prevent page from submit on Refresh in PHP

Read more

Get checked Checkboxes value with PHP

Checkboxe­s are a versatile tool found on many we­bsites, allowing users to sele­ct their preferre­d choices among different options available­ with ease.

When you use it in your form and try to read all checked values as any other elements like –  text box, text area, radio button, etc.

echo $_POST['lang'];  // Checkbox element

you will get the last checked value.

You need to send the checkboxes value in the form of an Array when the form gets submitted then you can loop over $_POST values.

In this tutorial, I show how you can read submitted checked checkboxes values with PHP and also show how you can save it to the MySQL database.

Get checked Checkboxes value with PHP

Read more

How to Break the nested loop in PHP

The break statement in PHP is utilized to terminate the execution of the current loop or switch case statement. However, when dealing with nested loops and the intention is to exit from one or more of the outer loops, you can achieve this by providing a numeric value with the break statement.

This tutorial demonstrates the process of terminating a specified number of nested foreach, for, while, and do-while loops in PHP by utilizing the break statement.

How to Break the nested loop in PHP

Read more