Submit auto form without submit button - php

I want to auto submit form after 5 minutes without submit button my code is working but not get post value.Please help me.
<form name="addcontact" method="post" content="2;" action="URL=demo.php">
<input type="text" name="addontable" value="Add on Table" />
</form>

You have a wrong value for action attribute of the form - change it to:
<form name="addcontact" method="post" content="2;" action="demo.php" content="2;">
<input type="text" name="addontable" value="Add on Table" />
</form>

Related

SUBMIT button value sent only when clicked

I have the following web form:
<form action="processor.php" method="post">
<input type="checkbox" name="cb" onclick="submit()">
<input type="submit" name="search" value="Search">
</form>
So either clicking the submit button or the checkbox this form is submitted to process.php page. But submit's value named "search" is sent only when button clicked explicitly, not when checkbox is clicked. Unexpectedly for me. I expected that submitting the form with submit() command will send all parameters as well (including submit button's "search" parameter).
So in PHP code I cannot use:
if(isset($_POST['search'])
to test if form was submitted, I have to use:
if($_SERVER['REQUEST_METHOD']=='POST')
Is this normal behaviour of submitt button?
Yes this the correct behavior.
The value of a submit input is only send when activated or clicked, since here you submit the form through the function it's logical.
Check this example:
<form action="edit.php" method="post">
<input type="text" name="name">
<input type="submit" name="action" value="Save">
<input type="submit" name="action" value="Preview">
</form>
This behavior allow multiple submit action in a form.
__
On checkbox click simulate a click on the submit button instead of using submit()
Yes it's normal. I have made some code for you to make it work:).
Add a class to your checkbox and submit button. And add the js code to your html or separate js file.
<form action="processor.php" method="post">
<input type="checkbox" class="checkbox" name="cb" onclick="submit()">
<input type="submit" class="sub" name="search" value="Search">
</form>
It goes in this function when you click on the checkbox, it is seeing when its enabled and if it's so simulate a click on the submit button.
$(".checkbox").change(function() {
if(this.checked) {
$(".sub").click();
}
});

different form field required depending on submit clicked

I was wondering if it was possible to make a form field required if I submit my form with one button and not required if I click on another button.
Exemple:
<form method="post" action="action.php" name="form1">
<input type="text" name="participant_name" /> //required if submit button = save_button
//not required if submit button = cancel_button
<input type="submit" value="save" name="save_button" />
<input type="submit" value="cancel" name="cancel_button" />
</form>
Thx everyone :)
You can add the attribute: required to the input. And make from the cancel button a non submit button with u goback link with javascript.
<form method="post" action="action.php" name="form1">
<input type="text" name="participant_name" required/>
<input type="submit" value="save" name="save_button" />
<input type="button" value="cancel" onclick="window.history.back();"/>
Otherwise you should write a javascript/jquery script that validates the form after form submit.
Here is running code: https://jsfiddle.net/zmm896n2/

fetching value with the submit button in HTML?

If the submit button is pressed in HTML I need to send some value with it. How can I do it?
<input type="submit" name="ask" class="tbutton" value="ask" />
if(isset($_POST['ask'])){
// i need to fetch some value that is passed with submit button }
I think you want to fetch value of some input right?
may be this will help
<form method="post">
<input type="text" name="myText" />
<input type="submit" name="ask" class="tbutton" value="ask" />
</form>
<?php
if(isset($_POST['ask'])){
echo($_POST['myText']);
}
?>

Form Method 'GET'. On submit move to Other page then run php file

What I need to do as concept is quite simple.
Let's suppose this is my form:
<form name="my_form" class="my_class" id="my_id" method="GET">
<input type="text" name="input1" value="my_text" id="my_id">
<input type="submit" name="button" class="submit" value="submit" id="submit">
</form>
I need to perfom those 2 steps
Step 1) On Submit move to page 'http//myformsubmit.eu/form/result'
Step 2) 'Run query.php'
I was thinking to add a kind of action like:
<form name="my_form" id="my_id" method="GET" action="/result/query.php">
Is this possible? Any way to perform those two steps?

Passing query string with input from a text box through a click PHP HTML

I am trying to pass query string through a button and a text box.
Such that I enter some text into a text box and I will click an image button.
And that button will pass what is typed in the text box and pass it to next page.
How should I go about doing it?
Below is my code:
<input type="text" name="search" class="resizedTextbox">
<a href=page.php?productName=$_GET["search"]><img src="images/search-btn.gif"/></a>
Try this:
<form method="GET" action="page.php">
<input type="text" name="search" class="resizedTextbox">
<input type="image" src="images/search-btn.gif"/>
</form>
Try This
<form name="frm" method="get" action="page.php">
<input type="text" name="search" id="search">
<input type="submit" name="btnSearch" value="Search" onclick="location.href='http://www.website.com/index.php?search='+document.getElementById('search').value;" id="btnSearch" class="buttonSearch" />
</form>
get value with java script and pass with get method.

Categories