w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Prevent HTML form action from being displayed on browser, or redirect to another page after the action being executed

use an hidden parameter like

 <input type="hidden" name="action" value="1" />

Your form will look like this:

<form action="http://www.example.com/form-manager.php"
method="POST">

</form>

Yout form manager will look like this:

 if ($_POST['action'] == "1")
       require_once('ThePHPFileIDoNotWantToBeLoadedOnBrowser.php");

Seeing your comment, you can do it with an AJAX call:

$(document).on('submit' ,
'form[action="http://www.example.com/ThePHPFileIDoNotWantToBeLoadedOnBrowser.php"]'
, function(e){

     var formData = $(this).serialize(); // if you need any of the vars

     $.ajax({
         url:'someOtherURL.php',
         type:'POST',
         datatype:'json',
         data: formData,
         success : function(data){
             for(var i = 0; i < data.length; i++){
                 console.log(data);

             }
         },
         error : function(s , i , error){
             console.log(error);
         }
     });

     return true; // keep normal behavior
 });




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.