i cant call a function
Posted: Sat Dec 25, 2010 3:25 am
<html>
<body>
<?php
$con=mysql_connect("localhost","root");
if(!$con)
{
echo "problem in connection".mysql_errror();
}
mysql_select_db("my_db",$con);
function inst($fn,$ln,$mn,$hn,$em)
{
mysql_query("insert into mobi_dat values('$fn','$ln','$mn','$hn','$em')");
echo '<script language="javascript">';
echo 'alert("Data addded successfully")';
echo '</script>';
}
echo '<form name=insef method=post action="">';
echo ' Enter the First Name: <input type=text name=fname style="left:200px;top:10px; position:absolute;"><br><br>';
echo ' Enter The Last Name: <input type=text name=lname style="left:200px; position:absolute;"><br><br>';
echo ' Enter The Mobile Number: <input type=text name=mnum style="left:200px; position:absolute;"><br><br>';
echo ' Enter The Home Number: <input type=text name=hnum style="left:200px;position:absolute;"><br><br>';
echo ' Enter The Email Id: <input type=text name=email style="left:200px; position:absolute;"><br><br>';
echo "<button style='left:200px; position:absolute;' onClick='inst(fname,lname,mnum,hnum,email)'>Insert</button>";
echo ' </form>';
?>
</body>
</html>
in above program i got five text field from textbox,,, i want to insert those values to database without sending data to other php file such like using post and get,,, no error in this program but values not inserted,,,,pls help me
<body>
<?php
$con=mysql_connect("localhost","root");
if(!$con)
{
echo "problem in connection".mysql_errror();
}
mysql_select_db("my_db",$con);
function inst($fn,$ln,$mn,$hn,$em)
{
mysql_query("insert into mobi_dat values('$fn','$ln','$mn','$hn','$em')");
echo '<script language="javascript">';
echo 'alert("Data addded successfully")';
echo '</script>';
}
echo '<form name=insef method=post action="">';
echo ' Enter the First Name: <input type=text name=fname style="left:200px;top:10px; position:absolute;"><br><br>';
echo ' Enter The Last Name: <input type=text name=lname style="left:200px; position:absolute;"><br><br>';
echo ' Enter The Mobile Number: <input type=text name=mnum style="left:200px; position:absolute;"><br><br>';
echo ' Enter The Home Number: <input type=text name=hnum style="left:200px;position:absolute;"><br><br>';
echo ' Enter The Email Id: <input type=text name=email style="left:200px; position:absolute;"><br><br>';
echo "<button style='left:200px; position:absolute;' onClick='inst(fname,lname,mnum,hnum,email)'>Insert</button>";
echo ' </form>';
?>
</body>
</html>
in above program i got five text field from textbox,,, i want to insert those values to database without sending data to other php file such like using post and get,,, no error in this program but values not inserted,,,,pls help me