I'm new to Laravel. I'm getting this issue from a long while. I've added a route to a page in web.php but it is showing a blank page instead of going to that page.
Here are the routes in web.php:
Route::group(['middleware' => ['auth','admin']], function() {
//For Admin Dashboard
Route::get('/dashboard', function () {
return view('admin.dashboard');
});
//For listing users
Route::get('/users-list', function () {
return view('admin.users');
});
});
The users-list route is not working. The users.blade.php file is placed in admin folder.
I'm trying to add the path directory to url but still not working. Here is another thing I'm trying.
Navbar
<li>
<!-- <a href="{{ url('/admin/users') }}"> -->
<a href="{{ url('/users-list') }}">
<i class="now-ui-icons users_single-02"></i>
<p>Users Profiles</p>
</a>
</li>
Here is my views directory
I'm trying to access it from here but still no results, same blank page. There's something wrong which I'm not able to find out. Any suggestion will be highly appreciated.
I'll be happy to provide any sorts of other details if required.
Replace your route with below route code:
Route::get('users-list', function () {
return view('admin/users');
});
Blade file code:
<li>
<!-- <a href="{{ url('/admin/users') }}"> -->
<a href="{{ url('users-list') }}">
<i class="now-ui-icons users_single-02"></i>
<p>Users Profiles</p>
</a>
</li>
just change your url in this way
Navbar
<li>
<a href="{{ url('/admin/users-list') }}">
<i class="now-ui-icons users_single-02"></i>
<p>Users Profiles</p>
</a>
Alright everyone, thanks alot for your answers and suggestions. I think I have found my issue.
I was using a layout file for dashboard.blade.php and users-list.blade.php named master.blade.php. And issue was in that file as it was not displaying output. I've corrected it and it worked.
Here is my users.blade.php
#extends('layouts.master')
#section('title')
Users Profiles | TestWeb
#endsection
#section('content')
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h4 class="card-title"> Simple Table</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead class=" text-primary">
<th>
Name
</th>
<th>
Country
</th>
<th>
City
</th>
<th class="text-right">
Salary
</th>
</thead>
<tbody>
<tr>
<td>
Dakota Rice
</td>
<td>
Niger
</td>
<td>
Oud-Turnhout
</td>
<td class="text-right">
$36,738
</td>
</tr>
<tr>
<td>
Minerva Hooper
</td>
<td>
Curaçao
</td>
<td>
Sinaai-Waas
</td>
<td class="text-right">
$23,789
</td>
</tr>
<tr>
<td>
Sage Rodriguez
</td>
<td>
Netherlands
</td>
<td>
Baileux
</td>
<td class="text-right">
$56,142
</td>
</tr>
<tr>
<td>
Philip Chaney
</td>
<td>
Korea, South
</td>
<td>
Overland Park
</td>
<td class="text-right">
$38,735
</td>
</tr>
<tr>
<td>
Doris Greene
</td>
<td>
Malawi
</td>
<td>
Feldkirchen in Kärnten
</td>
<td class="text-right">
$63,542
</td>
</tr>
<tr>
<td>
Mason Porter
</td>
<td>
Chile
</td>
<td>
Gloucester
</td>
<td class="text-right">
$78,615
</td>
</tr>
<tr>
<td>
Jon Porter
</td>
<td>
Portugal
</td>
<td>
Gloucester
</td>
<td class="text-right">
$98,615
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="card card-plain">
<div class="card-header">
<h4 class="card-title"> Table on Plain Background</h4>
<p class="category"> Here is a subtitle for this table</p>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead class=" text-primary">
<th>
Name
</th>
<th>
Country
</th>
<th>
City
</th>
<th class="text-right">
Salary
</th>
</thead>
<tbody>
<tr>
<td>
Dakota Rice
</td>
<td>
Niger
</td>
<td>
Oud-Turnhout
</td>
<td class="text-right">
$36,738
</td>
</tr>
<tr>
<td>
Minerva Hooper
</td>
<td>
Curaçao
</td>
<td>
Sinaai-Waas
</td>
<td class="text-right">
$23,789
</td>
</tr>
<tr>
<td>
Sage Rodriguez
</td>
<td>
Netherlands
</td>
<td>
Baileux
</td>
<td class="text-right">
$56,142
</td>
</tr>
<tr>
<td>
Philip Chaney
</td>
<td>
Korea, South
</td>
<td>
Overland Park
</td>
<td class="text-right">
$38,735
</td>
</tr>
<tr>
<td>
Doris Greene
</td>
<td>
Malawi
</td>
<td>
Feldkirchen in Kärnten
</td>
<td class="text-right">
$63,542
</td>
</tr>
<tr>
<td>
Mason Porter
</td>
<td>
Chile
</td>
<td>
Gloucester
</td>
<td class="text-right">
$78,615
</td>
</tr>
<tr>
<td>
Jon Porter
</td>
<td>
Portugal
</td>
<td>
Gloucester
</td>
<td class="text-right">
$98,615
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
#endsection
And #extends('layouts.master')
#section('title')
Users Profiles | TestWeb
#endsection
#section('content')
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h4 class="card-title"> Simple Table</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead class=" text-primary">
<th>
Name
</th>
<th>
Country
</th>
<th>
City
</th>
<th class="text-right">
Salary
</th>
</thead>
<tbody>
<tr>
<td>
Dakota Rice
</td>
<td>
Niger
</td>
<td>
Oud-Turnhout
</td>
<td class="text-right">
$36,738
</td>
</tr>
<tr>
<td>
Minerva Hooper
</td>
<td>
Curaçao
</td>
<td>
Sinaai-Waas
</td>
<td class="text-right">
$23,789
</td>
</tr>
<tr>
<td>
Sage Rodriguez
</td>
<td>
Netherlands
</td>
<td>
Baileux
</td>
<td class="text-right">
$56,142
</td>
</tr>
<tr>
<td>
Philip Chaney
</td>
<td>
Korea, South
</td>
<td>
Overland Park
</td>
<td class="text-right">
$38,735
</td>
</tr>
<tr>
<td>
Doris Greene
</td>
<td>
Malawi
</td>
<td>
Feldkirchen in Kärnten
</td>
<td class="text-right">
$63,542
</td>
</tr>
<tr>
<td>
Mason Porter
</td>
<td>
Chile
</td>
<td>
Gloucester
</td>
<td class="text-right">
$78,615
</td>
</tr>
<tr>
<td>
Jon Porter
</td>
<td>
Portugal
</td>
<td>
Gloucester
</td>
<td class="text-right">
$98,615
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="card card-plain">
<div class="card-header">
<h4 class="card-title"> Table on Plain Background</h4>
<p class="category"> Here is a subtitle for this table</p>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead class=" text-primary">
<th>
Name
</th>
<th>
Country
</th>
<th>
City
</th>
<th class="text-right">
Salary
</th>
</thead>
<tbody>
<tr>
<td>
Dakota Rice
</td>
<td>
Niger
</td>
<td>
Oud-Turnhout
</td>
<td class="text-right">
$36,738
</td>
</tr>
<tr>
<td>
Minerva Hooper
</td>
<td>
Curaçao
</td>
<td>
Sinaai-Waas
</td>
<td class="text-right">
$23,789
</td>
</tr>
<tr>
<td>
Sage Rodriguez
</td>
<td>
Netherlands
</td>
<td>
Baileux
</td>
<td class="text-right">
$56,142
</td>
</tr>
<tr>
<td>
Philip Chaney
</td>
<td>
Korea, South
</td>
<td>
Overland Park
</td>
<td class="text-right">
$38,735
</td>
</tr>
<tr>
<td>
Doris Greene
</td>
<td>
Malawi
</td>
<td>
Feldkirchen in Kärnten
</td>
<td class="text-right">
$63,542
</td>
</tr>
<tr>
<td>
Mason Porter
</td>
<td>
Chile
</td>
<td>
Gloucester
</td>
<td class="text-right">
$78,615
</td>
</tr>
<tr>
<td>
Jon Porter
</td>
<td>
Portugal
</td>
<td>
Gloucester
</td>
<td class="text-right">
$98,615
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
#endsection
And master.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="apple-touch-icon" sizes="76x76" href="/assets/img/apple-icon.png">
<link rel="icon" type="image/png" href="/assets/img/favicon.png">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>
#yield('title')
</title>
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no' name='viewport' />
<!-- Fonts and icons -->
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700,200" rel="stylesheet" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<!-- CSS Files -->
<link href="{{ asset('assets/css/bootstrap.min.css') }}" rel="stylesheet" />
<link href="{{ asset('assets/css/now-ui-dashboard.css?v=1.3.0') }}" rel="stylesheet" />
<!-- CSS Just for demo purpose, don't include it in your project -->
<link href="{{ asset('assets/demo/demo.css') }}" rel="stylesheet" />
</head>
<body class="">
<div class="wrapper ">
<div class="sidebar" data-color="orange">
<!--
Tip 1: You can change the color of the sidebar using: data-color="blue | green | orange | red | yellow"
-->
<div class="logo">
<a href="http://www.creative-tim.com" class="simple-text logo-normal">
| TestWeb |
</a>
</div>
<div class="sidebar-wrapper" id="sidebar-wrapper">
#include('inc.admin_navbar')
</div>
</div>
<div class="main-panel" id="main-panel">
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-transparent bg-primary navbar-absolute">
<div class="container-fluid">
<div class="navbar-wrapper">
<div class="navbar-toggle">
<button type="button" class="navbar-toggler">
<span class="navbar-toggler-bar bar1"></span>
<span class="navbar-toggler-bar bar2"></span>
<span class="navbar-toggler-bar bar3"></span>
</button>
</div>
<a class="navbar-brand" href="#pablo">Table List</a>
</div>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navigation" aria-controls="navigation-index" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-bar navbar-kebab"></span>
<span class="navbar-toggler-bar navbar-kebab"></span>
<span class="navbar-toggler-bar navbar-kebab"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="navigation">
<form>
<div class="input-group no-border">
<input type="text" value="" class="form-control" placeholder="Search...">
<div class="input-group-append">
<div class="input-group-text">
<i class="now-ui-icons ui-1_zoom-bold"></i>
</div>
</div>
</div>
</form>
<ul class="navbar-nav">
<!-- Logout Button Starts -->
<li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
{{ Auth::user()->name }}
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ __('Logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
#csrf
</form>
</div>
</li>
<!-- Logout Button Ends -->
</ul>
</div>
</div>
</nav>
<!-- End Navbar -->
<div class="panel-header panel-header-sm">
</div>
<div class="content">
#yield('content')
</div>
<footer class="footer">
<div class="container-fluid">
<nav>
<ul>
<li>
<a href="#">
TestWeb
</a>
</li>
<li>
<a href="#">
About Us
</a>
</li>
<li>
<a href="#">
Blog
</a>
</li>
</ul>
</nav>
<div class="copyright" id="copyright">
<script>
document.getElementById('copyright').appendChild(document.createTextNode(new Date().getFullYear()))
</script>
</div>
</div>
</footer>
</div>
</div>
<!-- Core JS Files -->
<script src="{{ asset('assets/js/core/jquery.min.js') }}"></script>
<script src="{{ asset('assets/js/core/popper.min.js') }}"></script>
<script src="{{ asset('assets/js/core/bootstrap.min.js') }}"></script>
<script src="{{ asset('assets/js/plugins/perfect-scrollbar.jquery.min.js') }}"></script>
<!-- Google Maps Plugin -->
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY_HERE"></script>
<!-- Chart JS -->
<script src="{{ asset('assets/js/plugins/chartjs.min.js') }}"></script>
<!-- Notifications Plugin -->
<script src="{{ asset('assets/js/plugins/bootstrap-notify.js') }}"></script>
<!-- Control Center for Now Ui Dashboard: parallax effects, scripts for the example pages etc -->
<script src="{{ asset('assets/js/now-ui-dashboard.min.js?v=1.3.0') }}" type="text/javascript"></script>
<!-- Now Ui Dashboard DEMO methods, don't include it in your project! -->
<script src="{{ asset('assets/demo/demo.js') }}"></script>
</body>
</html>
Related
I want to use a PDF converter for my Laravel project so I thought Dompdf might be a good idea. I managed to get it to work to convert a simple invoice file. However when I wanted to structured my invoice more with tables tag and others to make it look nicer, it wouldn't convert for me and throws a:
domPDF exception: frame not found in cellmap
Here is my invoice.blade.php for reference:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Invoice</title>
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" />
</head>
<body>
<div class="container">
<div class="card">
<div class="card-header">
<span class="float-left " > <img src="{{ asset('images/Logo.png') }}" style="width:60%;" alt="No Logo"></span>
<div class="float-center">
<h4>DC Signature Livingstyle SDN BHD</h4>
<small> 1-21-01,Menara Bangkok Bank,Berjaya Central Park,No 105,Jalan Ampang,50450 Kuala Lumpur,Malaysia </small><br>
<small>603-02818821 bujishu#gmail.com www.bujishu.com </small>
</div>
<div class="float-right">
<strong>Invoice:[Invoice Number]</strong>
<br>
<strong>[Date Placeholder]</strong> <br>
<strong>Credit Term:[Cash]</strong>
</div>
</div>
<div class="card-body">
<div class="row mb-4">
<div class="col-sm-6">
<h6 class="mb-3">From:</h6>
<div>
<strong>[Panel Name]</strong>
</div>
<div>[Address 1]</div>
<div>[Address 2]</div>
<div>Email:[panel_email]</div>
<div>Phone: [panel_number]</div>
</div>
<div class="col-sm-6">
<h6 class="mb-3">To:</h6>
<div>
<strong>[Customer Name]</strong>
</div>
<div> [Shipping address 1] </div>
<div>[shipping address 2]</div>
<div>Email:[customer_email]</div>
<div>Phone: [customer_number]</div>
</div>
</div>
<div class="table-responsive-sm">
<table class="table table-striped">
<thead>
<tr>
<th class="center">No</th>
<th>Item</th>
<th>Description</th>
<th class="left">Quantity</th>
<th class="center">Unit Price (RM)</th>
<th class="right">Amount(RM)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="center">1</td>
<td class="left strong">Electrical wire</td>
<td class="left">Longest wire ever</td>
<td class="center">1</td>
<td class="left">999,00</td>
<td class="right">999,00</td>
</tr>
<tr>
<td class="center">2</td>
<td class="left">Interior design</td>
<td class="left">Instalation and Customization (cost per hour)</td>
<td class="left">20</td>
<td class="center">150</td>
<td class="right">3.000,00</td>
</tr>
<tr>
<td class="center">3</td>
<td class="left">Table</td>
<td class="left">Round table</td>
<td class="left">1</td>
<td class="center">499,00</td>
<td class="right">499,00</td>
</tr>
</tbody>
</table>
</div>
<div class="row">
<div class="col-lg-4 col-sm-5 ml-auto " >
<table class="table table-clear ">
<th><strong> Payment Received </strong></th>
<tbody>
<tr>
<td class="left">
Payment Method: xxxxxx
</td>
</tr>
<tr>
<td class="left">
Reference No: 2192012
</td>
</tr>
<tr>
<td class="left">
Amount Paid: RM10,000.00
</td>
</tr>
<tbody>
</table>
</div>
<div class="col-lg-4 col-sm-5 ml-auto">
<table class="table table-clear">
<tbody>
<tr>
<td class="left">
<strong>Subtotal</strong>
</td>
<td class="right">8.497,00</td>
</tr>
<tr>
<td class="left">
<strong>Transportation(Klang Valley)</strong>
</td>
<td class="right">xxxxx</td>
</tr>
<tr>
<td class="left">
<strong>Grand Total</strong>
</td>
<td class="right">8.497,00</td>
</tr>
<tr>
<td class="left">
<strong>Discount (20%)</strong>
</td>
<td class="right">1,699,40</td>
</tr>
<tr>
<td class="left">
<strong>Amount Paid</strong>
</td>
<td class="right">679,76</td>
</tr>
<tr>
<td class="left">
<strong>Balance Due</strong>
</td>
<td class="right">
<strong>7.477,36</strong>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<h6 style="margin-left:30%;">This invoice is computer generated,no signature is required.</h6>
</div>
</div>
</body>
</html>
Does anyone know how to resolve this?
Edit:
Validator returns this:
Error: Bad value {{ asset('css/app.css') }} for attribute href on element link: Illegal character in path segment: { is not allowed.
From line 8, column 2; to line 8, column 58
</title>↩ <link href="{{ asset('css/app.css') }}" rel="stylesheet"> ↩↩
Error: Bad value {{ asset('images/Logo.png') }} for attribute src on element img: Illegal character in path segment: { is not allowed.
From line 18, column 37; to line 18, column 111
-left " > <img src="{{ asset('images/Logo.png') }}" style="width:60%;" alt="No Logo"></span
Error: th start tag in table body.
From line 112, column 43; to line 113, column 12
e-clear ">↩ <th><stron
I have this code right here:
#foreach($products as $p)
<tr>
<td class="col-md-6">
<div class="media">
<a class="thumbnail pull-left" href="#"> <img class="media-object" src="{{URL::to($p['image'])}}" style="width: 72px; height: 72px;"> </a>
<div class="media-body">
<span style="padding-left: 20px">Pavadinimas: </span><span class="text-warning"><strong>{{$p['title']}}</strong></span>
</div>
</div>
</td>
<td class="col-md-1" style="text-align: center">
<input type="number" class="form-control" id="quantity" value="{{$p['quantity']}}">
</td>
<td class="col-md-1 text-center">
<strong>{{$p['price']}} EUR</strong>
</td>
<td class="col-md-1 text-center">
<strong>{{$p['price']*$p['quantity']}} EUR</strong>
</td>
<td class="col-md-1">
<button type="button" class="btn btn-danger">
<span class="glyphicon glyphicon-remove"></span> Pašalinti
</button>
</td>
</tr>
#endforeach
the $products is in foreach loop and I don't know how to get the all price if there're two, three or more products because I don't know how to set variable outside foreach loop. Because if I add this code in foreach loop wich is not right now added in foreach loop:
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><h5>Subtotal</h5></td>
<td class="text-right"><h5><strong> EUR</strong></h5></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><h5>Another taxes</h5></td>
<td class="text-right"><h5><strong>1.44 EUR</strong></h5></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><h3>Total</h3></td>
<td class="text-right"><h3><strong> EUR</strong></h3></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td>
<button type="button" class="btn btn-default">
<span class="glyphicon glyphicon-shopping-cart"></span> Žiūrėti kitas prekes
</button>
</td>
<td>
<button type="button" class="btn btn-success">Užsakyti
<span class="glyphicon glyphicon-play"></span>
</button>
</td>
</tr>
This code will just duplicate. So any suggestion how to get total price of all products in cart without adding this piece of code in foreach loop ?
If you are just trying the get the total of the $products collection, then try {{ $products->sum('amount'); }}
Alternatively, you could use JavaScript to dynamically update the total. If that value is then needed to be passed into a controller on form::submit, then you could store the value in a hidden input.
i have wrote a php file for data entry i am getting error on php
like undefined index my php code is
i want to insert values which are posted by different input types on form
<?php
include("$_SERVER[DOCUMENT_ROOT]/riteshproject/config.php"); ?>
<?php include("auth.php"); //include auth.php file on all secure
pages ?> <?php
$aria=$_POST['area'];
$custname=$_POST['custname'];
$mob1=$_POST['mob1'];
$mob2=$_POST['mob2'];
$flatbunglo=$_POST['flatbungalo'];
$address=$_POST['address'];
$bhk=$_POST['bhk'];
$rent=$_POST['rent'];
$diposit=$_POST['diposit'];
$sqft=$_POST['sqft'];
$floor=$_POST['floor'];
$lift=$_POST['lift'];
echo $addquery="insert into propertymaster (area,custname,mob1,mob2,proptype,address,bhk,rent,diposit,sqft,floor,lift)
values ('$aria','$custname','$mob1','$mob2','$flatbunglo','$address','$bhk','$rent','$diposit','$sqft','$floor','$lift')";
mysql_query($addquery);
?> <!DOCTYPE html> <html lang="en"> <head> <title>Shree Shree Property,kolhapur</title> <meta charset="utf-8"> <meta
name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script
src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<style>
/* Remove the navbar's default margin-bottom and rounded borders */
.navbar {
margin-bottom: 0;
border-radius: 0;
}
/* Set height of the grid so .sidenav can be 100% (adjust as needed) */
.row.content {height: 450px}
/* Set gray background color and 100% height */
.sidenav {
padding-top: 20px;
background-color: #f1f1f1;
height: 100%;
}
/* Set black background color, white text and some padding */
footer {
background-color: #555;
color: white;
padding: 15px;
}
/* On small screens, set height to 'auto' for sidenav and grid */
#media screen and (max-width: 767px) {
.sidenav {
height: auto;
padding: 15px;
}
.row.content {height:auto;} .active { background-color: #00bfff; }
}
</style> </head> <body>
<nav class="navbar navbar-inverse"> <div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Logo</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li>Home</li> <li class="current" id="dddd"><a href="../aboutus.php" >About
US</a></li> <li>Contact US</li>
<li>Add Property</li> <li>Luxarious Property</li> <li><a href="#">Property For
Sale</a></li> <li>Other Services</li>
</ul>
<ul class="nav navbar-nav navbar-right"> <li><a href="logout.php"><span class="glyphicon
glyphicon-log-in"></span>Logout</a></li>
</ul>
</div> </div> </nav> <div class="container-fluid text-center"> <div class="row content">
<div class="col-sm-2 sidenav">
<p>Link</p>
<p>Link</p>
<p>Link</p>
</div>
<div class="col-sm-8 text-left"> <html> <body> <div id="wrap2"> <form> <h4>Welcome Mr.<?php echo
$_SESSION['username']; ?>!
<td align="right">
Area:
</td>
<td style="text-align:left" width="100px">
<select name="area" id="area" value="select">
<option value="SELECT" style="display:none">SELECT</option>
<?php
$query="select code,areaname from areamaster";
$query_run=mysql_query($query);
mysql_num_rows($query_run);
while($row=mysql_fetch_assoc($query_run))
{
?>
<option value="<?php echo $row['areaname']?>"><?php echo $row['areaname']?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr class="space1">
<td width='100px' >
</td>
<td align="right">
Customer Name:
</td>
<td>
<input type="text" id="custname" name="custname" size="40">
</td>
</tr>
<tr>
<td width='100px' >
</td>
<td align="right">
Mobile No 1:
</td>
<td>
<input type="text" id="mob1" name="mob1">
</td>
</tr>
<tr>
<td width='100px' >
</td>
<td align="right">
Mobile No 2:
</td>
<td>
<input type="text" id="mob2" name="mob2">
</td>
</tr>
<tr>
<td>
</td>
<td><b>FLAT DETAILS:</b>
</td>
</tr>
<tr>
<td width='100px' >
</td>
<td align="right">
Flat/Bungalo:
</td>
<td>
<select name="flatbungalo" id="flatbungalo" value="select">
<option>Flat</option>
<option>Bungalo</option>
<option>House</option>
</select>
</td> </tr>
<tr>
<td width='100px' >
</td>
<td align="right">
Property Address:
</td>
<td><input type="text" id ="address" name ="address" size="40">
</td> </tr>
<tr>
<td width='100px' >
</td>
<td align="right">
BHK:
</td>
<td>
<select name="bhk" id="bhk" value="select">
<option>1 BHK</option>
<option>2 BHK</option>
<option>3 BHK</option>
<option>4 BHK</option>
</select>
</td> </tr>
<tr>
<td width='100px' >
</td>
<td align="right">
RENT:
</td>
<td><input type="text" id ="rent" name ="rent" size="10">
</td> </tr>
<tr>
<td width='100px' >
</td>
<td align="right">
Diposit:
</td>
<td><input type="text" id ="diposit" name ="diposit" size="10">
</td> </tr>
<tr>
<td width='100px' >
</td>
<td align="right">
SQ Ft:
</td>
<td><input type="text" id ="sqft" name ="sqft" size="10">
</td> </tr>
<tr>
<td width='100px' >
</td>
<td align="right">
Floor:
</td>
<td><input type="text" id ="floor" name ="floor" size="10">
</td> </tr>
<tr>
<td width='100px' >
</td>
<td align="right">
Lift:
</td>
<td>
<select name="lift" id="lift" value="select">
<option>Yes</option>
<option>No</option>
</select>
</td> </tr>
<tr height="20">
</tr>
<tr>
<td>
</td>
<td>
</td> <td align="left"><form method="POST"><input type="Submit" name="Add" id="add" value="Add"></form>
</td> </tr>
</table> </html> </form> </div> </body> </html>
</div>
<div class="col-sm-2 sidenav">
<div class="well">
<p>ADS</p>
</div>
<div class="well">
<p>ADS</p>
</div>
</div> </div> </div>
<footer class="container-fluid text-center"> <p>Footer Text</p>
</footer>
</body> </html>
i had echo my query and i got result like insert into propertymaster
(area,custname,mob1,mob2,proptype,address,bhk,rent,diposit,sqft,floor,lift)
values ('','','','','','','','','','','','') basically blank values
are inserting
i want to insert values which are posted by different input types from form
the thing is happening is blank values are assigning to vauables;
for eg i wrote $aria=$_POST['area']; $aria="blank"
please help me to solve this problem
You've got several problems according to the code you posted:
You've got two opening <html> tags and two opening <body> tags.
You've got two opening <form> tags before your submit button, which is invalid HTML, probably leading to your submit button not belonging to the form with all of your inputs, so when you hit the submit button, none of your inputs are sent with it. Forms are not nestable. To fix this error, remove the second opening <form> tag, making it one form.
Before you use any input coming from a user such as GET and POST variables, you should check for their existence, typically with the isset() function such as:
if (isset($_POST['aria'])) { $aria = $_POST['aria']; }
You should NEVER put user input directly into a SQL statement. That is extremely vulnerable to a SQL injection attack. You should use prepared statements and bind your parameters.
For example, instead of using:
$addquery="insert into propertymaster (area,custname) values ('$aria','$custname')";
mysql_query($addquery);
You should instead use:
$stmt = $db->prepare("INSERT INTO propertymaster (area,custname) VALUES (':aria',':custname')";
$stmt->bindParams(':aria', $aria);
$stmt->bindParams(':custname', $custname);
$stmt->execute();
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I'm having trouble inserting a simple row into a mysql database.
My code is:
<?php
include("$_SERVER[DOCUMENT_ROOT]/riteshproject/config.php");
include('../config.php')
?>
<?php
if(isset($_POST['Add'])) {
$query1="INSERT INTO flatmaster(flat) VALUES ('123')";
mysql_query($query1);
}?>
<input type="Submit" name="Add" id="add" value="Add">
I want to insert the row into the flatmaster table when I click on submit.
my whole code is
<?php
include("$_SERVER[DOCUMENT_ROOT]/riteshproject/config.php");
include('../config.php') ?>
<?php
/*if(isset($_POST['Add'])) {
$aria=$_POST['area'];
$custname=$_POST['custname'];
$mob1=$_POST['mob1'];
$mob2=$_POST['mob2'];
$flatbunglo=$_POST['flatbungalo'];
$address=$_POST['address'];
$bhk=$_POST['bhk'];
$rent=$_POST['rent'];
$diposit=$_POST['diposit'];
$sqft=$_POST['sqft'];
$floor=$_POST['floor'];
$lift=$_POST['lift'];
echo $addquery="insert into propertymaster (area,custname,mob1,mob2,proptype,address,bhk,rent,diposit,sqft,floor,lift)
values ('$aria','$custname','$mob1','$mob2','$flatbunglo','$address','$bhk','$rent','$diposit','$sqft','$floor','$lift')";
mysql_query($addquery);
}*/
if(isset($_POST['Add'])) {
$query1="INSERT INTO flatmaster(flat) VALUES ('123')"; mysql_query($query1);
}
?> <!DOCTYPE html> <html lang="en"> <head> <title>Shree Shree Property,kolhapur</title> <meta charset="utf-8"> <meta
name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script
src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<style>
/* Remove the navbar's default margin-bottom and rounded borders */
.navbar {
margin-bottom: 0;
border-radius: 0;
}
/* Set height of the grid so .sidenav can be 100% (adjust as needed) */
.row.content {height: 450px}
/* Set gray background color and 100% height */
.sidenav {
padding-top: 20px;
background-color: #f1f1f1;
height: 100%;
}
/* Set black background color, white text and some padding */
footer {
background-color: #555;
color: white;
padding: 15px;
}
/* On small screens, set height to 'auto' for sidenav and grid */
#media screen and (max-width: 767px) {
.sidenav {
height: auto;
padding: 15px;
}
.row.content {height:auto;} .active { background-color: #00bfff; }
}
</style> </head> <body>
<nav class="navbar navbar-inverse"> <div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Logo</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li>Home</li> <li class="current" id="dddd"><a href="../aboutus.php" >About
US</a></li> <li>Contact US</li>
<li>Add Property</li> <li>Luxarious Property</li> <li><a href="#">Property For
Sale</a></li> <li>Other Services</li>
</ul>
<ul class="nav navbar-nav navbar-right"> <li><a href="logout.php"><span class="glyphicon
glyphicon-log-in"></span>Logout</a></li>
</ul>
</div> </div> </nav> <div class="container-fluid text-center"> <div class="row content">
<div class="col-sm-2 sidenav">
<p>Link</p>
<p>Link</p>
<p>Link</p>
</div>
<div class="col-sm-8 text-left"> <html> <body> <div id="wrap2"> <form> <?php include("auth.php"); //include auth.php file on all
secure pages ?> <h4>Welcome Mr.<?php echo $_SESSION['username'];
?>!</h4> </form> <form> <html>
<body>
<table>
<tr>
<td width='100px' >
</td>
<td align="right">
Area:
</td>
<td style="text-align:left" width="100px">
<select name="area" id="area" value="select">
<option value="SELECT" style="display:none">SELECT</option>
<?php
$query="select code,areaname from areamaster";
$query_run=mysql_query($query);
mysql_num_rows($query_run);
while($row=mysql_fetch_assoc($query_run))
{
?>
<option value="<?php echo $row['code']?>"><?php echo $row['areaname']?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr class="space1">
<td width='100px' >
</td>
<td align="right">
Customer Name:
</td>
<td>
<input type="text" id="custname" name="custname" size="40">
</td>
</tr>
<tr>
<td width='100px' >
</td>
<td align="right">
Mobile No 1:
</td>
<td>
<input type="text" id="mob1" name="mob1">
</td>
</tr>
<tr>
<td width='100px' >
</td>
<td align="right">
Mobile No 2:
</td>
<td>
<input type="text" id="mob2" name="mob2">
</td>
</tr>
<tr>
<td>
</td>
<td><b>FLAT DETAILS:</b>
</td>
</tr>
<tr>
<td width='100px' >
</td>
<td align="right">
Flat/Bungalo:
</td>
<td>
<select name="flatbungalo" id="flatbungalo" value="select">
<option>Flat</option>
<option>Bungalo</option>
<option>House</option>
</select>
</td> </tr>
<tr>
<td width='100px' >
</td>
<td align="right">
Property Address:
</td>
<td><input type="text" id ="address" name ="address" size="40">
</td> </tr>
<tr>
<td width='100px' >
</td>
<td align="right">
BHK:
</td>
<td>
<select name="bhk" id="bhk" value="select">
<option>1 BHK</option>
<option>2 BHK</option>
<option>3 BHK</option>
<option>4 BHK</option>
</select>
</td> </tr>
<tr>
<td width='100px' >
</td>
<td align="right">
RENT:
</td>
<td><input type="text" id ="rent" name ="rent" size="10">
</td> </tr>
<tr>
<td width='100px' >
</td>
<td align="right">
Diposit:
</td>
<td><input type="text" id ="diposit" name ="diposit" size="10">
</td> </tr>
<tr>
<td width='100px' >
</td>
<td align="right">
SQ Ft:
</td>
<td><input type="text" id ="sqft" name ="sqft" size="10">
</td> </tr>
<tr>
<td width='100px' >
</td>
<td align="right">
Floor:
</td>
<td><input type="text" id ="floor" name ="floor" size="10">
</td> </tr>
<tr>
<td width='100px' >
</td>
<td align="right">
Lift:
</td>
<td>
<select name="lift" id="lift" value="select">
<option>Yes</option>
<option>No</option>
</select>
</td> </tr>
<tr height="20">
</tr>
<tr>
<td>
</td>
<td>
</td> <td align="left"><form method="POST"><input type="Submit" name="Add" id="add" value="Add"></form>
</td> </tr>
</table> </html> </form> </div> </body> </html>
</div>
<div class="col-sm-2 sidenav">
<div class="well">
<p>ADS</p>
</div>
<div class="well">
<p>ADS</p>
</div>
</div> </div> </div>
<footer class="container-fluid text-center"> <p>Footer Text</p>
</footer>
</body> </html>
You need to wrap your submit button inside a form and use POST to send data:
<?php
if(isset($_POST['Add'])) {
$query1="INSERT INTO flatmaster(flat) VALUES ('123')";
mysql_query($query1);
}
?>
<form method="POST">
<input type="Submit" name="Add" id="add" value="Add">
</form>
Warning! Your code is vulnerable to SQL Injection Attacks! How do I prevent SQL Injection Attacks?
so i have this html table:
$table = '<table cellpadding="0" cellspacing="0" class="calendar">
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tue</th>
<th>Wed</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td> </td>
<td data-date="12/01/2014">
<div class="wrapper">
<div class="day">1</div>
</div>
</td>
<td data-date="12/02/2014">
<div class="wrapper">
<div class="day">2</div>
</div>
</td>
<td data-date="12/03/2014">
<div class="wrapper">
<div class="day">3</div>
</div>
</td>
<td data-date="12/04/2014" class="green">
<div class="wrapper">
<div class="day">4</div>
</div>
</td>
<td data-date="12/05/2014" class="green">
<div class="wrapper">
<div class="day">5</div>
</div>
</td>
<td data-date="12/06/2014" class="green">
<div class="wrapper">
<div class="day">6</div>
</div>
</td>
</tr>
<tr>
<td data-date="12/07/2014" class="green">
<div class="wrapper">
<div class="day">7</div>
</div>
</td>
<td data-date="12/08/2014" class="green">
<div class="wrapper">
<div class="day">8</div>
</div>
</td>
<td data-date="12/09/2014" class="green">
<div class="wrapper">
<div class="day">9</div>
</div>
</td>
<td data-date="12/10/2014" class="green">
<div class="wrapper">
<div class="day">10</div>
</div>
</td>
<td data-date="12/11/2014" class="green">
<div class="wrapper">
<div class="day">11</div>
</div>
</td>
<td data-date="12/12/2014">
<div class="wrapper">
<div class="day">12</div>
</div>
</td>
<td data-date="12/13/2014">
<div class="wrapper">
<div class="day">13</div>
</div>
</td>
</tr>
</table>';
i want to get the date inside data-date property in tag <td> which has no property class="green". the valid results expected are:
12/01/2014
12/02/2014
12/03/2014
12/12/2014
12/13/2014
(they are not have property class="green")
this my code:
preg_match_all('/<td[^>]*data-date="(.*?)">(.*?)<\/td>/', $table, $tag, PREG_PATTERN_ORDER);
print_r($tag);
however the regex i used is still match with tag <td> which has property class="green". since i want to exclude theme, what is the correct regex?
need your advise, thank you for helping.
<td[^>]*data-date="[^"]*"(?:(?!class="green"|>).)*>(.*?)<\/td>
Try this.See demo.
https://regex101.com/r/dU7oN5/9
I try this :
/<td[^>]*data-date="([0-9\/]+)">(.*?)<\/td>/s
and it looks like it does the job,
Use https://fr.functions-online.com/preg_match_all.html to test your regexp ;)
Sorry for my english