I have a really strange problem here..
I have my form:
<form class="attach" name="attach" method="post" action="main.php">
<label for="aurl">URL:</label>
<input type="text" name="aurl" id="aurl" si开发者_运维百科ze="50"/>
<input type="submit" id="submit" name="submit" value="Submit"/>
</form>
If I do print_r($_POST)
I see it fine.
However, if I do, after the print_r
:
if(!empty($_POST['aurl'])) {
$url = $_POST['aurl'];
I can't use $_POST['aurl']
and print_r
shows an empty array.
Any idea what could be going on here?
My full code: http://pastebin.com/Ayt1qCUY
If $_POST['aurl']
has a value of 0, "0", or "", empty($_POST['aurl'])
will return true. I prefer using isset($_POST['aurl'])
.
you can use
echo"url:";
print_r($_POST['aurl']);
die;
to see what is in aurl and then use
if(isset($_POST['aurl'])) {
$url = $_POST['aurl'];
}
If you want to debug your POST and GET, please use print_r($_GET); and print_r($_POST); to see all POST and GET you can have in the actionpage ;-)
It's better to use isset. If you want to check empty for a string, i recommend to use strlen. empty is problematic for some characters as hughes describes.
精彩评论