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 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制