views:

365

answers:

3

hi there, i have this files:

JAVASCRIPT

$(document).ready(function(){
    $('a').click(function(){
        $('div').load("formular.html",function(){
            $('input[type="submit"]').click(function(){
                $('form').submit(); 
            });
        });
    });
});

formular.html

<form action="gigi.php" name='formular' method="post" enctype="multipart/form-data" />
    <input type="file" name="fisier" />
    <input type="submit" value="trimite" />

main html file

<a href="#">click</a>
<div></div>

PHP(gigi.php)

$nume = $_FILES['fisier']['tmp_name'];
print $nume;

what I'm trying to do is to load the formular.html on "a" click, and then to submit the imported form. BUT..if I'm not using the submit() method and I try to click the submit button...NOTHING happens (it won't load the gigi.php in the browser). Using the submit method, it looks like the form is submitted (the gigi.php is loaded in the browser) but the form data is not passed to php page (so i get the "undefined index..." error). This is an example with a file input, but I tried with text too... and it still doesn't work. SO I REALLY NEED HELP :D thanks guys

+4  A: 

Look closely at your form declaration

<form action="gigi.php" name='formular' method="post" enctype="multipart/form-data" />

Note /> at the end of it. It means you have empty form, no form fields, no submit button. They do not relate to this form in any way.

Instead, try this:

<form action="gigi.php" name='formular' method="post" enctype="multipart/form-data">
    <input type="file" name="fisier" />
    <input type="submit" value="trimite" />
</form>
vava
A: 

Hai salut! :)

Try closing your form tag in formular.html. Oh, I now see from the other response (which arrived in the meantime) that you were actually submitting an empty form because you were closing it on the line you opened it.

kitsched
A: 

so crazy! for 6 years i used your version...but about one year ago i tried to validate a html page with W3C validator and i was adviced to use my current version...and it works just fine! i never thought that this could be the problem :)) i spent half a day trying to find something "huge" , i can't belive this :)) thanks so much @vava for your almost instant answer, you saved my day :P

kmunky
Use comments for discussions. And you can also 'accept' correct answer :)
vava
ok,i accepted it :D (i'm new to stackoverflow :P )
kmunky