0

hello i am a novice user
i could not pass the value(text) into database from listbox
i tried using get method but it is not working
can anybody help me????????
here is my code

<head>
<style>
#margin_left{margin-left:400px;
height:400px;}
#spanning{margin-left:70px;}
#spanning_gender{margin-left:66px;}
#spanning_marstatus{margin-left:27px;}
#spanning_city{margin-left:82px;}
#spanning_country{margin-left:62px;}
#spanning_religion{margin-left:63px;}
#spanning_crime{margin-left:74px;}
#spanning_crimetype{margin-left:39px;}
#table{border:thick;border-color:#09F;}
#insert{margin-left:140px;}
#foot{
    background:none;}
</style>
</head>
<body>
<?php 
include('database.php');
include('commonheader.php');
?>
<form method="get" name="queries" action="queryverify.php">
<h3 align="center"><font face="Tahoma, Geneva, sans-serif" color="#6C6">Queries</font></h3>
<div id="margin_left"><table id="table"  border="1"cellpadding="10">
<tr>
<td>
Name: <span id="spanning"><input type="text" name="name" size="30"></span><br/>
Gender:<span id="spanning_gender"><select id="gender" size="1"><option value="r">male</option><option value="m">female</option></select></span><br/>
Marital Status:<span id="spanning_marstatus"><select size="1" id="marstatus"><option value="f">Married</option><option value="g">Unmarried</option><option value="h">Unknown</option></select></span><br/>
City: <span id="spanning_city"><input type="text" name="city" size="30"></span><br/>
Country:<span id="spanning_country"><input type="text" name="country" size="30"></span><br/>
Religion:<span id="spanning_religion"><input type="text" name="religion" size="30"></span><br/>
Crime:<span id="spanning_crime"><select id="crime" size="1"><option value="a">Murder</option></select></span><br/>
Crime Type:<span id="spanning_crimetype"><select id="crimetype"  size="1"><option value="b">Half Murder</option></select></span>
</td>
</tr>
</table>
<div id="insert"><input type="submit" name="Insert" value="Insert"></div>
</div>
</form>
<?php include('footer.php');?>
<br />
<br/>
</body>



####queryverify.php#####################
<?php
                   $name = $_GET['name'];
                   $gender=$_GET['gender'];
                   $marstatus=$_GET['marstatus'];
                   $city=$_GET['city'];
                   $country=$_GET['country'];
                   $religion=$_GET['religion'];
                   $crime=$_GET['crime'];
                   $crimetype=$_GET['crimetype'];
                   include('database.php');
                 $query="insert into criminal values('NULL','".$name."','".$religion."','".$marstatus."','".$city."','".$country."','".$crime."','".$crimetype."')";
                   mysql_query($query) or die ('Error Cannnot Insert Records!'); 
               ?>

Edited by Dani: Formatting fixed

2
Contributors
1
Reply
4
Views
6 Years
Discussion Span
Last Post by qazplm114477
0

try adding a name to each select

ex

<select id="gender" name = "gender" size="1"><option value = "M">M</option>
</select>

<?php 
     $_GET['gender']//this will now have the "option value" of M
     //also note: if it's a list box and not a dropdown, you can select multiple options by adding an attribute name = "example[]"

?>

the problem may be because you're calling the $_[GET] with the id.

Edited by qazplm114477: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.