SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    May 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question login using stored procedure with 2 in 4 out help

    Hi,
    I am rather rusty with my php coding and I am trying to create a login using a stored procedure with 2 in and 4 output variables. sp_LoginApplication. . with these ins and outs
    IN:
    p_userName VARCHAR
    p_userPassword VARCHAR

    OUT:
    p_result INT
    p_idIntitution INT
    p_nameInstitution VARCHAR
    p_userProfile INT

    Here is the code I have
    PHP Code:
    <?php

    // Inialize session
    session_start();

    // Include database connection settings
    include('config.inc');

    // Retrieve username and password from database according to user's input
    //$login = mysql_query("SELECT * FROM user WHERE (p_userName = '" . mysql_real_escape_string($_POST['username']) . "') and (p_userPassword = '" . mysql_real_escape_string(md5($_POST['password'])) . "')");
    $login mysql_query('CALL sp_loginApplication($_POST['username'], $_POST['password'], $loginResult, $idinstitution, $nameinstitution, $userprofile)');
    // Check username and password match
    if (mysql_num_rows($login) == 1) {
            
    // Set username session variable
            
    $_SESSION['username'] = $_POST['username'];
            
    // Jump to secured page
            
    header('Location: securedpage.php');
    }
    else {
            
    // Jump to login page
            
    header('Location: index.php');
    }

    ?>
    I keep getting a Parse error: syntax error, unexpected T_STRING in /homepages/37/d89354651/htdocs/tek/test/Portal/examples/loginproc.php on line 11

    Any help would be great. . .
    Thanks

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,343
    Mentioned
    192 Post(s)
    Tagged
    4 Thread(s)
    I don't have experience with Stored Procedures.
    But, the Syntax Error can be squelched with this change:
    PHP Code:
    $login mysql_query('CALL sp_loginApplication(' $_POST['username'] . ',' $_POST['password'] . ',' $loginResult ',' $idinstitution ',' $nameinstitution ',' $userprofile ')'); 
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  3. #3
    SitePoint Member
    Join Date
    May 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks that cleared that one, and now I have other issues.
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /homepages/37/d89354651/htdocs/tek/test/Portal/examples/loginproc.php on line 13

    Warning: Cannot modify header information - headers already sent by (output started at /homepages/37/d89354651/htdocs/tek/test/Portal/examples/loginproc.php:13) in /homepages/37/d89354651/htdocs/tek/test/Portal/examples/loginproc.php on line 21


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
  •