PHPJack77 Posted June 22, 2006 Share Posted June 22, 2006 It seems like whenever I submit a form to the same page using the code...$_SERVER['PHP_SELF']as the form action, the page just clears out the form data and the page will never fully load (the status bar says: "(1 item remaining) opening page..."). Here is an example of code that I have been trying to get working, but can not due to this very reason.Any idea as to why this is not working? <?php $self = $_SERVER['PHP_SELF']; $fields = $POST['fields']; $db = $POST['db']; $name = $POST['name']; $table = $POST['table']; $type = $POST['type']; $size = $POST['size']; if( !$fields and !$db ) { $form ="<form action=\"$self\" method=\"post\">"; $form.="How many fields are needed in the new table?"; $form.="<br /><input type=\"text\" name=\"fields\">"; $form.="<input type=\"submit\" value=\"submit\">"; echo( $form ); } else if( !$db ) { $form ="<form action=\"$self\" method=\"post\">"; $form.="Database: <input type=\"text\" name=\"db\"><br />"; $form.="Table Name: <input type=\"text\" name=\"table\"><br />"; for ( $i = 0; $i < $fields; $i++ ) { $form.="Column Name: <input type=\"text\" name=\"name[$i]\">"; $form.="Type: <select name=\"type[$i]\">"; $form.="<option value=\"char\">char</option>"; $form.="<option value=\"int\">int</option>"; #Add Other Options HERE Later $form.="</select> "; $form.="Size:<input type=\"text\" name=\"size[$i]\">"; } $form.="<input type=\"submit\" value=\"Submit\">"; $form.="</form>"; echo( $form ); } else { #Make the connection to mysql $conn = @mysql_connect ("sample@sampledomain.com", "SampleUsername", "SamplePassword") or die("Err:conn"); #Select the specified database $rs = "create table $table ("; for ($i = 0; $i < count($name); $i++) { #Field name and data type $sql .= "$name[$i] $type[$i]"; #Allow size specification for char and varchar types if ( ($type[$i] == "char") or ($type[$i] == "varchar") ) { #If the size has been specified add to the query if ($size[$i] != "") { $sql.= "($size[$i])"; } } #If this is not the final field add a comma if ( ($i+1) != count($name) ) { $sql.=","; } } $sql .= ")"; #Display SQL Query echo("SQL Command: $sql <hr>"); #Execute the query - attempt to create the table $result = mysql_query($sql,$conn) or die("Err:Query"); #Confirm if successful if ($result) { echo("Result: Table \"$table\" has been created"); } }?> Link to comment Share on other sites More sharing options...
justsomeguy Posted June 22, 2006 Share Posted June 22, 2006 $fields = $POST['fields']; $db = $POST['db']; $name = $POST['name']; $table = $POST['table']; $type = $POST['type']; $size = $POST['size'];The array for POST data is $_POST, not $POST. Link to comment Share on other sites More sharing options...
PHPJack77 Posted June 22, 2006 Author Share Posted June 22, 2006 The array for POST data is $_POST, not $POST.<{POST_SNAPBACK}> ahhhhh.... you very smart Danial son No really, Thank you very much. You're a great asset to this forum and I really appreciate the help you have given me! Link to comment Share on other sites More sharing options...
justsomeguy Posted June 22, 2006 Share Posted June 22, 2006 Thanks, my pleasure. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now