dqyin0101 2016-12-15 11:04
浏览 33

未定义的索引:第49行的C:\ xampp \ htdocs \ assignment.php中的n1 [重复]

Hi i'm totally beginner with php. So I'm trying this one for my school project. And I'm seeing

Undefined index: n1 in C:\xampp\htdocs\assignment.php on line 49

Really don't know where the problem is.

<html>

<body style="color:Midnightblue;"bgcolor=#eee8aa>
<form action="index.php" method="post">

<h1>Mobile Shop Management</h1>

<font size='16'><i>Type your Name:</i></font> <input type="text" name="n1" size="10" style="background-color: lightblue;    
    display: inline-block; 
    margin-right: 20px; 
    width: 380px;
    height: 50px;
    border-radius: 0%;
    margin-left: 72px;  
    text-align: center;
    font-size: 2em;"><br><br>
<font size='16'><i>Type your Budget:</i></font> <input type="text" name="n2" size="10" style="background-color:lightblue;   
    display: inline-block; 
    margin-right: 20px; 
    width: 180px;
    height: 50px;
    border-radius: 0%;
    margin-left: 50px;  
    text-align: center;
    font-size: 2em;"><br><br>

<input type="submit" size="10" value="Show" style="background-color:lightblue;

    box-shadow: 5px 5px 5px #888;   
    display: inline-block; 
    margin-right: 20px; 
    width: 280px;
    height: 50px;
    border-radius: 0%;
    margin-left: 230px; 
    color: #CC0000;
    text-align: center;
    font-weight: bold;
    font-size: 2em;
    border: 4px solid #008800;">
</form>

</body>
</html>


<?php
if ($_POST['n1']<>""||$_POST['n2']<>"")
{

    $x=$_POST['n1'];
    $y=$_POST['n2'];

$c=mysql_connect("localhost","root",""); 
mysql_select_db('mis410');


$q=mysql_query("select Mobile_brand from mobile_shop where price<=$y"); 



echo "Hello mr./ms. $x <br> Available devices: $q";


mysql_close($c);
}
?> 
</div>
  • 写回答

1条回答 默认 最新

  • dqc42632 2016-12-15 11:13
    关注

    You are posting your form to index.php and are trying to get the variable in assignment.php. Try changing

     <form action="index.php" method="post"> 
    

    to

    <form action="assignment.php" method="post">
    
    评论

报告相同问题?

悬赏问题

  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 qgcomp混合物线性模型分析的代码出现错误:Model aliasing occurred
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答
  • ¥20 在本地部署CHATRWKV时遇到了AttributeError: 'str' object has no attribute 'requires_grad'