Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7005471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:21:17+00:00 2026-05-27T21:21:17+00:00

Is there anyway to send post data to a php script other than having

  • 0

Is there anyway to send post data to a php script other than having a form? (Not using GET of course).

I want javascript to reload the page after X seconds and post some data to the page at the same time. I could do it with GET but I would rather use POST, as it looks cleaner.

Thanks a lot.

EDIT: Would it be possible to do with PHP header? I’m sure it is better to use JQuery but for my current situation I could implement that a lot easier/faster : )

Cheers

I ended up doing it like so:

<script>
  function mySubmit() {
    var form = document.forms.myForm;
    form.submit();
  }
</script>

...

<body onLoad="mySubmit()";>
  <form action="script.php?GET_Value=<?php echo $GET_var ?>" name="myForm" method="post">
    <input type="hidden" name="POST_Value" value="<?php echo $POST_Var ?>">
  </form>
</body>

Seems to work fine for me, but please say if there is anything wrong with it!

Thanks everyone.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:21:18+00:00Added an answer on May 27, 2026 at 9:21 pm

    As requested above, here is how you could dynamically add a hidden form and submit it when you want to refresh the page.

    Somewhere in your HTML:

    <div id="hidden_form_container" style="display:none;"></div>
    

    And some Javascript:

    function postRefreshPage () {
      var theForm, newInput1, newInput2;
      // Start by creating a <form>
      theForm = document.createElement('form');
      theForm.action = 'somepage.php';
      theForm.method = 'post';
      // Next create the <input>s in the form and give them names and values
      newInput1 = document.createElement('input');
      newInput1.type = 'hidden';
      newInput1.name = 'input_1';
      newInput1.value = 'value 1';
      newInput2 = document.createElement('input');
      newInput2.type = 'hidden';
      newInput2.name = 'input_2';
      newInput2.value = 'value 2';
      // Now put everything together...
      theForm.appendChild(newInput1);
      theForm.appendChild(newInput2);
      // ...and it to the DOM...
      document.getElementById('hidden_form_container').appendChild(theForm);
      // ...and submit it
      theForm.submit();
    }
    

    This is equivalent to submitting this HTML form:

    <form action="somepage.php" method="post">
      <input type="hidden" name="input_1" value="value 1" />
      <input type="hidden" name="input_2" value="value 2" />
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there anyway which I can shrink ( like gzip ) a post data
I know how to send post/get request using any HTTPClient which are explained here
In my view there is a form shown below <% using (Html.BeginForm(SaveRecords, Search, FormMethod.Post))
I want to submit a form using jquery .post() . I want to send
Is there any way for developer to send data to the iPhone's USB port?
Is there anyway in Java to delete data (e.g., a variable value, object) and
Is there anyway to upgrade the installed JRE in the system? We are having
I am trying to submit data using Jquery AJAX (using the following script) and
I am trying to send data to my server using HttpPost via the following
I'm sending an HTTP POST request from my C++ app to a PHP script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.