I'm having trouble with a global variable, I think it might be pulling its data from a HTML Form Input, but I can't find any documentation on the web about global var pulling data from a HTML Form Input.
Thanks.
When a form is submitted the method tag specifies if it is a POST or GET request. Depending on what method your form is using your form values can either be in your $_POST or $_GET Super global.
Example:
<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
After the submit button on the form is clicked the form contents can be found by referencing the name attribute in the super global(In this case the POST).
$_POST['name']
$_POST['email']
For documentation see
http://php.net/manual/en/reserved.variables.post.php
This applies to PHP 4 >= 4.1.0, PHP 5, PHP 7 ie. fits PHP 5.3.
Related
sorry for the very noob question. I have a page : www.example.com/edit/3 with form inside.
<form class="" action="" method="post">
Usually my form action I will specify something like add, register, etc. In this case, I am not sure how do I specify it. Currently it is working when I save it if I leave it blank without specifying anything. But I am not sure is this the right way to do it.
Controller
public function edit_game(){}
Routes
$routes->match(['get', 'post'], 'account/edit_game/(:num)', 'Addgame::edit_game/$1');
Can anyone advise?
action="" is the URI to which send the form data, aka the controller where you treat the received data. If not specified, it will be the same page as the one you are currently on.
What you can do:
<form method="post">
</form>
<form method="post" action=""> <!-- same as previous -->
</form>
<form method="post" action="/some/page">
</form>
In the last example, note the leading /, it means it is according to the site root. If you forget it, it will be relative to the current URI.
Exemple, if the page containing the <form> is http://example.com/edit/3:
action="/some/page" will redirect to http://example.com/some/page.
action="some/page" will redirect to http://example.com/edit/some/page
When creating a custom view in joomla with multiple forms, there is a conflict because each form has the id="adminForm" name="adminForm".
Renaming the form causes incompatibility with joomla.
How can I display multiple adminForm's on a single view?
Restructure the form elements into a single page-encompassing form
and remove the &task=controller.task portion from the form action
URL, e.g.
<form
action="<?php echo JRoute::_(''); ?>"
name="adminForm" id="adminForm" class="form-validate"
method="post" enctype="multipart/form-data">
On each submit button use the joomla method: onclick="Joomla.submitbutton('controller.task')" e.g.
<button type="submit"
onclick="Joomla.submitbutton('group.join')">Join</button>
Joomla will automatically update a hidden field with the name="task" and value="controller.task" which will get submitted with the form.
You need to have this element in your form for it to work, e.g.
<input type="hidden" name="task" value="" />
</form>
I have a post type form with action to an external PHP that calculates a shipping tax.
<form id="shipping_costs" autocomplete="off" method="post" action="tarif.php" target="blank">
<input type="hidden" name="serviciu" value="Standard">
All the inputs are hidden and the website that receives all the values calculates the tax.
How can I retrieve the resulted amount into my website?
Also, the website I work on is using smarty.
<H1 align="center">ID Lookup</H1>
<FORM ACTION="index.jsp" METHOD="POST">
<H3 ALIGN="center">Please enter your User ID:</H3>
<INPUT TYPE="TEXT" NAME="userIDTextBox">
<br>
<br>
<INPUT TYPE="SUBMIT" value="Submit">
<%
String userID = request.getParameter("userIDTextBox");
%>
</FORM>
I'm a beginner and this is my form on my jsp page. What I want to do is have the form disappear after submitting. Can anyone help me please? Or give some tips?
Give your form an ID, then use a javascript command to get your form element and set its visibility.
var myform = document.getElementById('myForm');
myform.style.visibility="hidden";
Now you just need to handle a javascript event and run that.
After Reading your requirement all I understand is you are trying to read parameter "userIDTextBox" from one page and need to display the value to some other page. And You are trying to achieve the same in one page.
Rather have two separate pages..
First with Form and required text field
Other to display the value
Define servlet and servlet-mapping configuration in web.xml
That is the valid way to do it. Hope it may help
This is a really strange issue that I cannot seem to solve. On a WordPress site, I have several forms (login, registration, and other) outputted on a site via short codes. When the forms are submitted, their data is processed via an "init" hook that listens for the $_POST data.
Note, the site is running WordPress, but I have deemed this to not be a WordPress issue, which is why I'm posting here.
When the forms are submitted in IE 9, all fields are cleared of the values when clicking submit. For example, let's say there is an input field with a name of "username", and the field's value is set to "johndoe"; when submitting the form through any browser besides IE 9 (include 7 and 8), the data comes in like this:
$_POST['username'] = 'johndoe'
Exactly as expected.
However, when the form is submitted with IE9, it comes out like this:
$_POST['username'] = ''
As far as I can tell, it happens with every form on the site.
The custom login form I've built, for example, looks like this:
<form id="re_login_form" class="re_login_form" action="" method="post">
<fieldset>
<label for="re_user_Login"><?php _e('Username', 're'); ?></label>
<input name="re_user_login" id="re_user_login" class="required" type="text" title="<?php _e('Username', 're'); ?>"/>
</fieldset>
<fieldset>
<label for="re_user_pass"><?php _e('Password', 're'); ?></label>
<input name="re_user_pass" id="re_user_pass" class="password required" type="password"/>
</fieldset>
<fieldset class="form-action">
<input type="hidden" name="refalf_redirect" value="<?php echo $redirect; ?>"/>
<input type="hidden" name="re_login_nonce" value="<?php echo wp_create_nonce('re-login-nonce'); ?>"/>
<input id="re_login_submit" type="submit" class="button re_submit" value="<?php _e('Log In', 're'); ?>"/>
<p class="forgot-password"><?php _e('Lost Password?', 're'); ?></p>
</fieldset>
</form>
One of the things that is extra interesting is that the fields are visibly cleared of their values when clicking submit in IE9. It's also as though the submit button is triggering something in IE9 that clears the fields.
Anyone have any ideas?
I was able to solve this by giving each input field a placeholder attribute. I still don't know why that made it work, but when the placeholder was present, everything worked fine.
You're not alone..
See for instance http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/afda3def-b0be-431d-a9fc-c40dd7cb2fa4
Easiest test is at http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_form_mail
I just experienced a bit similar case: IE9 posted back a form only partially; some values were cleared upon submit. I tested submitting form with IE9, IE10, IE11, Chrome36, FF31 and all others worked fine except IE9.
So I checked the markup and there was another form nested inside the main form page which actually did not have any input fields or submit buttons it had been created by some automated template/editor software.
After I removed those extra form nodes, IE9 started to submit all fields. I worked with ASP.NET 4.5 MVC4.