When I use
<form method="post" enctype="text/plain" action="proc.php">
form data can not be sent to proc.php file properly. Why? What is the problem? Why I can't use text/plain encoding with post but I can use it with get method?
When I use
<form method="post" enctype="text/plain" action="proc.php">
form data can not be sent to proc.php file properly. Why? What is the problem? Why I can't use text/plain encoding with post but I can use it with get method?
The good news is that PHP and JavaScript have a similar idea about what values are true and false.
0
in PHP) will be true on both sides.0
will be false on both sides. All other numbers will be true on both sides.Since the values of a form will always be strings, as Quentin pointed out in his answer, a good practice might be to use an empty string as false value and something else (e.g. 'true'
) as true value. But I think your way of using 0
and 1
and testing the numerical values is the safest approach because it isn't misleading. (When someone sees 'true'
they might think 'false'
would also be usable for a false value.
This code is working. You need to add some condition, that checks, if $username
is posted or not.
Something like that:
if(count($_POST)){
$username ='';
if(isset($_POST['user'])){
$username = $_POST['user'];
if ($username==null || !$username)
echo 'username is null';
echo strlen($username);
echo $username;
}
}
Seems to be working just fine now:
https://jsfiddle.net/jphellemons/0ukbtgs4/
with your code:
<input type="email" id="tags" placeholder="Any Criteria">
<script type="text/javascript" src="external/jquery/js/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="external/jquery-ui/js/jquery-ui-1.12.1.min.js"></script>
<script>
$(function() {
var availableTags = ["ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure",
"COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript",
"Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme"
];
$("#tags").autocomplete({
source: availableTags
});
});
</script>
Matlab matrices with more than 1 dimesion must have same number of elements for each value in one of the dimensions.
In your case, when fi
is declared its dimension is 1x1
. And you are trying to add 6 elements on the 2nd position of the first dimension. So, if that worked, you would end up with something like this: [[1],[a1 a2 a3 a4 a5 a6]]
. But that is not allowed.
If you still want to do that, you may want to use a cell array. Which allows you to add different elements.
Here you have an example:
fi = {1}
fi{end+1} = 0.8*(V./T)
Notice that some functions like sum
won't work on a cell array and you would have to do some conversions.
On the other hand if you expected to have a different output like this: [1 a1 a2 a3 a4 a5 a6]
(like sugested on another answer). You may have different options including horzcat
:
fi = horzcat([1],0.8*(V./T))
[Revised]
The answer is, because PHP doesn't handle it (and it is not a bug):
https://bugs.php.net/bug.php?id=33741
The first is the default, the second one you need only when you upload files.
@Alohci provided explanation why PHP doesn't populate
$_POST
array, but store the value inside a variable$HTTP_RAW_POST_DATA
.Example of what can go wrong with
text/plain
enctype:file1.php:
file2.php:
Result:
No way to distinguish what is the value of
input1
andinput2
variables. It can beabcrninput2=def
, input2=ghi
, as well asabc
, input2=defrninput2=ghi
No such problem when using the other two encodings mentioned before.
The difference between GET and POST:
enctype="text/plain"
- it just gets ignored by the browser; you can test it using Wireshark to sniff the request packets),text/plain
orapplication/x-www-form-urlencoded
, but the second one is the only non-ambiguous solution.