注意:未定义的索引:C:\ wamp64中的用户名

时间:2017-01-01 21:33:22

标签: php html mysql

我正在尝试提交一个在mysql数据库中保存一些信息的表单,下面的代码保存在一个php文件中,该文件在 action =“addrestaurant.php”中调用 信息未保存在数据库中,

<html ng-app='myApp'>
    <body>
        <div><input type="text"></div>
        <div ng-view></div>
        // Imports
        <script>
            (function() {
                $('input').each(function() {
                    $(this).addClass('doSomething');
                });
            })();
        </script>
    </body>
</html>

这是表格:

//addrestourant.php

<?php
include("config.php");
$rname =  addslashes($_POST['username']);
$add=addslashes($_POST['address']);
$restype=$_POST['restype'];
$postcode=$_POST['zipcode'];
$mobile=$_POST['mobile'];
$email=$_POST['email'];
$latitude=$_POST['latitude'];
$longitude=$_POST['longitude'];
$time=$_POST['time'];
$totime=$_POST['time2'];
$timing=$time." "."To"." ".$totime;
$status=$_POST['status'];
$food=$_POST['browsers'];
$ratting=2;
function cwUpload($field_name = '', $target_folder = '', $file_name = '', $thumb = FALSE, $thumb_folder = '', $thumb_width = '', $thumb_height = ''){
    $target_path = $target_folder;
    $thumb_path = $thumb_folder;
    $filename_err = explode(".",$_FILES[$field_name]['name']);
    $filename_err_count = count($filename_err);
    $file_ext = $filename_err[$filename_err_count-1];
    $r1 = chr(rand(ord('a'), ord('z')));
    $r2 = chr(rand(ord('a'), ord('z')));
    $r3 = chr(rand(ord('a'), ord('z')));
    $id=$r1.$r2.$r3;
    $fileName = $id.$_FILES[$field_name]['name'];
    $upload_image = $target_path.basename($fileName);
    if(move_uploaded_file($_FILES[$field_name]['tmp_name'],$upload_image)) {
        if($thumb == TRUE) {
            $thumbnail = $thumb_path.$fileName;
            list($width,$height) = getimagesize($upload_image);
            $thumb_create = imagecreatetruecolor($thumb_width,$thumb_height);
            switch($file_ext){
                case 'jpg':
                    $source = imagecreatefromjpeg($upload_image);
                    break;
                case 'jpeg':
                    $source = imagecreatefromjpeg($upload_image);
                    break;
                case 'png':
                    $source = imagecreatefrompng($upload_image);
                    break;
                case 'gif':
                    $source = imagecreatefromgif($upload_image);
                    break;
                default:
                    $source = imagecreatefromjpeg($upload_image);
            }
            imagecopyresized($thumb_create,$source,0,0,0,0,$thumb_width,$thumb_height,$width,$height);
            switch($file_ext){
                case 'jpg' || 'jpeg':
                    imagejpeg($thumb_create,$thumbnail,100);
                    break;
                case 'png':
                    imagepng($thumb_create,$thumbnail,100);
                    break;
                case 'gif':
                    imagegif($thumb_create,$thumbnail,100);
                    break;
                default:
                    imagejpeg($thumb_create,$thumbnail,100);
            }
        } return $fileName;
    } else { return false; }
} if(!empty($_FILES['image']['name'])){
    $upload_img = cwUpload('image','../uploads/image/','',TRUE,'../uploads/','200','97');
    $thumb_src = '../uploads/thumbs/'.$upload_img;
    $imagepath =  $upload_img;
} $query=mysqli_query($con,"insert into tbl_restourant (name,address,latitude,longitude,ratting,zipcode,phone_no,time,email,is_active,vegtype,thumimage) VALUES ('$rname','$add','$latitude','$longitude','$ratting','$postcode','$mobile','$timing','$email','$status','$restype','$imagepath')");
if($query){
    $q=mysqli_query($con,"select id from tbl_restourant WHERE name ='$rname' && phone_no='$mobile'");
    $r=mysqli_fetch_array($q);
    foreach($food as $value){
        $qr=mysqli_query($con,"insert into tbl_food (food_id,food_type) VALUES ('".$r['id']."','$value')");
    }
    for($i=0; $i<count($_FILES['photos']['name']); $i++) {
        $tmpFilePath = $_FILES['photos']['tmp_name'][$i];
        if ($tmpFilePath != ""){
            $r1 = chr(rand(ord('a'), ord('z')));
            $r2 = chr(rand(ord('a'), ord('z')));
            $id=$r1.$r2;
            $newFilePath = "../uploads/" .$id. $_FILES['photos']['name'][$i];
            $imagepath= $id.$_FILES['photos']['name'][$i];
            if(move_uploaded_file($tmpFilePath, $newFilePath)) {
                $qry=mysqli_query($con,"insert into tbl_images (image_id,img_url) VALUES ('".$r['id']."','$imagepath')");
            }
        }
    }
    ?><script> window.location='../addrestourant.php';</script><?php
}
?>

这是我在提交表单时遇到的错误:

<?php  session_start(); if(isset($_SESSION['uname'])){ ?>
<?php include'include/config.php'; ?>  


<form id="exampleFullForm" method="post" autocomplete="off" enctype="multipart/form-data" action="include/addrestourant.php">
                    <div class="row row-lg">
                        <div class="col-lg-6 form-horizontal">
                            <div class="form-group">
                                <label class="col-lg-12 col-sm-3 control-label">Restaurant Name
                                    <span class="required">*</span>
                                </label>
                                <div class="col-lg-12 col-sm-9">
                                    <div class="input-group" >
                                        <span class="input-group-addon">
                                        <i class="icon wb-user" aria-hidden="true"></i>
                                        </span>
                                        <input type="text" class="form-control boder"   name="username" placeholder="" required="">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-12 col-sm-3 control-label">Restaurant Type
                                    <span class="required">*</span>
                                </label>
                                <div>
                                    <div class="col-lg-4 col-sm-9">
                                        <div class="radio-custom radio-primary">
                                            <input type="radio" class="boder" id="inputAwesome" name="restype" value="Veg"  required="">
                                            <label for="inputAwesome">Veg</label>
                                        </div>
                                    </div>
                                    <div class="col-lg-4 col-sm-9">
                                        <div class="radio-custom radio-primary">
                                            <input type="radio"  class="boder" id="inputVeryAwesome" name="restype" value="Nonveg">
                                            <label for="inputVeryAwesome">Nonveg</label>
                                        </div>
                                    </div>
                                    <div class="col-lg-4 col-sm-9">
                                        <div class="radio-custom radio-primary">
                                            <input type="radio"  class="boder" id="inputVeryAwesome" name="restype" value="Both">
                                            <label for="inputVeryAwesome">Both</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-12 col-sm-3 control-label">Address
                                    <span class="required">*</span>
                                </label>
                                <div class="col-lg-12 col-sm-9">
                                    <div class="input-group" >
                                        <span class="input-group-addon">
                                            <i class="icon wb-briefcase" aria-hidden="true"></i>
                                         </span>
                                        <textarea class="form-control boder"   name="address" placeholder="Write Address" required=""></textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-12 col-sm-3 control-label">Zipcode
                                    <span class="required">*</span>
                                </label>
                                <div class="col-lg-12 col-sm-9">
                                    <div class="input-group" >
                                        <span class="input-group-addon">
                                                <i class="icon wb-list-numbered" aria-hidden="true"></i>
                                        </span>
                                        <input type="text" class="form-control boder"   name="zipcode" placeholder="" required="">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-12 col-sm-3 control-label">Phone No.<span class="required">*</span></label>
                                <div class="col-lg-12 col-sm-9">
                                    <div class="input-group" >
                                        <span class="input-group-addon"><i class="icon wb-mobile" aria-hidden="true"></i></span>
                                        <input type="text" class="form-control boder"   name="mobile" placeholder="" required="">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-12 col-sm-3 control-label">Email<span class="required">*</span>
                                </label>
                                <div class="col-lg-12 col-sm-9">
                                    <div class="input-group" >
                                        <span class="input-group-addon">
                                            <i class="icon wb-envelope" aria-hidden="true"></i>
                                         </span>
                                        <input type="email" class="form-control boder"   name="email" placeholder="email@email.com"
                                               required="">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-12 col-sm-9 control-label">Thumbnail image</label>
                                <div class="col-lg-12 col-sm-9">
                                    <input class="form-control boder" type="file" name="image" id="file" required="" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-12 col-sm-9 control-label">Select Images</label>
                                <div class="col-lg-12 col-sm-9">
                                    <input class="form-control boder" type="file" name="photos[]" id="file" multiple="true" required="" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-12 col-sm-9 control-label">Status
                                    <span class="required">*</span>
                                </label>
                                <div >
                                    <div class="col-lg-6 col-sm-9">
                                        <div class="radio-custom radio-primary">
                                            <input type="radio" class="boder" id="inputAwesome" name="status" value="1" checked required="">
                                            <label for="inputAwesome">Active</label>
                                        </div>
                                    </div>
                                    <div class="col-lg-6 col-sm-9">
                                        <div class="radio-custom radio-primary">
                                            <input type="radio"  class="boder" id="inputVeryAwesome" name="status" value="0">
                                            <label for="inputVeryAwesome">Deactive</label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>


                        <script src="http://maps.google.com/maps/api/js?libraries=places&region=uk&language=en&sensor=true"></script>
                        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>





                        <div class="col-lg-6 form-horizontal">
                            <div class="form-group">
                                <div class="col-lg-12 col-sm-9">
                                    <div class="form-group">
                                        <label class="col-lg-12 col-sm-3 control-label">Search Address
                                            <span class="required">*</span>
                                        </label>
                                        <div class="col-lg-12 col-sm-9">
                                            <div class="input-group" >
                                        <span class="input-group-addon">
                                                <i class="icon wb-map" aria-hidden="true"></i>
                                        </span>
                                                <input id="searchTextField" type="text" size="50" class="form-control boder" style="direction: ltr;">  </div>
                                        </div>
                                    </div>
                                    <div id="map_canvas" style="height: 250px;width: 450px;margin: 0.6em;"></div>
                                <div class="form-group">
                                    <label class="col-lg-12 col-sm-3 control-label">Latitude
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-lg-12 col-sm-9">
                                        <div class="input-group" >
                                        <span class="input-group-addon">
                                                <i class="icon wb-map" aria-hidden="true"></i>
                                        </span>
                                            <input type="text" id="MapLat" class="form-control boder MapLat"   name="latitude" placeholder="latitude" required="">
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-12 col-sm-3 control-label">Longitude<span class="required">*</span></label>
                                    <div class="col-lg-12 col-sm-9">
                                        <div class="input-group" >
                                        <span class="input-group-addon">
                                                <i class="icon wb-map" aria-hidden="true"></i>
                                        </span>
                                            <input type="text" id="MapLon"  class="form-control boder MapLon"   name="longitude" placeholder="Longitude" required="">
                                        </div>
                                    </div>
                                </div>
                            <div class="form-group">
                                <label class="col-lg-12 col-sm-3 control-label">Time
                                    <span class="required">*</span>
                                </label>
                                <div class="col-lg-6 col-sm-9">
                                    <div class="input-group " >
                                        <span class="input-group-addon">
                                                <i class="icon wb-time" aria-hidden="true"></i>
                                        </span>
                                        <input type="text" class="form-control boder" name="time" placeholder="Ex:08:30 AM" required="">
                                    </div>
                                </div>
                                <div class="col-lg-1 col-sm-9">TO</div>
                                <div class="col-lg-5 col-sm-9">
                                    <div class="input-group " >
                                        <input type="text" class="form-control boder" name="time2" placeholder="Ex:09:30 PM" required="">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                             <label class="col-lg-12 col-sm-9 control-label">Food Type</label>
                                <div class="col-lg-12 col-sm-9">
                                    <select class="form-control boder" id="browsers" name="browsers[]" title="Please select at least one browser" size="5" multiple="multiple" required="">
                                        <?php $query = mysqli_query($con,"select * from tbl_foodcategories");
                                        while($res=mysqli_fetch_array($query)){ ?>
                                        <option value="<?php echo $res['name']; ?>"><?php echo $res['name']; ?></option>
                                        <?php } ?>
                                    </select>
                                </div>
                            </div>
                        </div>
                            <?php
                            $rit=$_SESSION['uname'];
                            $qur=mysqli_query($con,"select * from adminlogin WHERE Username='$rit'");
                            $user=mysqli_fetch_array($qur);
                            if($user['right'] == 1 ) { ?>
                                <div class="form-group col-lg-12 text-right padding-top-m">
                                    <button type="submit" class="btn btn-primary" id="validateButton1">Add Restourant</button>
                                </div>
                            <?php }  else { ?>
                                <div class="form-group col-lg-12 text-right padding-top-m">
                                    <button type="button" class="btn btn-primary" onclick="right()"  id="validateButton1">Add Restaurant</button>
                                </div>
                                <?php }  ?>
                    </div>
                </form>

0 个答案:

没有答案