使用$\u GET PHP通过URL传递输入类型文本值

使用$\u GET PHP通过URL传递输入类型文本值,php,Php,我有这段代码,我想使用$\u GET通过URL传递输入类型文本的文本 <?php print(" <tr class='$class'> <td> <input type='text' name='newName' /> <a class='rename' href='http://www.example.com/php/rename

我有这段代码,我想使用
$\u GET
通过URL传递输入类型文本的文本

<?php print("
            <tr class='$class'>
              <td>
                <input type='text' name='newName' />
                <a class='rename' href='http://www.example.com/php/rename.php?file=$namehref&new_name=$_GET['$newName']'>
                  <span>Rename</span>
                </a>
              </td>
           ");
?>

尝试将
$\u GET['$newName']
更改为
{$\u GET[“$newName”]}

<?php print("
        <tr class='$class'>
            <td>
                <input type='text' name='newName' />
                <a class='rename' href='http://www.example.com/php/rename.php?file=$namehref&new_name={$_GET["$newName"]}'>
                    <span>Rename</span>
                </a>
            </td>");

只需移除
$newName
周围的
'

<?php
 print("
    <tr class='$class'>
        <td>
            <input type='text' name='newName' />
            <a class='rename' href='http://www.example.com/php/rename.php?file=$namehref&new_name=$_GET[$newName]'>
                <span>Rename</span>
            </a>
        </td>");

如果使用$\u GET[],这将是一个更难的代码。我建议您使用javascript将文本传递给元素中的其他属性。

试试以下方法:

<?php
   //put your php code here and close tag
?>
            <tr class=''>
                <td>
                    <input type='text' name='newName' />
                    <a class='rename' 
                       onclick="var textVal = document.getElementsByName('newName')[0].value; 
                           window.location.href = 'http://www.example.com/php/rename.php?file=<?php echo $namehref;?>&new_name='+textVal"
                       href="javascript:void(0);">
                        <span>Rename</span>
                    </a>
                </td>