post variable with textarea - forms

I think that if you assign a name attribute to an input type='text' that name becomes the post variable. How can you assign a post variable to am html textarea. i cant seem to get it working. Im just trying to take a user's imputed text from the textarea and put it into a mysql database. thanks
form:
<form action='index.php' method='POST'>
<textarea name='form'></textarea>
</form>
<?php $input=$_POST['form']; ?>

Related

Testing form input text value

I am testing the following form in my html :
<form wicket:id="form">
<input type="text" wicket:id="input"/>
<input type="submit"/>
</form>
The default value is null and in my test I tried to change it to something and check if I have really changed the field as following:
formTester.setValue(formTester.getForm().get("input"), "randomText");
Assert.assertEquals("randomText", formTester.getTextComponentValue("input"));
However the test is not successful because the field expected <[randomText]> but was: [].Any ideas why the setting doesn't work?
You need to call FormTester#submit() after setting the values of the FormComponents.

How to parse html forms in the Go Iris framework?

Sorry if this question is a bit basic, but how can you parse form inputs in the Go Iris framework?
Here is the form I am using
<form action="/" method="post">
Username:<input type="text" name="username">
Password:<input type="password" name="password">
<input type="submit" value="Login">
</form>
here is the route and the controller respectively
iris.Post("/", TestController)
func TestController(c *iris.Context){
username := c.Form.Get("username")//Doesn't work
password := c.Form.Get("password")//Doesn't work
}
how do I retrieve the values in the Post request after the form has been submitted, Thanks
Based off an example on the iris github page you could try c.PostValue("Username"). The code you have may also work but I think you need to capitalize the variable names. In the html template you can see the name value is lowercased, however your context is more likely going off those the variable names to the left of the actual html like Username.

Passing AngularJS variable through form input field does not work

I have an iFrame that has content on a different domain, that I also control. I like to pass confidential data from the parent to the iFrame. Therefore, I do not want to pass it via query string or URL. I like to pass it via Form hidden input fields. It works if the values of the fields are text. However, it does not work if I use AngularJS variables as values for the fields.
Below is my code.
{{session.user.user_ID}} and {{i18n.domain}} works in this HTML file and writes the correct values to the webpage.
<form id="form_frame" action="http://other.mydomain.com/forIframe.php" method="post" target="output_frame">
<input type="hidden" value="{{session.user.user_ID}}" name="id" />
<input type="hidden" value="{{i18n.domain}}" name="domain" />
</form>
<iframe name="output_frame" width="400" height="400">
</iframe>
<script language="JavaScript" type="text/javascript">
document.getElementById("form_frame").submit(); // automatically submit the form
</script>
I have this in my forIframe.php file, which is the file that writes the content for the iFrame:
echo 'user ID is: '.$_POST['id'];
However, the above writes this:
user ID is: {{session.user.user_ID}}
Why doesn't this AngularJS variable parse correctly into the value attribute of the input field? How do I pass the values in {{session.user.user_ID}} and {{i18n.domain}} securely to my PHP file in my iFrame?
Elements inside the iFrame do not inherit the scope of the parent. You best bet is to use messaging i.e. $broadcast and $on : http://plnkr.co/edit/Osa5MNKiJKzsi7wAUXgM?p=preview

if isset doesn't work in php

I'm having a form with only one submit button. I don't know why, but when I use this code and I click on the submit button, nothing is happening. If I use a ! before the isset you'll see the echo in the page. I don't know what's wrong with it.
<form>
<input type="submit" value="Toevoegen" name="addImg" />
</form>
<?
if (isset($_POST['addImg'])) {echo "haaallloooo";}
?>
Maybe, form by default is sending variables by get, try using method="POST" attribute in form tag
You have to set the method to POST.
Otherwise you can use:
$_REQUEST['addImg']
The variable $_REQUEST can access both GET and POST parameters.
Form needs an action and a method.
<form action="" method="post">
<input type="submit" value="Toevoegen" name="addImg" />
</form>
<?
if (isset($_POST['addImg'])) {echo "haaallloooo";}
?>
Regarding "isset", if $_POST['addImg'] is not set, it doesn't echo "haaallloooo".
isset — Determine if a variable is set and is not NULL
Check http://hk.php.net/manual/en/function.isset.php

Validate form field to make sure it is not empty

Everyone i am newbie to ASP, I wrote a code that should take the input from HTML form.
I have given one textbox that text box value is mandatory. If user doesn't give input to the field. the asp page should show the message that "The field cannot be left empty!"
I have written a code, but I am not getting the output. Can anyone help me?
My code snippet is
index.html
<form method="post" action="a1.asp">
Field 1<input type="text" name="field1">*
</br></br><input type="submit" name="send" value="submit">
<input type="reset" name="clear" value="clear">
</form>
a1.asp
<%
Function Mandatory(field1)
if field1 = "" then
response.write("Field one is mandatory!cannot be left empty")
else
response.write("Welcome to new html")
End if
End Function
%>
you must use Request.Form to get the value from "POST" action.
like:
field1 = request.form("field1")
if field1 = "" then
....
refer to this: http://www.w3schools.com/asp/coll_form.asp
by the way, asp is very very old. if you want to learn web develop languages, you can try ASP.NET or php.
Hard to tell without more information. But you need to call the function somewhere, and reference the Request collection, like:
<% Mandatory(Request("field1")) %>