Autosubmit Form after 5 seconds

autosubmit form after 5 seconds

AUTOSUBMIT FORM AFTER 5 SECONDS

In this tutorial we are going to see how a form we can submit on its own by the help of Javascript. Here we are using HTML / JAVASCRIPT / PHP to send a value from one end to another end without leaving traces. This trick we can use to make many things.

So lets start with out HTML page. Here is the code for the link through which we are going to send a Youtube video code.

<a href="https://firstsite.com/link.php?v=iYrpfZWmG_U">Click To Watch The Video</a>

Above code will make a Hyper Link.

It will open firstsite.com/link.php and recieve youtube code ” iYrpfZWmG_U ” on that page through $_GET[‘v’] variable.

So our code for link.php is

<?php
if(isset($_GET['v']) AND !empty($_GET['v']))
{
    $vcode = trim($_GET['v']);
?>
<script>
window.setInterval(function(){ 
    document.getElementById("youcode").submit(); 
}, 5000); 
</script>
<form action="newpage.php" method="post" id="youcode">
    <input type="hidden" value="<?php echo $vcode; ?>" name="vcode" />
</form>
<?php
}
else 
{
    echo 'Not valid code';
}
?>

Variable $vcode is recieving youtube code through variable $_GET[‘v’]

placing $vcode in a hidden field inside a form with id=”youcode” and that id will autosubmit after 5 seconds with the help of JavaScript , that Javascript code is

<script> 
window.setInterval(function(){ 
document.getElementById("youcode").submit(); 
}, 5000); 
</script>

If want to submit more quicker or late then change value of 5000 to any number which suits.

Once the form autosubmit it will send value of code to newpage.php with the method=”post” , so next page which is newpage.php will not show any trace of the video code

Now newpage.php code is here to recieve youtube code.

<center>
<?php 
if(isset($_POST['vcode']) AND !empty($_POST['vcode']))
{
 $vidcode = trim($_POST['vcode']);
?>
<iframe width="853" height="480" src="https://www.youtube.com/embed/<?php echo $vidcode; ?>" title="Motu Patlu | मोटू पतलू S1 | John The Bodyguard | Episode 129 Part 1 | Download Voot Kids App" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<?php
}
?>
</center>

If someone directly open newpage.php it will not show any video on it. So having no trace.

Hope this trick our readers like it.

Leave a Reply

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

89  −  83  =