dongzhiman2162 2014-12-19 20:46
浏览 44
已采纳

PHP将特定查询结果发布到另一个PHP [关闭]

I have a problem with a PHP/SQL project I'm writing. It is basically a database of books, every book has its owner data. I set up a query to retrieve every book matching the query; what I want to do is being able to select one of the results, post its data to another PHP file (which will send a mail to the owner of the book). I wrote the code like this

$sql = "SELECT * FROM mydb WHERE parameter LIKE '%$value%' OR parameter LIKE '$value%' OR parameter LIKE '%$value'"; $result=mysql_query($sql);
$num = mysql_num_rows($result);
$i = 0; while ($i < $num) {
$attribute = mysql_result($result,$i,"attribute");
$mail = mysql_result($result,$i,"mail");
echo "
<form action=\"mailform.php\" method=\"post\"/><table border=\"1\">
<tr><
<td>$attribute</td>
<td>$mail</td>
<td><input type=\"submit\" value=\"Submit\"/></form></td>
</tr>
</table>
";
$i++;
}

The query is working, I get results. The mailform.php is set up this way

<?php
$mail = $_POST['$mail'];
?>

When I click on the submit button i am redirected to mailform.php but I get this error: Notice: Undefined index: $emailproprietario

What am I doing wrong? Thanks in advance

  • 写回答

1条回答 默认 最新

  • dongzilu0178 2014-12-19 23:38
    关注

    Your html is badly formed - the table spans the form instead of being nested, there is an extra, unmatched angle bracket, the form tag is self-closed and your not sending any data from the form. Consider:

    <form action=\"mailform.php\" method=\"post\">
      <table border=\"1\">
        <tr><td>$attribute</td>
            <td>$mail</td>
            <td><input type=\"submit\" value=\"Submit\"/>
            <input type=\"hidden\" name=\"attribute\" value=\"$attribute\">
            <input type=\"hidden\" name=\"mail\" value=\"$mail\">
            </td>
         </tr>
       </table>
     </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作