duanrong0738 2018-12-15 08:28
浏览 84
已采纳

注意:未定义的变量:在线输入[重复]

I'm a student and currently I'm learning about PHP, i'm stuck at this, I really don't understand, and I hope there someone can teach me how to fix this things

The error shows: Notice: Undefined variable: tipe in C:\xampp\htdocs\q\admin\tambahjadwal.php on line 13 semua form harus diisi!

<?php
include"../koneksi/koneksi.php";
if(isset($_POST['tipe'])){
    $berangkat=strip_tags($_POST['tipe']);
    $dari=strip_tags($_POST['lokasi']);
    $ke=strip_tags($_POST['harga']);
    $waktu=strip_tags($_POST['fasilitas']);
    $harga=strip_tags($_POST['max']);

  $gambar=$_FILES['gambar']['tmp_name'];
  $gambar_name=$_FILES[ 'gambar']['name'];

if($gambar&&$tipe&&$lokasi&&$harga&&$fasilitas&&$max){
  move_uploaded_file($gambar, '../gambar/'.$gambar_name);
    $insert="insert into hotel values('','$gambar_name','$tipe','$lokasi','$harga','$fasilitas','$max')";
    $hasil=mysql_query($insert);
    echo"<script>alert('jadwal berhasil ditambah');window.location.href='index.php';</script>";
}else{
  echo"semua form harus diisi!";
}}
?>



<html>

<body>
<h2>Tambah Hotel</h2><br />

<form action="#" method="post" enctype="multipart/form-data">
<table width="850" border="0">
  <tr>
    <td width="360" align="right">gambar</td>
    <td width="14" align="center">:</td>
    <td width="462"><input type="file" name="gambar" required="required" /></td>
  </tr>
  <tr>
    <td align="right">Tipe</td>
    <td align="center">:</td>
    <td><input type="text" name="tipe"" class="input"  required="required" /></td>
  </tr>
  <tr>
    <td align="right">Lokasi</td>
    <td align="center">:</td>
    <td><input type="text" name="lokasi" class="input" required="required" /></td>
  </tr>
  <tr>
    <td align="right">Harga</td>
    <td align="center">:</td>
    <td><input type="text" name="harga" class="input" required="required" /></td>
  </tr>
  <tr>
    <td align="right">Fasilitas</td>
    <td align="center">:</td>
    <td><input type="text" name="fasilitas" class="input" required="required" /></td>
  </tr>
  <tr>
    <td align="right">Maksimal</td>
    <td align="center">:</td>
    <td><input type="text" name="max" class="input" required="required" /></td>
  </tr>
  <tr>
    <td height="73" align="right"><input type="reset" value="reset" class="button" /></td>
    <td>&nbsp;</td>
    <td><input type="submit" value="tambah" class="button" onclick="return confirm('apakah anda yakin?')" /></td>
  </tr>
</table>
</form>
</body>
</html>

and koneksi.php

<?php
mysql_connect("localhost","root","");
mysql_select_db("a");
?>
</div>
  • 写回答

1条回答 默认 最新

  • doufu6196 2018-12-15 08:33
    关注

    You should use $tipe = strip_tags($_POST['tipe']); instead of $berangkat = strip_tags($_POST['tipe']);. Because you did not define the variable $tipe.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题