Jump to content

PHP post without button


edd12345678

Recommended Posts

Hello everyone,

 

I wonder if anyone can help me.

 

I have a timer which when the time expires I want any data in my form to be submitted to the database.

 

Is it possible to use post without having a button to trigger it?

 

So:  e.g

 

if(($_SESSION['endOfTimer'] - time()) < 0) 
{
Insert values to the database? 
}

 

How can I do this so it posts the data without the use of a button? 

 

Thanks in advance.

 

Ed

Link to comment
Share on other sites

Hi,

 

Many thanks for your reply.

 

Is the set timeout() needed for the timer or is it calling the submitFunction function every 5 seconds?

 

At the moment I cannot get it to work.

 

Also at the moment I do not have a form set up as such. I just have:

 



if(isset($_POST["save"])){

Then run query

}

 

 

Thanks

 

Edd

Link to comment
Share on other sites

setTimeout() only runs once.  You might be thinking of setInterval(), which runs repeatedly.  However, if you're using setTimeout() to submit a form back to the same page, well then your page will just run setTimeout() over and over again on each page load.

 

I just tried this out and this works.

 

<script type="text/javascript">
function submitForm()
{
	document.forms["theFormName"].submit();
}
setTimeout("submitForm()",2000);
</script>

<form name="theFormName" id="theFormName" action="receiving_page.html">
<input type="text" name="field1" id="field1" value="field1value">
<input type="text" name="field2" id="field2" value="field2value">
</form>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.