I really need help with my code! The code is supposed to add data input from html to mysql's database. There is a bug in it, and since I am a beginner, I don't know what is actually happening. If a data is coded into the script it adds to the database ok, but it doesn't add from html.
This is my code:
<head>
<title>Donation Entry</title>
</head>
<body>
<h1>Donation New Entry</h1>
<?php
$username = "afriyit"; $dbname = "afriyit"; $password = " ";
//$db = mysql_connect("", "afriyit", " ");
$db = mysql_connect( "", $username, $password);
mysql_select_db( $dbname, $db);
$sql = "SELECT * FROM donations";
<?php
$username = "afriyit"; $dbname = "afriyit"; $password = " ";
//$db = mysql_connect("", "afriyit", "pen2down");
$db = mysql_connect( "", $username, $password);
mysql_select_db( $dbname, $db);
$sql = "SELECT * FROM donations";
$result = mysql_query( $sql, $db) or die( "<p>Query Error!<br><b>".mysql_error
echo"<tr><td>".$row["donor_fullname"]."</td>";
mysql_select_db("donations",$db);
$sql3 = "INSERT INTO donations (donor_fullname, donor_organisation, donor_address
$result = mysql_query($sql3);
if ($result) {
echo mysql_affected_rows(). "details inserted into database.";
$result = mysql_query($sql);
if ($result) {
echo mysql_affected_rows(). "detail inserted into database.";
}
echo "Thank you! Information entered.\n";
?>
This is my html code:
<HEAD>
<TITLE>DONATION</TITLE
</HEAD>
<BODY>
<h2><p align="center"><b>Donations Page</b></p></h2>
<HR>
<P>
Please fill in the form </P>
<FORM ACTION="http://www.sbu.ac.uk/php-cgiwrap/~afriyit/test.php" METHOD= "post">
<!--webbot bot="SaveResults" U-File="formrslt.htm" S-Format="HTML/D
B-Label-Fields="TRUE" --><P>
<font size="3" face="Times New Roman">
Donation</font> </P>
<BLOCKQUOTE>
<TABLE height="262">
<TR>
<TD ALIGN="right" height="25">
<input type=hidden name="donor_id" values="<?echo $Donation;?>"
<font size="3" face="Times New Roman">Name</font></TD>
<TD height="25">
<font size="3" face="Times New Roman">
<INPUT TYPE=TEXT NAME="DonorFullName" SIZE=35>
</font>
</TD>
</TR>
<TR>
<TD ALIGN="right" height="25">
<font size="3" face="Times New Roman">Organization</font></TD>
<TD height="25">
<font size="3" face="Times New Roman">
<INPUT TYPE=TEXT NAME="DonorOrganization" SIZE=35>
</font>
</TD>
</TR>
<TR>
<TD ALIGN="right" height="25">
<font size="3" face="Times New Roman">Address</font></TD>
<TD height="25">
<font size="3" face="Times New Roman">
<INPUT TYPE=TEXT NAME="DonorAddress" SIZE=35>
</font>
</TD>
</TR>
<TR>
<TD ALIGN="right" height="25">
<font size="3" face="Times New Roman">Town</font></TD>
<TD height="25">
<font size="3" face="Times New Roman">
<INPUT TYPE=TEXT NAME="DonorTown" SIZE=35>
</font>
</TD>
</TR>
<TR>
<TD ALIGN="right" height="25">
<font size="3" face="Times New Roman">Zip Code</font></TD>
<TD height="25">
<font size="3" face="Times New Roman">
<INPUT TYPE=TEXT NAME="DonorZipCode" SIZE=12 MAXLENGTH=12>
</font>
</TD>
</TR>
<TR>
<TD ALIGN="right" height="25">
<font size="3" face="Times New Roman">Country</font></TD>
<TD height="25">
<font size="3" face="Times New Roman">
<INPUT TYPE=TEXT NAME="DonorCountry" SIZE=25>
</font>
</TD>
</TR>
<TR>
<TD ALIGN="right" height="25">
<font size="3" face="Times New Roman">Telephone</font></TD>
<TD height="25">
<font size="3" face="Times New Roman">
<INPUT TYPE=TEXT NAME="Donortelephone" SIZE=25 MAXLENGTH=25>
</font>
</TD>
</TR>
<TR>
<TD ALIGN="right" height="25">
<font size="3" face="Times New Roman">Email</font></TD>
<TD height="25">
<font size="3" face="Times New Roman">
<INPUT TYPE=TEXT NAME="DonorEmail" SIZE=25>
</font>
</TD>
</TR>
<TR>
<TD ALIGN="right" height="15">
<font size="3" face="Times New Roman">Date</font></TD>
<TD height="25">
<font size="3" face="Times New Roman">
<INPUT TYPE=TEXT NAME="Date" SIZE=25>
</font>
</TD>
</TR>
</TABLE>
</BLOCKQUOTE>
<P>
</P>
<P>
</P>
<BLOCKQUOTE>
<TR>
<TD ALIGN="right">
<TABLE>
</BLOCKQUOTE>
<font size="3" face="Times New Roman">
<INPUT TYPE=SUBMIT VALUE="Submit">
<INPUT TYPE=RESET VALUE="Reset Form">
</font>
</FORM>
<p align="center"><a href="http://www.sbu.ac.uk/~afriyit/index.html">Return to Main</a></p>
</body>
</TR>
I hope you guys may come up with something.
Thank You very much.