Hello, I am using Jquery's ajax $.POST to insert a form into the database.I'm having 2 issues: For some reason the radio input on the gender won't insert into the database.The other input fields do work. And then II can't display the data after insertion into a div .
The Javascript:
<script type ="text/javascript">
function put(){
$.post('data2.php', { iname:form.iname.value, age:form.age.value, gender:form.gender.value },
function (putout) {
('#idata').html(putout).show();
});}
</script>
The page data2.php
<?php
$iname=$_REQUEST['iname'];
$age=$_REQUEST['age'];
$gender=$_REQUEST['gender'];
mysql_connect("localhost", "root" , "") or die(" Can't connect !");
mysql_select_db("test");
$insert = mysql_query ("INSERT INTO users (name , age , gender) VALUES ('$iname' , '$age' , '$gender')");
$dbname = mysql_query ("SELECT * FROM users WHERE '$iname' = name");
while($row = mysql_fetch_assoc($dbname))
{echo $row['name'];}
And the HTML :
Name <input type = "text" name = "iname"/></br>
Age <input type = "text" name = "age"/></br>
Gender <input type="radio" name="gender" value="male"/> : Male
<input type="radio" name="gender" value="female"/> : Female <br/>
<input type = "button" value = "Insert" onclick = "put();"/>
<div align = "left" id = "idata">
</div>