0

I am using following code.

1) When one of fields with required attribute is not filled up And we try to submit form, It is showing that certain empty field is required and stops further proceeding till fill up that field.

BUT

2) When all fields are filled up,Submit button doesn't work and Form is NOT getting submitted.

On clicking Submit button, Nothing happens...

===============================================================

CODE Before HTML Coding :

<?php
 include("db.php"); // contains start_session()...

if($_POST['action']=="registration"){

        $all_columns[]="country";
        $all_columns[]="state";
        $all_columns[]="city";

        $all_values[]=addslashes($_POST["country"]);
        $all_values[]=addslashes($_POST["state"]);
        $all_values[]=addslashes($_POST["city"]);
        .....

       //remaining code to insert data in mysql database.....

 }
 ?>

FORM

<form name="myForm" id="myForm" method="post" action="" enctype="multipart/form-data">

<input type="hidden" name="action" value="registration" />

<input type="text" name="country" value="" required/>
<input type="text" name="state" value="" required/>
<input type="text" name="city" value="" required/>

<input type="submit" value="SUBMIT FORM" id="register" name="register" class="link-button-blue">
</form>

Error Log in cpanel showing : Undefined index: action in /home/username/public_html/.... on line 4

  • "***On clicking Submit button, Nothing happens...***" 99% of the time this means that your script contains errors. To enable error reporting to your php code append `error_reporting(E_ALL); ini_set('display_errors', '1');` at the top of your script, what does it return ? – Pedro Lobito May 01 '16 at 22:44
  • 1
    When you load the page, before submitting form, `$_POST['action']` is not defined. Change `if($_POST['action']=="registration")` to `if( isset( $_POST['action'] ) && $_POST['action'] == "registration" )`. Then I guess that the issue is in *remaining code to insert data in mysql database* – fusion3k May 01 '16 at 22:46
  • action="" with fushion3k answer. – Prem Bikram Limbu May 01 '16 at 23:12

0 Answers0