Professional Web Applications Themes

'Return values' from links - PHP Development

First of all, Hi! I just started getting into php a week ago, but already ran into a problem I can't seem to solve. The issue is this : I code 2 different websites, each has it's own mySQL-DB. Website A has a login-section, each time you successfully log in, a key is generated which stays only valid for a certain period of time (done via database). Now, I have a link from the login section on website A to a sign-up-form on website B. This sign-up is supposed to only be accessible if you have a valid key from ...

  1. #1

    Default 'Return values' from links

    First of all, Hi!
    I just started getting into php a week ago, but already ran into a problem I
    can't seem to solve.
    The issue is this : I code 2 different websites, each has it's own mySQL-DB.
    Website A has a login-section, each time you successfully log in, a key is
    generated which stays only valid for a certain period of time (done via
    database).
    Now, I have a link from the login section on website A to a sign-up-form on
    website B. This sign-up is supposed to only be accessible if you have a valid
    key from website A, which qualifies you as a member.
    Website B lets you fill out the form no matter what key you offer it, but
    when you have finished, right before I insert the data into my DB, I want it to
    check back with website A whether the key is valid or not.

    That's where I'm stuck right now.
    I have a php file in website A's directory, which, when given a key value,
    will check whether it is valid or not. Is there any way I can treat this
    website like a function and have it give me a return value after it has "run
    through" ?
    I tried it by putting a header from B to validate.php on A, and have that
    only call the 'exit;' when a valid key is provided, but it seems to proceed
    with website B's code no matter what the header to website A does.

    Is there any other way or workaround that I can accomplish this ? I just
    need a link to that validation page, and after the link the code should proceed
    or not based on the "return value" from that link.

    By the way, I work with php3, so I hope there's a solution for that version
    ;)
    Thanks in advance for any help, I hope my english wasn't too bad for you to
    understand what I meant.

    --
    NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien...
    Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService

    Jetzt kostenlos anmelden unter http://www.gmx.net

    +++ GMX - die erste Adresse für Mail, Message, More! +++
    akroeger1@gmx.de Guest

  2. #2

    Default Re: [PHP] 'Return values' from links

    On Fri, 17 Oct 2003 08:54:23 +0200 (MEST), you wrote:
     

    Yes; some kind of Remote Procedure Call protocol (eg SOAP) is designed for
    this. But the lightweight way would be something like:

    function get_token_validity ($token)
    {
    $token = 'token=' . rawurlencode ($token); // armour message for sending
    $host = 'www.webserverA.com';
    if (($sp = fsockopen ($host, 80)) == FALSE)
    {
    return (NULL);
    }

    fputs ($sp, "POST /path/to/script.php HTTP/1.0\r\n");
    fputs ($sp, "Host: $host\r\n");
    fputs ($sp, "Content-type: application/x-www-form-urlencoded\r\n");
    fputs ($sp, "Content-length: " . strlen ($token) . "\r\n\r\n");
    fputs ($sp, "$token\r\n");

    $result = NULL;
    while (!feof ($sp)) {
    $a = fgets ($sp);
    if (is_numeric ($a))
    {
    if ($a == FALSE)
    {
    $result = FALSE;
    } else {
    $result = TRUE;
    }
    }
    }

    fclose ($sp);
    return ($result);
    }

    Untested, but it should be pretty close. Returns TRUE on a valid result,
    FALSE on invalid and NULL on error.

    The paired script on www.webserverA.com should just echo(1) or echo(0) for a
    good or bad result.
     

    /Ah/. I have to ask... why?

    I have no idea whether the above code will run on PHP 3.
    David Guest

  3. #3

    Default Re: 'Return values' from links

    Some XML would do the trick

    pete

    de wrote: 
    Pete Guest

  4. #4

    Default Re: [PHP] 'Return values' from links

    > fputs ($sp, "POST /path/to/script.php HTTP/1.0\r\n"); 

    Sorry. That should be HTTP/1.1, of course.
    David Guest

Similar Threads

  1. Return two values Form Validation
    By DDhillon in forum Coldfusion - Getting Started
    Replies: 1
    Last Post: September 1st, 08:02 PM
  2. SQL - return only certain values?
    By Lurk Master Flex in forum PHP Development
    Replies: 2
    Last Post: December 1st, 08:32 PM
  3. #26343 [Bgs]: Function does not return any values at all.
    By ccetanr at nus dot edu dot sg in forum PHP Development
    Replies: 0
    Last Post: November 21st, 09:01 AM
  4. function return values
    By sinister in forum PHP Development
    Replies: 11
    Last Post: November 18th, 01:34 PM
  5. Getting return values to PHP from external VB-program
    By Henrik Olsen in forum PHP Development
    Replies: 0
    Last Post: October 1st, 11:24 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139