I have a bit of a problem with my website. I have phpbb integrated into my website and a login form on the homepage. This form needs to execute two different actions. It first needs to run the ucp.php (to log into phpbb) and also the login.php (to hide the form and add control panel on home screen). They both work by themselves, I just need a way to have them together when a user logs in. i have researched this for a while and can't find a solution. Thanks in advances, Josh
I need to combine this
<form action="./forums/ucp.php?mode=login" method="post" enctype="multipart/form-data">
with this
<form action="login.php" method="post" enctype="multipart/form-data">
I think you have a serious design issue in your code if you have to "merge" stuff like that, but in any case:
Just create a new file ie. post_handler.php
and toss this code in it:
<?php
include('forums/upc.php');
include('login.php');
?>
Place it in the same directory as login.php.
Then adjust your form to point to post_handler.php?mode=login
.
Ofcourse merging files like that could result in crazy unexpected results..
Another option, though more complex, would be to use the login.php
as your action and do a curl request to forums/ucp.php
inside it. (search for Curl on php.net documentation)
Unfortunately I can not give more suggestions, because what you are trying to do is probably more complex then something that can easily be answered here.
Well you can try trick with ajax. Here is an example that should work with jquery: Im not sure if preventDefaut() wont make us a problem here and we still be allowed to use .submit() on it. If it wont work. Try to put whole thing into function, remove preventDefault and bind this function into submit button.
<form id="form_id" action="login.php" method="post" enctype="multipart/form-data">
User name: <inputy type="text" id="username" name="username" />
</form>
<script type="text/javascript">
$(function() {
//we prevent normal form submit
$('#form_id').preventDefault();
var data = {} ;
//here u build data u want send by taking it from form field by field
//example
data['username'] = $('#username');
//and you send this data via ajax to your upc script
$.ajax({
type: "POST",
url: '/forums/ucp.php?mode=login',
data: data,
//in case of succes we send form normal way
success: function( xhr ) { $('#form_id').submit(); },
dataType: String
});
});
<script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.