Kasani Prabhakar
Kasani Prabhakar

Reputation: 109

Retrieving data by accepting its input dynamically

My Html File

<!DOCTYPE html>
<html>
<head>
<script>
function myfun(){
var x,y,z;
x=document.input.name.value;
if((x=="")||(x==null))
{
alert("Please Enter Your Name");
document.input.name.focus();
return false;
}
y=document.input.hallticket.value;
if((y=="")||(y==null))
{
alert("Please Enter Your Hallticket");
document.input.hallticket.focus();
return false;
}
z=document.input.dob.value;
if((z=="")||(z==null))
{
alert("Please Enter Your Dob");
document.input.dob.focus();
return false;
}


}
</script>
<style>
h1{
text-align:center;
}
#header{
background-color:#985544;
}
#left{
background-color:#789564;
}
#center{
background-color:#888999;
}
#body{
background-image:url(bodyback.png);
}
#right{
background-color:#789564;
}
</style>
</head>
<body id="body" style=" no-repeat">
<div id="header" style="height:100px;width:100%">
</div>
<marquee>Welcome to CSE-A Website</marquee>
<div>
<div id="left" style="height:1000px;width:10%;float:left">
</div>
<div id="center" style="height:px;width:80%;float:left">
<h1>CSE-A</h1>   
<p>Here you can check your details in this site :)</p>

<form name="input" action="data.php" id="searchform">
Name: <input type="text" name="name">
HallticketNo: <input type="text" name="hallticket">
Dob:<input type="date" name="dob">
<Input onclick="return myfun();" type="Submit" name="Submit" value="Search" id="n3"/>
</form>

</div>
<div id="right" style="height:1000px;width:10%;float:left">
</div>
</div>
</body>
</html>

My Php file :

<?php
$con=mysqli_connect("localhost","prabha","prabha","cvsr");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM details WHERE hallticket='$_GET["hallticket"]'");

while($row = mysqli_fetch_array($result)) {
  echo $row['name'] . " " . $row['hallticket'];
  echo "<br>";
}
?>

When i submit the form it showing like this error

Parse error: parse error, expecting T_STRING' orT_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\New folder\data.php on line 8

Actually i am trying to retrieve the name,halltickets if i submit value dynamically by checking with hallticket, Please tell me what is the problem

Upvotes: 0

Views: 40

Answers (1)

undefined_variable
undefined_variable

Reputation: 6228

$hallticket = $_GET["hallticket"]; 
mysqli_real_escape_string($con,$hallticket); 
$result = mysqli_query($con,"SELECT * FROM details WHERE hallticket='$hallticket'"); 

Upvotes: 1

Related Questions