简体   繁体   中英

cannot get textarea values from post in php

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>

on savecontact.php, I am retrieving 'txtspecificaddress' value

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

but it shows nothing. I have checked the value of $_SESSION['oldspecificaddress']. Can Somebody help? I am new to PHP.

Try this with mysqli :

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

or try this

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM