Hi,
Ive created a form in html and written code in hp tht takes data feom html and stores it in MySQL database. Bt wen i click on the submit button i get an error. Instead of storing it in database it asks to open the php file which has bees specified in the action attribute of the form tag. It is being created for windows platform.
Im pasting the code of both the html and php file that ive used and plz let me know how to fix that problem.
File name:form.html
[code=html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<HEAD>
<TITLE>Form Handling with PHP</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFF F">
<FORM METHOD=POST ACTION="add.php ">
<input type="hidden" name="id" value="NULL">
<TABLE>
<TR height="20">
<TD colspan="2"><FO NT SIZE="+0" face="verdana"> Below is a Sample Form for our PHP tutorial</TD>
</TR>
<TR height="50">
<td></td>
</TR>
<TR>
<TD align="left"><F ONT SIZE="+0" face="verdana"> <b>Your Name <br>
Your E-Mail Address</b></td>
<td><INPUT TYPE="text" NAME="name">
<br>
<INPUT TYPE="text" NAME="email">
</TD>
</TR>
<tr>
<td colspan="2"><ce nter>
<SELECT NAME="opinion">
<option value="is great">I like your site</option>
<option value="is OK">Your Site is OK</option>
<option value="is horrible">Your Site is horrible</option>
</SELECT>
<INPUT TYPE="submit" value="Tell us!">
</td>
</tr>
</TABLE>
</FORM>
</BODY>
</HTML>
[/code]
Filename:add.ph p
[code=php]
<?
$DBhost = "localhost" ;
$DBuser = "root";
$DBpass = "database";
$DBName = "test";
$table = "informatio n";
mysql_connect($ DBhost,$DBuser, $DBpass) or die("Unable to connect to database");
@mysql_select_d b("$DBName") or die("Unable to select
database $DBName");
$sqlquery = "INSERT INTO $table
VALUES('$id','$ name','$email', '$opinion')";
$results = mysql_query($sq lquery);
mysql_close();
print "<HTML><TIT LE> PHP and MySQL </TITLE><BODY
BGCOLOR=\"#FFFF FF\"><center><t able border=\"0\"
width=\"500\">< tr><td>";
print "<p><font face=\"verdana\ " size=\"+0\"> <center>You
Just Entered This Information Into the
Database<p><blo ckquote>";
print "Name : $name<p>E-Mail : $email<p>Opinio n :
$opinion</blockquote></td></tr></table>
</center></BODY></HTML>";
?>
[/code]
Plz help me out as soon as possible.
Thanks
Ive created a form in html and written code in hp tht takes data feom html and stores it in MySQL database. Bt wen i click on the submit button i get an error. Instead of storing it in database it asks to open the php file which has bees specified in the action attribute of the form tag. It is being created for windows platform.
Im pasting the code of both the html and php file that ive used and plz let me know how to fix that problem.
File name:form.html
[code=html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<HEAD>
<TITLE>Form Handling with PHP</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFF F">
<FORM METHOD=POST ACTION="add.php ">
<input type="hidden" name="id" value="NULL">
<TABLE>
<TR height="20">
<TD colspan="2"><FO NT SIZE="+0" face="verdana"> Below is a Sample Form for our PHP tutorial</TD>
</TR>
<TR height="50">
<td></td>
</TR>
<TR>
<TD align="left"><F ONT SIZE="+0" face="verdana"> <b>Your Name <br>
Your E-Mail Address</b></td>
<td><INPUT TYPE="text" NAME="name">
<br>
<INPUT TYPE="text" NAME="email">
</TD>
</TR>
<tr>
<td colspan="2"><ce nter>
<SELECT NAME="opinion">
<option value="is great">I like your site</option>
<option value="is OK">Your Site is OK</option>
<option value="is horrible">Your Site is horrible</option>
</SELECT>
<INPUT TYPE="submit" value="Tell us!">
</td>
</tr>
</TABLE>
</FORM>
</BODY>
</HTML>
[/code]
Filename:add.ph p
[code=php]
<?
$DBhost = "localhost" ;
$DBuser = "root";
$DBpass = "database";
$DBName = "test";
$table = "informatio n";
mysql_connect($ DBhost,$DBuser, $DBpass) or die("Unable to connect to database");
@mysql_select_d b("$DBName") or die("Unable to select
database $DBName");
$sqlquery = "INSERT INTO $table
VALUES('$id','$ name','$email', '$opinion')";
$results = mysql_query($sq lquery);
mysql_close();
print "<HTML><TIT LE> PHP and MySQL </TITLE><BODY
BGCOLOR=\"#FFFF FF\"><center><t able border=\"0\"
width=\"500\">< tr><td>";
print "<p><font face=\"verdana\ " size=\"+0\"> <center>You
Just Entered This Information Into the
Database<p><blo ckquote>";
print "Name : $name<p>E-Mail : $email<p>Opinio n :
$opinion</blockquote></td></tr></table>
</center></BODY></HTML>";
?>
[/code]
Plz help me out as soon as possible.
Thanks
Comment