PHP Submit button doesn't have any effect.

Okay so I was making a code, the code is given below. Now whenever I click on the submit button, the page loads and nothing happens. The same form is displayed again and no results are displayed as per the code.

My code is:

What may be the issue here? I can't use POST as PHPStorm POST code doesn't work. Any help why the page loads but doesn't echo the result and remains same as it is?

    Creating a Table!

.h1 {text-align: center}




if(isset($_GET['button_create'])) {

$conn = mysqli_connect("localhost","root","");

if(!conn) {
    die("Connection failed!");


$tablename = $_POST['table_name'];

$row1name = $_POST['row1_name'];
$row1input = $_POST['row1_input'];
$row1length = $_POST['row1_length'];

$row2name = $_POST['row2_name'];
$row2input = $_POST['row2_input'];
$row2length = $_POST['row2_length'];

$row3name = $_POST['row3_name'];
$row3input = $_POST['row3_input'];
$row3length = $_POST['row3_length'];

$sql = "CREATE TABLE $tablename (".
    "$row1name $row1input($row1length),".
    "$row2name $row2input($row2length),".
    "$row3name $row3input($row3length) )";

$retval = mysqli_query($conn,$sql);

if(!$retval) {
    echo("Error. Queries couldn't be done <br />").mysqli_error();

echo("Table created successfully! <br />");
echo("Follow the navigation window below now! <br />");



else {



    Creating a Table!


<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="get">
            <td>Enter your Table Name:</td>
            <td><input type="text" name="Table name" id="table_name"/></td>
            <td>Row 1 Name:</td>
            <td><input type="text" name="Row 1 name" id="row1_name"/></td>
            <td>Row 1 INPUT TYPE: <br/>
                <input type="text" name="Row 1 INPUT TYPE" id="row1_input"/></td>
            <td>Row 1 LENGTH: <br/>
                <input type="text" name="Row 1 INPUT LENGTH" id="row1_length"/></td>


            <td>Row 2 Name:</td>
            <td><input type="text" name="Row 2 name" id="row2_name"/></td>
            <td>Row 2 INPUT TYPE: <br/>
                <input type="text" name="Row 2 INPUT TYPE" id="row2_input"/></td>
            <td>Row 2 LENGTH: <br/>
                <input type="text" name="Row 2 INPUT LENGTH" id="row2_length"/></td>

            <td>Row 3 Name:</td>
            <td><input type="text" name="Row 3 name" id="row3_name"/></td>
            <td>Row 3 INPUT TYPE: <br/>
                <input type="text" name="Row 3 INPUT TYPE" id="row3_input"/></td>
            <td>Row 3 LENGTH: <br/>
                <input type="text" name="Row 3 INPUT LENGTH" id="row3_length"/></td>
            <td><input type="submit" name="Submit" id="button_create" value="Create Table!"></td>


    <a href="landing_page.phtml"><input type="button" value="Go back to landing page!"/> </a>
    <a href="insert%20table.phtml"><input type="button" value="Insert values into table!"/></a>



1 comment
Comment actions Permalink

Hi there,

The problem is in your code (form uses GET and not POST) and has nothing to do with PhpStorm -- you will get the same result in another IDE/editor.

Same on StackOverflow:


Please sign in to leave a comment.