This is my body i want to submit more than 1 data from diffrent forms at the same time with the same button is it possible in php? i want first form send the selected one second form send the text value...
<body>
<div id="kategoriler">
<h4>Kategoriler</h4>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<select name="mydropdown">
<option value="Oteller">Oteller</option>
<option value="Restaurant">Restaurant</option>
<option value="Cafe">Cafe</option>
<option value="Bar">Bar</option>
<option value="Köy">Köy</option>
</select>
</form>
</div>
<div id ="text">
<h4>Başlik</h4>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="baslik" value="" maxlength="100" />
<h4>Açıklama</h4>
<textarea rows="30" cols="70">
Buraya yazın...
</textarea>
</form>
</div>
<div id="bresim">
<h4>Başlik Resmi</h4>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<label for="file">Resmi Seçin:</label>
<input name="uploaded" type="file" />
</form>
</div>
<div id="ekle">
<input type="submit" name="submit" value="Eklemek için tıklayın!" />
</div>
</body>
Yes.
remove the input that submits, and add a link outside every form with the javascript that submits all: (also add an ID to everyform, so you can call them via this javascript)
EDIT: this doesn't work, the only way is via AJAX, please check @Phil's answer!
One option would be forcing javascript being used: launch a javascript handler that collects the values, submits a ajax request, or even writes a form and submits it.
Jquery can easily be used to to loop through all form values.
So something like:
If you're using jQuery...
First, give your forms and submit button some IDs (I used #form1, #form2, and #submit). Then...
Edit: Here's a non-AJAX solution that takes advantage of the fact that the forms post to the same URL.
When the submit button is clicked, move/append the text input
$(input[name=baslik])
to the second form and then submit it. This solution doesn't need the jQuery Form plugin and doesn't use AJAX:Original, AJAX solution:
If you want AJAX, you can use the jQuery Form Plugin.
You can't use jQuery's
$(form).serialize()
because it does not work on file fields. This solution also assumes you want to use AJAX.