| re: problem with mysqp
////////////////////////////home.php starts here///////////////////////////////////////////////////
<?php
$host="localhost";
$mysql_user="root";
$password="";
$database="library";
$link = @mysql_connect($host,$mysql_user,$password) or $conn="error";
@mysql_select_db($database,$link);
mysql_query("SET NAMES utf8");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<script>
function show()
{
alert(document.getElementById('submit').value);
location.href='homeview.php';
}
function getthis(){
if(document.form.bkname.value=='')
{
alert('Please enter the name of the book');
document.form.bkname.focus();
return false;
}
if(document.form.bkauther.value=='')
{
alert('Please enter the name of the auther');
document.form.bkauther.focus();
return false;
}
if(document.form.bkprice.value=='')
{
alert('Please enter the cost of the book');
document.form.bkprice.focus();
return false;
}
if(document.getElementById('submit').value)
{
var n1 = document.getElementById('bkname').value;
var n2 = document.getElementById('bkauther').value;
var n3 = document.getElementById('bkprice').value;
var n4 = document.getElementById('bkava').selectedIndex;
var n5 = document.getElementById('bkava').options[n4].text;
//var n5 = document.getElementById.options[n4].value;
//alert(n4);
//location.href='hfirst1.php?display='+display.repla ce('&','%26')+'&chkbr='+chkbr;
location.href='homeentry.php?n1='+n1+'&n2='+n2+'&n 3='+n3+'&n5='+n5;
alert('You have successfully inserted!!!!');
}
//alert(document.getElementById('submit').value);
}
</script>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {font-size: 24px}
-->
</style>
</head>
<body bgcolor="#000033">
<form method="post" name="form" action="">
<table width="1005" align="center"><tr><td colspan="5" bordercolor="#FFFFFF"><div align="left">
<h2><strong><span
style="font-size:xx-large; color:#FFFFFF;">Book Entry</span></strong></h2>
</div></td>
</tr>
<tr><td colspan="5"> </td></tr>
<tr><td colspan="5"> </td></tr>
<tr><td width="190"> </td>
<td width="180"> </td>
<td width="217"> </td>
<td width="153"> </td>
<td width="241"><a href="homeview.php"><img src="btn_view.gif" width="85" height="24" border="0" /></a></td>
</tr>
<tr><td colspan="5"> </td>
</tr></table>
<table width="457" height="228" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
<tr>
<td width="164" height="47"> <div align="center" class="style1">Book Name </div></td>
<td width="293"><div align="center"><input type="text" name="bkname" size="40" id="bkname" value="<?php echo $bkname?>"></div></td>
</tr>
<tr>
<td><div align="center" class="style1">Auther</div></td>
<td><div align="center"><input type="text" name="bkauther" size="40" id="bkauther" value="<?php echo $bkauther?>"></div></td>
</tr>
<tr>
<td><div align="center" class="style1">Price</div></td>
<td><div align="center"><input type="text" name="bkprice" size="40" id="bkprice" value="<?php echo $bkprice?>"></div></td>
</tr>
<tr>
<td height="44"><div align="center" class="style1">Available</div></td>
<!-- <td><div align="center"><input type="text" name="bkava" id="bkava" value=""></div></td> -->
<td><div align="center"><select name="bkava" size="1" id="bkava">
<option selected>yes</option>
<option>no</option>
</select>
</div></td>
</tr>
<tr>
<td><div align="center"></div></td>
<td><div align="center"><input type="submit" name="submit" value="save" id="submit" onClick="return getthis()"></div></td>
</tr>
</table>
<div align="left"></div>
</form>
</body>
</html>
///////////////////////////////home.php ends here/////////////////////////////////////
///////////////////homeentry.php starts here///////////////////////////////////
<?php
$host="localhost";
$mysql_user="root";
$password="";
$database="library";
$link = @mysql_connect($host,$mysql_user,$password) or $conn="error";
@mysql_select_db($database,$link);
mysql_query("SET NAMES utf8");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$n1=$_REQUEST["n1"];
$n2=$_REQUEST["n2"];
$n3=$_REQUEST["n3"];
$n5=$_REQUEST["n5"];
//$sql= mysql_query("insert into bk_entry(bkname,bkauther,costofbk,available) values('$n1','$n2','$n3','$n5')");
$sql=mysql_query("INSERT INTO library.bk_entry (bkname, bkauther, costofbk, available) VALUES ('$n1', '$n2', '$n3', '$n5');");
?>
</body>
</html>
/////////////////////////////ends here/////////////////////////////////////////////
|