Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
<form action="../index.php?option=com_rsform&formId=3" method = "get">
<input type="hidden" name='form[Name]' value="1">
<input type="submit" value="Submit">
</form>
and i need this result:
http://localhost/index.php?option=com_rsform&formId=3&form[Name]=1
but i get this result:
http://localhost/index.php?form%5BName%5D=1
where is the problem?
This seems to be expected behavior regarding form actions when a combination of action URL parameters and form fields are present, and at the moment I'm not finding anything in a spec which tells otherwise.
The practical solution seems to be to just put the values you want in the form itself:
<form action="../index.php" method="get">
<input type="hidden" name='option' value="com_rsform">
<input type="hidden" name='formId' value="3">
<input type="hidden" name='form[Name]' value="1">
<input type="submit" value="Submit">
</form>
Check this: submitting a GET form with query string params and hidden params disappear
The GET parameters of "action" are overwrited by the form. So, the answer of David is correct.
Other solution: make a POST form and keep your URL ;)
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
NOTE: Possible duplicate question is not helpful, as it does not compensate for multiple options for different pages while also passing form information.
I need to take user input from the current page (for now, this is just a single text field), and there are three buttons. The three buttons are supposed to go to different pages respectively, but all three need the value from the text field to do their job.
Essentially, I need to "pass" the value from the text field to either of the three pages that the buttons should redirect to. Currently, the buttons are unable to redirect as I do not know how to do that.
This is my code thus far:
<html>
<body>
<form name="form" action="" method="post">
Name: <input type="text" name="name" value="<?php echo $name;?>">
</form>
<button type="button">button1</button>
<button type="button">button2</button>
<button type="button">button3</button>
</body>
</html>
No JavaScript please.
<?php
if(isset($_POST['button1'])){
$link='index_1.php?name='.$_POST['name'];
header('location:'.$link);
}elseif(isset($_POST['button2'])){
$link='index_2.php?name='.$_POST['name'];
header('location:'.$link);
} elseif(isset($_POST['button3'])){
$link='index_3.php?name='.$_POST['name'];
header('location:'.$link);
}
?>
<form action="" method="POST">
Name: <input type="text" name="name" value="">
<button type="submit" name="button1" value="button1">button1</button>
<button type="submit" name="button2" value="button2">button2</button>
<button type="submit" name="button3" value="button3">button3</button>
</form>
The page where a form leads to is defined in its action attribute of the formtag. Just write the filepath + filename into that attribute and after submitting, you'll be redirected to that page and can use the POST parameter values there.
But you'll need to add a submit button - one, not three, and as an input tag
Use the submit type, and the check the value for the submitted (or the name you want to put it) in the PHP file, if the value is "button1" do something, if its "button2" etc.
<form action="/action_page.php" method="POST">
Name: <input type="text" name="name" value="<?php echo $name;?>">
<button type="submit" name="submited" value="button1">button1</button>
<button type="submit" name="submited" value="button2">button2</button>
<button type="submit" name="submited" value="button3">button3</button>
</form>
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
i'm deleting products(data) on checkbox and after click on delete button i'm deleting rows but the problem is after delete is complete i'm not getting $_GET global array variable values back to my page which is essential to load page...
$_GET['cid'] is category id and $_GET['scid'] is subcategory id...just because of missing values my page is showing up without data
if(isset($_GET['delete']))
{
$cnt=array();
$cnt=count($_GET['chkbox']);
for($i=0;$i<$cnt;$i++)
{
$del_id=$_GET['chkbox'][$i];
$query="delete from products where product_id=".$del_id;
mysqli_query($con,$query);
header("Location:topics.php?cid=".$_GET['cid']."&scid=".$_GET['scid']."");}}
on header location i'm not getting value ,
plz ignore if u found any mistake in my questioning because this is my first question
Given the information provided, I'm going to assume that this is the problem and hopefully this can be helpful...
Presumably you have a form of some kind which you access via your URL: localhost/php/FORM%20LOGIN/topics.php?cid=1&scid=5
<form method="GET">
// some form elements
<input type="submit" name="delete" value="Delete" />
</form>
Something at least similar to that. Then when you click the delete button you send a request to a URL which is more like: localhost/php/FORM%20LOGIN/topics.php?delete=Delete&...
So your original cid and scid values are lost. This is because they weren't included in the form. But since you had those values when the page loaded, you can include them in your form. Something like this:
<form method="GET">
<input type="hidden" name="cid" value="<?php echo $_GET['cid']; ?>" />
<input type="hidden" name="scid" value="<?php echo $_GET['scid']; ?>" />
// some form elements
<input type="submit" name="delete" value="Delete" />
</form>
By including the values in your form, they will be included in the form's request to the server.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
There is a href tag:
Send
or a button (needs form tag)
<form action="file.php" method="GET">
<button type="submit">Send</button>
</form>
that will redirect to file.php URL.
I want to send id parameter to another PHP file. How do I do that?
==========================================================================
To send that data where must be provided input params (ex. hidden input) or in-url parameter.
ex.
<form action="file.php" method="GET">
<button type="submit">Send</button>
<input type="hidden" name="id" value="YOUR_ID"
</form>
or
Send
You want to transfer the id only to the next file? Use this in the first:
link_to_2
or
<form...>
<input name="id" type="hidden" value="1">
<button type="submit">btn_to_2</button>
</form>
And in your second file use this for both cases:
<?= $_REQUEST['id'] ?>
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have simple email script with few forms and I am getting duplicate submissions...
So, what is the easiest way to prevent duplicate submissions?
My code..
<form action="main_contact.php" method="post" name="contact_form">
<input type="text" name="contact_name" placeholder="Name">
<input type="email" name="contact_email" placeholder="Email">
<input type="text" name="contact_subject" placeholder="Subject">
<textarea cols="30" name="contact_message" rows="10" placeholder="Your Message"></textarea>
<input type="submit" value="Send">
</form>
<?php
if(isset($_POST['contact_form'])){
var_dump($_POST);
}
?>
You can use jQuery to disable submit button after the form has been submitted:
$('form[name="contact_form"]').submit(function(){
$(this).find('input[type="submit"]').prop('disabled', true);
});
you just need to disable or make visibility hidden after just click on submit button. fist give a id to the submit button
<input type="submit" value="Send" id="sub_id">
and then make it hidden or disable in javascript once you submit the form
document.getElementById('sub_id').style.visibility='hidden';
If you used any framework like Laravel5 or Symfony you would get it "out of the box".
In short:
Register a session token and invalidate it after first form submission.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
i have a problem, i will send a POST with PHP but i will
send a GET Parameter with the form value:
<form action="/Eventsuche/" method="post">
<table>
<tr>
<td>
<input id="Headsucheort" name="Headsucheort" type="text" value="" />
</td>
<td>
<button type="submit" name="Submit" id="Headsuchestart" value="Headsuchestart">»</button>
</td>
</tr>
So, on submit he bring me to /Eventsuche/ but i would like to
go here: /Eventsuche/Value of Headsucheort
Thanks! :)
<button onclick="window.location.href='/Eventsuche/' + document.getElementById('Headsucheort').value">»</button>
Didn't test but
If you really must do it in PHP, add this to Eventsuch:
if ( isset($_POST['Headsucheort']) ) {
header('location:http://www.your-url.com/Eventsuche/'.$_POST['Headsucheort']);
exit;
}
I see two ways to the that.
first:
you can add your variable to the end of your action value such as: action="Eventsuche?var=somevalue"
and second one would be:
as a hidden input and even tho it is hidden, php will capture it on submit as in:
<input type="hidden" name="myvar_name" value="my_var_value" />
i think this should do it.