Thank you so much for your response. I made the changes to my script and read the string that you suggested, but now I get a different set of errors. I am following the examples from the 'PHP fast and easy' book, which probably needs to be updated. Here is the html and php codes --
Code: Select all
<HTML>
<HEAD>
<TITLE>Create a Database Table: Step 1</TITLE>
</HEAD>
<BODY>
<H1>Step 1: Name and Number</H1>
<FORM METHOD="POST" ACTION="do_showfielddef.php">
<P><strong>Table Name:</strong><br>
<INPUT TYPE="text" NAME="table_name" SIZE=30></p>
<P><strong>Number of Fields:</strong><br>
<INPUT TYPE="text" NAME="num_fields" SIZE=5></p>
<P><INPUT TYPE="submit" NAME="submit" VALUE="Go to Step 2"></p>
</FORM>
</BODY>
</HTML>
and
Code: Select all
<?php
if (($_REQUESTї'table_name']) or ($_REQUESTї'num_fields'])) {
header( "Location: http://localhost/test/show_createtable.html");
exit;
}
$form_block = "
<FORM METHOD="POST" ACTION="do_createtable.php">
<INPUT TYPE="hidden" NAME="table_name" VALUE="table_name">
<TABLE CELLSPACING=5 CELLPADDING=5>
<TR>
<TH>FIELD NAME</TH><TH>FIELD TYPE</TH><TH>FIELD LENGTH</TH></TR>
";
// create form fields on the fly
for ($i = 0 ; $i <$num_fields; $i++) {
$form_block .= "
<TR>
<TD ALIGN=CENTER><INPUT TYPE="text" NAME="field_nameї]" SIZE="30"></TD>
<TD ALIGN=CENTER>
<SELECT NAME="field_typeї]">
<OPTION VALUE="char">char</OPTION>
<OPTION VALUE="date">date</OPTION>
<OPTION VALUE="float">float</OPTION>
<OPTION VALUE="int">int</OPTION>
<OPTION VALUE="text">text</OPTION>
<OPTION VALUE="varchar">varchar</OPTION>
</SELECT>
</TD>
<TD ALIGN=CENTER><INPUT TYPE="text" NAME="field_lengthї]" SIZE="5"></TD>
</TR>
";
}
$form_block .= "
<TR>
<TD ALIGN=CENTER COLSPAN=3><INPUT TYPE="submit" VALUE="Create Table"></TD>
</TR>
</TABLE>
</FORM>
";
?>
<HTML>
<HEAD>
<TITLE>Create a Database Table: Step 2</TITLE>
</HEAD>
<BODY>
<H1>Define fields for<?echo "table_name";?></H1>
<?echo "$form_block";?>
</BODY>
</HTML>
the error which I now get is:
Notice: Undefined variable: num_fields in F:\Apache Group\Apache2\htdocs\test\do_showfielddef.php on line 20
Define fields fortable_name
I can see that table_name and num_fields have never been defined-- so I guess my question is -- where should I define my values, since the first thing that the php script needs to do is check that the values were actually entered for $table_name and $num_fields?
thanks again for your help
rosana