Grow your CSS skills. Land your dream job.

sending and receiving data on php

  • # May 16, 2013 at 4:10 am

    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 it

    # May 16, 2013 at 5:12 am

    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

    @bizzr3 there is no form in login.php just a php – my sql script for checking the username and password

    # May 16, 2013 at 6:51 am

    What is the flow? Is it index.php that has the form, which leads to login.php where things are processed using PHP and MySQL, and then you want the result returned to index.php?

    # May 16, 2013 at 7:04 am

    @Melindrea Yes it is as u said!

    # May 16, 2013 at 7:12 am

    Alright. How far have you gotten in what you’re trying to achieve?

    # May 16, 2013 at 7:15 am

    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

    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.php

    # May 16, 2013 at 8:34 am

    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.php

    # May 16, 2013 at 8:36 am

    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

    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

    > 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 variable

    # May 21, 2013 at 7:22 am

    AJAX is certainly a tool worth having if you’re pursuing web development

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".