tags:

views:

101

answers:

4
<?php

require ("../Application.php");//session_start(); included in this file
 //init();
 ?>
 <?php
 $_SESSION['message']='';
 echo $_SESSION['key'].":".isset($_POST['submit']).":".$_POST['key'];
 if(isset($_POST['submit']) && ($_SESSION['key'] == $_POST['key'])){
submit();
 }

 function submit(){
echo "submitted";
 }

 ?>
 <?php include("includes/headers.php");?>

 <div class="main">
 <h1>Employee Details</h1>
 <div class="message"><?=$_SESSION['message'];?></div>
 <form name="adduser" action="add.php" method="POST">
 <div class="fileds">
 <div><label for="code">Employe code<i>(6 digit)</i></label></div> <input type="text" name="code" maxlength="6" id="code" />
 </div>


 <div class="fileds">
 <div><label for="fname">First Name</label></div> <input type="text" name="fname" />
 </div>

 <div class="fileds">
 <div><label for="mname">Middle Name</label></div> <input type="text" name="mname" />
 </div>

 <div class="fileds">
 <div><label for="lname">Last Name</label></div> <input type="text" name="lname" />
 <div><label for="father_name">Father's Name</label></div> <input type="text"       name="father_name" />
 <div class="fileds">
 Status: <select name="status" >
 <option value="1">Active</option>
 <option value="0">Inactive</option>
 </select>
 </div>
 <?php
 $key=md5(rand(0,9999999));
 $_SESSION['key']=$key;
 //echo "<br>".$_SESSION['key'];
 ?>
 <input type="hidden" name="key" value="<?=$key?>" />
 <br><br>
 <input type="submit" name="submit" value="Save" >&nbsp;&nbsp;&nbsp;<input type="reset" name="clear all" value="clear all" />
 </div>

 </form>
 </div>
 <?php include("includes/footer.php");?>

Form is not submitting, dont know what happend. It was working earlier but now.. :(

any please check this, where am wrong???? Edit

A: 

you are missing form action - point it to the script!

dusoft
action to the same page
coderex
anwyay, you should have a script name there.
dusoft
ps: remove reset button, it is not important and you will only confuse users by having it there. use fieldset(s) instead of div(s), be semantically correct.
dusoft
A: 

Try changing

<form name="adduser" action="" method="POST">

to

<form name="adduser" action="<script name>" method="POST">

or the name of your script.

David Christiansen
A: 

Are you trying to post this form using JavaScript?

If that is the case you should change the name of your submit input, because it conflicts with submit() method. JS just doesn't know if it should use input.submit property or input.submit() method.

Change this to something like:

<input type="submit" name="mySubmit" value="Save" >

and it should start working.

RaYell
A: 

You may also want to try

$phpself = $_SERVER["PHP_SELF"];
 echo '<form name="adduser" action="$phpself" method="POST">';

Though I find this works for me too

Try a last ditch

echo "<pre>".print_r($_POST, true)."</pre>";

To see what's happen behind the scene.

Extrakun