Friday 15 May 2015

php - How to send two different actions in a form, with one submit button -



php - How to send two different actions in a form, with one submit button -

this question has reply here:

javascript: send multiple submitions 4 answers

i have 1 actions sends info journals.php , sec actions sends info uploads.php file. how can 1 submit button.

if show illustration awesome :)

<form id="login" action="journal.php?journal=journals&id=<?php echo $opened['id']; ?>" method="post" role="form"> <div class="form-group"> <label for="title">title</label> <input class="form-control" type="text" name="title" id="title" value="<?php echo $opened['title']; ?>" placeholder="title"> </div> <div class="form-group"> <label for="body">body</label> <textarea class="form-control" name="body" id="body" rows="14" placeholder="body"><?php echo $opened['body']; ?></textarea> </div> <button type="submit" id="loginsubmit" class="btn btn-default">save</button> <input type="hidden" name="submitted" value="1"> <?php if(isset($opened['id'])) { ?> <input type="hidden" name="id" value="<?php echo $opened['id']; ?>"> <?php } ?> </form> <form action="uploads.php" enctype="multipart/form-data"> <input type="file" name="file"> </form>

i have tried create script.

<script type="text/javascript"> $(document).ready(function() { $("#login").click(function(e) { e.preventdefault(); $.ajax({ type: "post", url: "uploads.php", datatype: "html", data: $("#loginsubmit").serialize(), success: function(data) { } }); $("#loginsubmit").submit(); }); }); </script>

you can submit text form ajax, wait come successfully, , submit file form regularly.

or

you can create single action file , include journal.php , uploads.php in it.

php html forms action

No comments:

Post a Comment