无法从php中的帖子中获取textarea值

时间:2016-10-18 11:19:50

标签: php post textarea

Editcontact.php

<form method="post" autocomplete="off" action="savecontact.php" id="form" name="form">
<table>
<tr>
<td>Specific Address in Office</td>
<td><textarea name="txtspecificaddress" id="txtspecificaddress" rows="4"   cols="50" placeholder="Type specific address within the office. e.g. Room  Number, Section Name or Division Name etc."><?php echo $_SESSION['oldspecificaddress']; ?></textarea></td>
</tr>
</table>
</form>
在savecontact.php上

我正在检索&#t; txtspecificaddress&#39;值

if(isset($_POST['txtspecificaddress']))
{   
$specificaddress=mysqli_real_escape_string(trim($_POST['txtspecificaddress']    ));
}
echo $specificaddress;

但它没有显示任何内容。我检查了$ _SESSION [&#39; oldspecificaddress&#39;]的值。有人可以帮忙吗?我是PHP的新手。

2 个答案:

答案 0 :(得分:0)

尝试使用mysqli:

   </td>
</tr>
<tr>
    <td style="padding-left:20px;">Referral Link</td>
    <td bgcolor="#FFFAEA" class="upp" width="600px" align="left">
        <strong>http://<? echo $namaweb; ?>/<? echo $r["username"];?></strong>
    </td>
</tr>

或试试这个

<?php
$mysqli = new mysqli("localhost", "root", "", "database_name");
if(isset($_POST['txtspecificaddress']))
{   
    $specificaddress = $mysqli->real_escape_string(trim($_POST['txtspecificaddress']));
}
echo $specificaddress;

答案 1 :(得分:-1)

mysqli_real_escape_string()只需要2个参数,并且您只传递了1个参数。