PHP form submit on same page

php form submit on same page

PHP form submit on same page

How to do PHP form submit on same page. On submitting the form stay on same page.

In this article we’ll discuss php form submit on same page. There are two ways to submit a form using php, either on the same page or to a php script. To submit a form on the same page, just specify

Syntax :


inside the action attribute.

<form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
//form elements

There will be a confusion that after self submitting how to do the code part, for that just check the form submited or not. then do the codings inside the if condition. Check the following example,

Full Code :

    //your php scripts
<!DOCTYPE html>
    <title>Base 64 image Upload</title>
    <link rel="stylesheet" href="">
    <div class="row">
	<div class="col-md-4">
	   <form action="<?=$_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data">
		<!-- Your form elements -->
		<input type="submit" name="submit" value="Submit" class="btn btn-sm btn-info">

Included bootstrap css to style the form.

For other php solutions please check php

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top