Jump to content

insert data in table through forms


drekha

Recommended Posts

I am not able to insert data in my database through forms.Please help .I expect this site is very active in helping newbies..

My code is :
form.php

<?php
echo"
<html>

<form name=\"AccessInterface\" action=\"process.php\" method=post>
DoctorsID:<input name=\"DoctorsID\" type=\"text\" size=\"25\" ><br>
Organization:<input name=\"Organization\" type=\"text\" size=\"25\" ><br>
password:<input name=\"password\" type=\"text\" size=\"25\" ><br>
<input type=Submit value=\"insert\">
</form>
</html>
";
?>



process.php

<html>
<?php
$cn=odbc_connect('doctordb','root',' ');
echo"connected";
if(!$cn)
Error_handler("nop connection",$cn);

$query="Select * from Table1";
$cr=odbc_exec($cn,$query);
$nbrow=0;
while( odbc_fetch_row( $cr )) {
$nbrow++;

echo"<tr><th>DoctorsID</th><th>Organization</th><th>password</th></tr>\n";
$DoctorsID=odbc_result($cr,1);
$Organization=odbc_result($cr,2);
$password=odbc_result($cr,3);
echo"<tr><td>$DoctorsID</td><td>$Organization</td><td>$password</td></tr>\n";
}
odbc_close($cn);
exit();
$cn=odbc_connect('doctordb','root',' ');
$query1="Insert into Table1 values('$DoctorsID'],'$Organization','$password)";
$cr1=odbc_exec($cn,$query1);
odbc_close($cn);
?>
</html>



Link to comment
https://forums.phpfreaks.com/topic/3513-insert-data-in-table-through-forms/
Share on other sites

  • 7 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.