Single sign on

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ctjpn
    New Member
    • Mar 2007
    • 1

    Single sign on

    hi all,
    we are working on a single sign on project.if a user registers with our software we store his passwords in oracle database and our aim is to retrieve it and insert it on the login page when he visits the respective website.we are coding in VB.we are facing a problem in insertion of password on login page.which language should we code?can anyone provide us with a sample code ? we have thought of php but quite unsure.
    Platform-Windows XP
  • lmwasisebe
    New Member
    • Feb 2007
    • 3

    #2
    [php]
    i would advise you to code with php and maybe use MySql for your database even though you can actually connect with any database management system. What you need is"
    1.The registration form
    2.Registration form processing code
    3. Login form
    4.Login processing code which verifies users against your database

    This is a dummy registration form:
    <form name="login" method="post" action="registr ation.php">
    <table border="0" width="225" align="center">
    <tr>
    <td width="219" bgcolor="#99999 9">
    <p align="center"> <font color="white">< span style="font-size:12pt;"><b> Registration</b></span></font></p>
    </td>
    </tr>
    <tr>
    <td width="219">
    <table border="0" width="282" align="center">
    <tr>
    <td width="116"><sp an style="font-size:10pt;">Nam e:</span></td>
    <td width="156"><in put type="text" name="name" maxlength="100" ></td>
    </tr>
    <tr>
    <td width="116"><sp an style="font-size:10pt;">Ema il:</span></td>
    <td width="156"><in put type="text" name="email" maxlength="100" ></td>
    </tr>
    <tr>
    <td width="116"><sp an style="font-size:10pt;">Use rname:</span></td>
    <td width="156"><in put type="text" name="username" ></td>
    </tr>
    <tr>
    <td width="116"><sp an style="font-size:10pt;">Pas sword:</span></td>
    <td width="156"><in put type="password" name="password" ></td>
    </tr>
    <tr>
    <td width="116">&nb sp;</td>
    <td width="156">
    <p align="right">< input type="submit" name="submit" value="Submit"> </p>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td width="219" bgcolor="#99999 9">&nbsp;</td>
    </tr>
    </table>
    </form>

    Registration Processing php code"

    <?php
    $dbhost = "localhost" ;
    $dbname = "php_login" ;
    $dbuser = "root";
    $dbpass = "clemence";

    mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error() );
    mysql_select_db ($dbname) or die(mysql_error ());

    $name = $_POST['name'];
    $email = $_POST['email'];
    $username = $_POST['username'];
    $password = md5($_POST['password']);

    $checkuser = mysql_query("SE LECT username FROM users WHERE username='$user name'");

    $username_exist = mysql_num_rows( $checkuser);

    if($username_ex ist > 0){
    echo "I'm sorry but the username you specified has already been taken. Please pick another one.";
    unset($username );
    include 'registration.h tml';
    exit();
    }

    $query = "INSERT INTO users (name, email, username, password)
    VALUES('$name', '$email', '$username', '$password')";
    mysql_query($qu ery) or die(mysql_error ());
    mysql_close();

    echo "You have successfully Registered";

    $yoursite = 'www.palmarecru its.co.zw';
    $webmaster = 'Lameck';
    $youremail = 'lmwasisebe@glo tecca.co.zw';

    $subject = "You have successfully registered at $yoursite...";
    $message = "Dear $name, you are now registered at our web site.
    To login, simply go to our web page and enter in the following details in the login form:
    Username: $username
    Password: $password


    Thanks,
    $webmaster";

    mail($email, $subject, $message, "From: $yoursite <$youremail>\ nX-Mailer:PHP/" . phpversion());

    echo "Your information has been mailed to your email address.";


    ?>

    Login Page

    <form name="login" method="post" action="login.p hp">
    <table border="0" width="225" align="center">
    <tr>
    <td width="219" bgcolor="#99999 9">
    <p align="center"> <font color="white">< span style="font-size:12pt;"><b> Login</b></span></font></p>
    </td>
    </tr>
    <tr>
    <td width="219">
    <table border="0" width="220" align="center">
    <tr>
    <td width="71"><spa n style="font-size:10pt;">Use rname:</span></td>
    <td width="139"><in put type="text" name="username" ></td>
    </tr>
    <tr>
    <td width="71"><spa n style="font-size:10pt;">Pas sword:</span></td>
    <td width="139"><in put type="password" name="password" ></td>
    </tr>
    <tr>
    <td width="71">&nbs p;</td>
    <td width="139">
    <p align="right">< input type="submit" name="submit" value="Submit"> </p>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td width="219" bgcolor="#99999 9"><font color="white">N ot Registered? </font><a href="registrat ion.html" target="_self"> <font color="white">R egister</font></a><font color="white"> </font><b><i><fon t color="white">N ow!</font></i></b></td>
    </tr>
    </table>
    </form>

    Login Processing php code

    <?php
    $dbhost = "localhost" ;
    $dbname = "php_login" ;
    $dbuser = "root";
    $dbpass = "clemence";

    mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error() );
    mysql_select_db ($dbname) or die(mysql_error ());

    session_start() ;

    $username = $_POST['username'];
    $password = md5($_POST['password']);

    $result = mysql_query("SE LECT * FROM users WHERE username='$user name' and password ='$password'");

    if (mysql_num_rows ($result) != 1) {
    $error = "Bad Login";
    include "login.html ";

    } else {
    $_SESSION['username'] = $username;
    include "memberpage.php ";
    }

    ?>[/php]

    Read the Posting Guidelines before you post in this forum!.
    Especially the part about enclosing code within code or php tags!!

    moderator
    Last edited by ronverdonk; Mar 5 '07, 04:07 PM. Reason: code within tags

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      When you are unsure about the programming language to use, maybe you should decide that first before you continue on this path.

      Ronald :cool:

      Comment

      Working...