- This topic is empty.
May 16, 2013 at 4:10 am #44814
i hav this form in index.php
then i want to send the values to login.php
process the data with mysql in login.php
and return the value / errors or data to index .php and display itMay 16, 2013 at 5:12 am #135258bizzr3Member
hey , in the login.php change action attribute of form to index.php and then in the index.php you can get the value of input boxes with $_POST , something like this :
$username = $_POST;
and process the $username and all variables like this.May 16, 2013 at 6:45 am #135264
@bizzr3 there is no form in login.php just a php – my sql script for checking the username and passwordMay 16, 2013 at 7:04 am #135269May 16, 2013 at 7:15 am #135273
well i created a form before and was able to chk and log in and echo my data but then php sql form all were on a same page…May 16, 2013 at 7:28 am #135277
well i just successfully sent the data to the login.php via method post
actually the echo was getting hidden under the form so neva noticed it
so now i need to send
$error or $success to index.phpMay 16, 2013 at 8:34 am #135281
I believe the best way to accomplish this is with AJAX.
Data is entered into the form and on clicking submit, instead of being taken to login.php, data is sent to login.php behind the scenes, the data is processed and returned to index.php as you wish, all seemingly in an instant without leaving index.phpMay 16, 2013 at 8:36 am #135282
This can be done quite easily using jQuery and the jQuery form plugin, http://malsup.com/jquery/form/May 16, 2013 at 8:47 am #135284CrocoDillonParticipant
I think AJAX would be a good solution too. I don’t see why you’re not just posting to index.php, check if there is $_POST data and if there is, include login.php to handle that data.
If you really want to post to login.php without using AJAX you could use session variables to set the return value/errors and redirect to index.php using the header. Then in index.php read those session variables.May 16, 2013 at 9:17 am #135288
> I believe the best way to accomplish this is with AJAX.
well i havnt used ajax yet so i dont know the method of using it….
@crocodillion i succesfully did it using $_SESSION variables but i wanted to know just one more thing that can i send those errors which initially i am echoing thru $_SESSION variableMay 21, 2013 at 7:22 am #135821
AJAX is certainly a tool worth having if you’re pursuing web development
- The forum ‘Back End’ is closed to new topics and replies.