Emergency help with user login and greeting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rpapaiof
    New Member
    • Oct 2006
    • 27

    Emergency help with user login and greeting

    i have designed a login page in this form
    <?php
    if ( $_POST[username] && $_POST[password] && $_POST[sbm]) {
    $a=file("file.t xt");
    foreach($a as $k => $v) {
    $b[]=trim($v);
    }
    #echo "<pre>"; print_r($b); echo "</pre>";
    $success="0";
    foreach($b as $k => $v) {
    $b1=split(":",$ v);
    if ( $_POST[username]==$b1[0] && $_POST[password]==$b1[1] ) { $success="1"; break;}
    } // foreach
    if ( $success==1 ) {
    header("Locatio n: include.php");
    }
    if ( $_POST[username]=="admin" && $_POST[password]=="admin32" ) {
    $success="1";
    header("locatio n:admin.php");
    break;}
    else{
    echo "<center>";
    echo "<font color=#ff0000>I nvalid Username or Password!!!</font>";
    echo "<form method=post>";
    echo "<table border=0>";
    echo "<tr bgcolor=#e0e0e0 > <td align=right>Use rname:</td> <td><input type=text name=username style='width:10 0px;'> </td></tr>";
    echo "<tr bgcolor=#e0e0e0 > <td align=right>Pas sword:</td> <td><input type=password name=password style='width:10 0px;'> </td></tr>";
    echo "<tr bgcolor=#e0e0e0 ><td colspan=2 align=center><i nput type=submit name=sbm value='Login'></td></tr>";
    echo "</table>";
    echo "</form>";
    echo "</center>";
    }
    } elseif ( !$_POST[sbm]) {
    echo "<center>";
    echo "<form method=post>";
    echo "<table border=0>";
    echo "<tr bgcolor=#e0e0e0 > <td align=right>Use rname:</td> <td><input type=text name=username style='width:10 0px;'> </td></tr>";
    echo "<tr bgcolor=#e0e0e0 > <td align=right>Pas sword:</td> <td><input type=password name=password style='width:10 0px;'> </td></tr>";
    echo "<tr bgcolor=#e0e0e0 ><td colspan=2 align=center><i nput type=submit name=sbm value='Login'></td></tr>";
    echo "</table>";
    echo "</form>";
    echo "</center>";
    } else {
    echo "<center>";
    echo "<font color=#ff0000>P lease Fill The Username And Password!!</font>";
    echo "<form method=post>";
    echo "<table border=0>";
    echo "<tr bgcolor=#e0e0e0 > <td align=right>Use rname:</td> <td><input type=text name=username style='width:10 0px;'> </td></tr>";
    echo "<tr bgcolor=#e0e0e0 > <td align=right>Pas sword:</td> <td><input type=password name=password style='width:10 0px;'> </td></tr>";
    echo "<tr bgcolor=#e0e0e0 ><td colspan=2 align=center><i nput type=submit name=sbm value='Login'></td></tr>";
    echo "</table>";
    echo "</form>";
    echo "</center>";
    }
    ?>
    it get user name and password and check if it exist in our txt file or not if it exist it load this page
    <head>
    </head>
    <body>
    <bgsound src="01.mp3"></bgsound>
    <table height=90% width=100% border=0 bordercolor=Red >
    <tr><td align=center>
    <table height=600 border=0 bordercolor=Gre en><tr><td></td></tr></table>
    </td><td>
    <table width=600 border=0 bordercolor=vio let><tr><td></td></tr></table>
    <table height=100% ;></table>
    <table height=99% width=100% border=1 bordercolor=blu e>
    <tr><td colspan=3 height=30><img src=logo.gif width=100%> </td></tr>
    <tr><td colspan=3 height=30><a href=Home.html> <font size=4>Home</font></a>
    &nbsp;&nbsp;&nb sp;&nbsp;<a href=contact.ht ml><font size=4>Contact</font></a>
    &nbsp;&nbsp;&nb sp;&nbsp;<a href=gal.html>< font size=4>Gallery</font></a>
    <tr><td width=150 valign=top> </td><td valign=top><cen ter><font size=8 color=blue >Thank You For Your
    Visit</font></center><form><f ont size=4 ><b>Upload Your File &nbsp;</font><input type='file'><br ><br><br><br><b r><select><opti on>Armenia
    </option><option> Iran</option><option> USA</option></select><input type=submit value='Go'></form></td><td width=150 valign=top><a href=01.jpg><im g src=01.jpg width=70 height=60></a><br><br><img src=02.jpg width=70 height=60><br>< br><img src=03.jpg width=70 height=60></td></tr>
    <tr><td colspan=3 height=40><cent er>&copy;copyri ght,Yerevan 2005,
    <br><A HREF="mailto:ro meo.p.m@gmail.c om" >romeo.p.m@gmai l.com</a>
    </td></tr>
    </table></td></tr>
    </table>
    </body>

    After 22 posts in you know you have to follow some basic rules in this forum and post your code within code, php or html tags. You are breaking the forum page! Read Posting Guidelines!! - Ronald :cool:
  • TheMadMidget
    New Member
    • Oct 2006
    • 98

    #2
    Put the username into a cookie or if this is a one page login scenario just pass it through via post. Then check if anything is there for the welcome message.

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      You could use sessions or cokies. I prefer sessions :P

      What I would do is add 'session_start( )' at the top of all your php code. It must be called before anything is sent to the browser.

      then if a user logs in successfully Id add teh username to the session thing like this '$_Session['UserName'] = $userName;'

      Now you can use this $_Session['UserName'] where ever you want.

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        I have edited your post because you are breaking the boxes!!

        Ronald :cool:

        Comment

        • rpapaiof
          New Member
          • Oct 2006
          • 27

          #5
          Originally posted by ronverdonk
          I have edited your post because you are breaking the boxes!!

          Ronald :cool:
          o i have no idea about it i will follow yout guide from this moment.

          Comment

          Working...