-3

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");
?>
  • could you higlight the youre line 13, since when trying to answer someone would have to count. – Poohl Dec 15 '18 at 08:47

1 Answers1

0

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

Rohit Rasela
  • 425
  • 3
  • 6