php indefined index error trouble - php

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();

Related

Is it possible to use media queries with a php file?

I am trying to make my site responsive and my media query was working but now it isn't. I made some changes and didn't use version control because I'm an idiot. Now I've taken out all the changes and the old media query isn't working, can anyone see why? I've included my css and the html I'm applying it to.
.contact_form {
margin: auto auto auto 27%;
}
.slides p {
margin: 2%;
text-align: center;
}
.slides h2 {
text-align: center;
font-size: 1.5em;
}
.required {
color: red;
}
.privacy p {
width: 60%;
text-align: center;
margin: auto;
}
#media screen and (max-width: 500px) {
.slides h2 {
text-align: center;
font-size: 1em;
margin: 10% auto auto auto;
}
.slides h1 {
text-align: center;
font-size: 2em;
margin: auto;
}
.contact_form {
margin: 2%;
}
.privacy p {
width: 90%;
text-align: center;
margin: auto;
}
.tablet_content {
display: none;
}
}
Html
<body>
<div class="banner">
<header>
<div id="ytWidget"></div>
<script src="https://translate.yandex.net/website-widget/v1/widget.js?widgetId=ytWidget&pageLang=en&widgetTheme=dark&autoMode=true" type="text/javascript"></script>
<br clear = "all">
<a href="index.html">
<h1>Laura Pohl Web Solutions</h1>
<h2>User Based Web Design</h2>
</a>
</header>
</div>
<div class="topnav" id="myTopnav">
Home
<div class="dropdown">
<button class="dropbtn">About</button>
<div class="dropdown-content">
My Story
Mascots
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Portfolio</button>
<div class="dropdown-content">
Custom Web Design
Wordpress
<!--Wix
Squarespace-->
</div>
</div>
FAQ
Contact
<a href="javascript:void(0);" class="icon" onclick="myFunction()">
<i class="fa fa-bars"></i>
</a>
</div>
<main class="site-content">
<div class="gradient">
<br>
<div class="slide">
<div class="main">
<div class="slides">
<h1>Contact Questionnaire</h1>
<h2>If you’d like to work with me, I can’t wait to get started! Your first step is to fill out the custom form below.</h2>
<br>
<br>
</div>
</div>
<div class = "contact_form">
<form name="form4" action="Contact Us.php" method="post">
<input type = "hidden" name ="recipient" value ="1">
<input type = "hidden" name ="subject" value ="Contact Survey">
<input type = "hidden" name ="print_blank_fields" value ="1">
<input type="hidden" name="_pid" value="154040">
<input type="hidden" name="_fid" value="A7QPIZEA">
<table class ="contact_table">
<tbody>
<!--Row 1-->
<tr>
<td class = "questions">Name:<span class="required">*</span></td>
<td colspan = "6"><input name="sender" id="name" type="text" maxlength="30" class ="input_text_box required" title="Please type your name." required></td>
</tr>
<!--Row 2-->
<tr>
<td class = "questions">Email:</td>
<td colspan = "6"><input name="senderEmail" type="text" maxlength="30" class ="input_text_box"></td>
</tr>
<!--Row 3-->
<tr>
<td class = "questions">Phone:</td>
<td colspan = "6"><input name="senderPhone" type="text" id="textfield2" maxlength="30"class ="input_text_box"></td>
</tr>
<!--Row 4-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 5-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 6-->
<tr>
<td class = "questions" rowspan="2">Preferred Method of Contact?</td>
<td><input type="radio" name="preferredContact" value="phone" id="PreferredContact_0"></td>
<td colspan = "2" width = "30%">Phone</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<!--Row 7-->
<tr>
<td><input type="radio" name="preferredContact" value="email" id="PreferredContact_2"></td>
<td colspan = "2">Email</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<!--Row 8-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 9-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 10-->
<tr>
<td class = "questions" rowspan="2">Would you like a response?<span class="required">*</span></td>
<td><input type="radio" name="Response" value="Yes" id="PreferredContact_2"></td>
<td colspan = "2">Yes</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<!--Row 11-->
<tr>
<td><input type="radio" name="Response" value="No" id="PreferredContact_3"></td>
<td>No</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<!--Row 12-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 13-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 14-->
<tr>
<td class = "questions" rowspan="7">What would you like to talk about?<span class="required">*</span></td>
<td><input type="radio" name="topic" value="web_design"></td>
<td colspan = "5">Website Design</td>
</tr>
<!--Row 15-->
<tr>
<td><input type="radio" name="topic" value="re_design"></td>
<td colspan="5">Website Re-Design</td>
</tr>
<!--Row 16-->
<tr>
<td><input type="radio" name="topic" value="consultation"></td>
<td colspan="6">Schedule a Consultation</td>
</tr>
<!--Row 17-->
<tr>
<td><input type="radio" name="topic" value="quote"></td>
<td colspan="6">Request a Quote</td>
</tr>
<!--Row 18-->
<tr>
<td><input type="radio" name="topic" value="suggestions"></td>
<td colspan="6">Suggestions</td>
</tr>
<!--Row 19-->
<tr>
<td><input type="radio" name="topic" value="problems"></td>
<td colspan="6">Site Problems</td>
</tr>
<!--Row 20-->
<tr>
<td><input type="radio" name="topic" value="something_else"></td>
<td colspan="6">Something Else</td>
</tr>
<!--Row 21-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 22-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 23-->
<tr>
<td class = "questions" style="vertical-align:middle;">Message Text: </td>
<td colspan = "6" style="text-align: left">
<textarea rows = "5" name="message" maxlength="800" id="Comments" class ="input_text_box" required></textarea>
</td>
</tr>
<!--Row 24-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 25-->
<tr>
<td colspan = "7"> </td>
</tr>
<!--Row 26-->
<tr>
<td><input name="submit" type="submit" id="submit" title="Submit" value="Submit" style = "float:left"></td>
<td colspan = "5"> </td>
<td><input type="reset" name="reset" id="reset" value="Reset" style = "float:right"></td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</div>
<br clear = "all">
<br>
<div class="privacy">
<hr style="width: 20%;">
<p>I take your privacy seriously. I will never share any of your
information with anyone outside legal requirements. You will never be spammed or marketed
to by any of my partners.</p>
<hr style="width: 20%;">
</div>
</main>
<div class="big_screen_content">
<footer>
<!--start footer-->
© November 30, 2020 · Laura Pohl · Billerica, MA <!--Copyright signature-->
</footer>
<!--end footer-->
</div>

php record not inserting database when click on submit event [closed]

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?

How to make a drop down that include years and when a year is selected, it gets the people who registered in that year in a table using php

<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th></th>
<th>Business Name</th>
<th>Commencement Date</th>
<th>Registered?</th>
<th>Business Address</th>
<th>Contact Details</th>
<th>Contact Name</th>
<th> </th>
</tr>
</thead>
<tbody>
<?
db_connect();
$result=mysql_query("select * from hbs_participants_register ORDER BY hbs_id DESC");
$num_result=mysql_num_rows($result);
?>
<tr>
<?
for ($i=0; $i<$num_result; $i++) {
$row=mysql_fetch_array($result);
?>
<td width="10"><div align="left">
<?php echo $i+1; ?>
</div>
</td>
<td><div align="left">
<? echo $row['hbs_bus_name'] ?>
</div>
</td>
<td><div align="left">
<? echo $row['hbs_com_date'] ?>
</div>
</td>
<td><div align="left">
<? echo $row['hbs_bus_reg']; ?>
<br /> <strong><?php if (!empty($row['hbs_bus_regnumber'])) {
echo "Reg No. ".$row['hbs_bus_regnumber'];
} else {} ?></strong>
</div>
</td>
<td><div align="left">
<? echo $row['hbs_bus_address']; ?>
<br />
</div>
</td>
<td><div align="left">
<? echo $row['hbs_email']; ?>
<br />
<? echo $row['hbs_phone']; ?>
<br />
<? echo $row['hbs_url']; ?>
<br />
</div>
</td>
<td><div align="left">
<? echo $row['hbs_contact_name']; ?>
</div>
</td>
<td>
<div class="btn-group">
<button class="btn btn-small dropdown-toggle"
data-toggle="dropdown">
<i class="icon-cog"></i> <strong
style="font-size: 14px; padding: 5px 0px"> Manage</strong><span
class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a
href="../../print-busreg.php?hbs_id=<?php echo $row['hbs_id'];?>"
target="_blank"><i class="icon-list"></i> Full Details</a>
</li>
<li><a
href="?w=plugins/HBS%202015/delete-busreg&hbs_id=<?php echo $row['hbs_id'];?>&action=delete"
onclick="return confirm('Are you sure you want to delete?')"><i
class="icon-trash"></i> Delete</a>
</li>
</ul>
</div>
</td>
</tr>
<? } ?>
</tbody>
</table>
I believe this should work, assuming you are storing the data together with the year it was submitted. This is not the whole code you need, just the part which lets you select a year and get it from the Dbase.
<form method="get" action="page.php" enctype="multipart/form-data">
year:
<select name="selectedYear">
<option value="2000">2000</option>
<option value="2001">2001</option>
<option value="2002">2002</option>
<option value="2003">2003</option>
<option value="2004">2004</option>
</select>
<input type="submit" name="submit">
</form>
PHP
<?php
$year = $_GET['selectedYear'];
?>
So then you just get all the columns that contain that year:
mysql_query('"select * from hbs_participants_register WHERE year LIKE" . $year . "ORDER BY hbs_id DESC"');

Jquery not adding dynamic php

I have a basic form that submits the form data to the same page and do a simple search in a MySQL db. The php for this in before the <html> tag
<body>
<div data-role="page">
<div role="main" class="ui-content">
enter code here
<table style="width:750px;">
<form enctype="multipart/form-data" action="player_documents_m.php" method="get" data-ajax="false">
<tr style="height:35px;">
<td style="width:250px; vertical-align:top; text-align:left;">
<label for="name">Player Name: </label>
</td>
<td style="text-align:left; vertical-align:middle; text-align:center;">
<input type="text" name="name" id="name" class="inputs" size="45" value="<?php echo $my_name; ?>" maxlength="255"/>
</td>
</tr>
<tr style="height:35px;">
<td style="text-align:left; vertical-align:bottom; text-align:right;" colspan="2">
<input type="submit" name="search" id="search" value="Search Player" />
</td>
</tr>
</form>
</table>
The above works in JqueryMobile
Then the results are added dynamically with html content but this does not work in JqueryMobile but taking out all JQueryMobile related stuff and leave a normal php page everything works.
Below the table tag above I add my php to add the founded search results.
<?php
for($j = 0; $j < $i; $j++)
{
$photo = "images/" . $db_new . "/players/" . $player[$j]["player_id"] . ".jpeg";
echo "<br />";
?>
<!-- Search Results -->
<div class="singleResult" onclick="javascript: window.location.replace('load_documents.php?identification=<?php echo $player[$j]["player_id"]; ?>');">
<table border="1" style="width:100%; border: solid thin; padding:0; border-spacing:0;">
<tr>
<!-- Image 1st Column -->
<td rowspan="2" colspan="1" style="width:10%; vertical-align:top; text-align:left;">
<img src="<?php echo $photo; ?>" style="width:150px; height:180px;" />
</td>
<td class="labels">Name:
<p class="results"><?php echo $player[$j]["player_name"]; ?></p>
</td>
</tr>
</table>
</div>
<!-- End Of Search Results -->
<?php
}
?>
</div>
</div>
</body>
Now the above only works normally and not in JqueryMobile. can some please explain to me what I am doing wrong / need to add, or anything helpful please.
Thanks

I am trying to make a Edit form Using PHP

My html code but saved as Modyfyitems.php
<?include 'Login/login_check.php';?>
<?include 'inc/Application.php';?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<style type="text/css">
body {
background-color: #284489;
text-shadow: 0px 0px #FFFFFF;
color: #FFFFFF;
}
form1 {
background-color: #FFFFFF
}
</style>
<link rel="stylesheet" type="text/css" media="all" href="css/jsDatePick_ltr.min.css" />
<script type="text/javascript" src="js/jsDatePick.min.1.3.js"></script>
<script type="text/javascript">
window.onload = function(){
new JsDatePick({
useMode:2,
target:"datereceived",
dateFormat:"%d-%M-%Y"
});
};
</script>
</head>
<body>
<h2> </h2>
<form id="form1" name="form1" aling="center" method="post">
<div align="center">
<table width="393" border="0">
<tr>
<td><div align="center">
<h2><span style="text-align: left; color: #FFFFFF;">LAC Product Registery</span></h2>
</div></td>
</tr>
</table>
<p>
<input type="button" name="button4" id="button4" onClick="location.href='Menu.php'" value="Menu">
</p>
</div>
<div align="center" style="background-color: #FFFFFF; color: #000000;">
<table width="827" border="0" align="center">
<tr bgcolor="#FDFDFD">
<td width="501"><h3>Modify Items</h3>
<p>Enter Code
<input name="barcode" type="text" autofocus required="required" id="barcode" form="form1">
<input type="submit" name="search" id="search" onClick="location.href='Actions/loaditem.php'" value="Search">
</p>
<table width="500" border="0" cellpadding="10" cellspacing="1">
<tr>
<td width="141" bgcolor="#E8F1FC">Sponsor</td>
<td width="316" bgcolor="#E8F1FC"><?include 'Actions/loadLists/sponsor.php';?></td>
</tr>
<tr>
<td bgcolor="#f1f4f9">Date Received</td>
<td bgcolor="#f1f4f9"><input type="datetime" name="datereceived" value="<? echo $DateReceived; ?>" id="datereceived" placeholder="17-FEB-2014"></td>
</tr>
<tr>
<td bgcolor="#E8F1FC"><strong>Code</strong></td>
<td bgcolor="#E8F1FC"> </td>
</tr>
<tr>
<td bgcolor="#F1F4F9"><ul>
<li> Container</li>
</ul></td>
<td bgcolor="#F1F4F9"><input name="container" type="number" value="<? echo $Container; ?>" id="container" placeholder="0152"></td>
</tr>
<tr>
<td bgcolor="#E8F1FC"><ul>
<li>Pallet</li>
</ul></td>
<td bgcolor="#E8F1FC"><input name="pallet" type="number" value="<? echo $Pallet; ?>" id="number5" placeholder="0028"></td>
</tr>
<tr>
<td bgcolor="#F1F4F9"><ul>
<li>Amount</li>
</ul></td>
<td bgcolor="#F1F4F9"><input name="amount" type="number" id="number6" value="<? echo $Amount; ?>" placeholder="0002"></td>
</tr>
<tr>
<td bgcolor="#E8F1FC">Description</td>
<td bgcolor="#E8F1FC"><?include 'Actions/loadLists/descriptions.php';?></td>
</tr>
<tr>
<td bgcolor="#F1F4F9">Remarks</td>
<td bgcolor="#F1F4F9"><textarea name="remarks" id="remarks"><? echo $Remarks; ?></textarea></td>
</tr>
<tr>
<td bgcolor="#E8F1FC">Location</td>
<td bgcolor="#E8F1FC"><?include 'Actions/loadLists/locations.php';?></td>
</tr>
<tr>
<td height="18"> </td>
<td> </td>
</tr>
</table></td>
<td width="316" valign="top" style="text-align: left"><p><br>
</p>
<p> Documents</p>
<p> </p></td>
</tr>
</table>
</div>
<table width="383" border="0" align="center">
<tr>
<td width="377" style="text-align: center"><input type="button" name="button" id="button" value="Save">
...
<input type="button" name="button6" id="button6" onClick="location.href='Menu.php'" value="Cancel">
...
<input type="button" name="button2" id="button2" value="Delete">
...
<input type="button" name="button3" id="button3" value="Print Barcode"> </td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
</form>
<p> </p>
<p> </p>
</body>
</html>
Here is my PHP script
<?
$conn = mysql_connect('localhost', 'root', 'root');
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("LAC", $conn);
$Barcode =$_REQUEST['barcode'];
$result = mysql_query("SELECT * FROM Lists WHERE Barcode = '$Barcode'");
$row = mysql_fetch_array($result);
if (!$result)
{
die("Error: Data not found..");
}
$Barcode = $row['Barcode'];
$Sponsor = $row['Sponsor'];
$DateReceived = $row['DateReceived'];
$Container = $row['Container'];
$Pallet = $row['Pallet'];
$Amount = $row['Amount'];
$Description = $row['Description'];
$Remarks = $row['Remarks'];
$Location = $row['Location'];
mysql_close($conn);
?>
So Basically I am trying to load all the text boxes and drop down boxes from the database when the correct barcode is entered and the search button is hit.
For some reason when I hit the search button it doesn't load anything it just reloads the page.
I am new to php but have programming experience in vb.net
I think your are initializing variables after fetching values from the database in PHP script. so the scope of those variable is only withing that file. So, I guess if you include that file in modifyitem.php, this would work.
thank you.

Categories