can anyone please help me with this code..

Last post 06-20-2008 11:31 AM by Jigzy. 3 replies.

Sort Posts:

  • can anyone please help me with this code..

    06-16-2008, 1:10 PM
    • Loading...
    • Jigzy
    • Joined on 02-10-2008, 12:32 PM
    • Multan, Pakistan
    • Posts 117

    hi, i'm newly migrating to asp.net from php.. i want to convert this PHP code in ASP.net.. i will appreciate the efforts:)

     

    <?
    $username = $_POST['username']; // get the username
    $username = trim(htmlentities($username)); // strip some crap out of it
    $file = '/home/js4hire/public_html/gafyd/data.csv'; // Here's the file. Notice the full path.

    echo check_username($file,$username); // call the check_username function and echo the results.

    function check_username($file_in,$username){
     $username=strtolower($username);
     $file = file($file_in);
     foreach ($file as $line_num => $line) {
      $line = explode(',',$line);
      $user = trim(str_replace('"','',$line[0]));
      if($username == strtolower($user)){
       return '<span style="color:#f00">Username Unavailable</span>';
      }
     }
     return '<span style="color:#0c0">Username Available</span>';
    }
    ?>

     

     

    thank U

    -Jigzy-

    Please remember to click “Mark as Answer” on the post that helps you.

    This can be beneficial to other members reading the thread.
  • Re: can anyone please help me with this code..

    06-16-2008, 5:16 PM
    Answer

    From the deepest recesses of my memory, it looks like the code takes a submitted value for a user name, then reads a csv file to see if there is a matching entry.  Since ASP.NET is not a language, it's impossible to translate as you have asked, but here's some samples of reading files in C#: http://www.mikesdotnetting.com/Article.aspx?ArticleID=52.

    By the way, I'd recommend putting the csv file into the App_Data folder.  That way it can't be browsed to and downloaded.  Where you have it at the moment leaves it completely vulnerable to this. 

     

    Regards Mike
    [MVP - ASP/ASP.NET]
  • Re: can anyone please help me with this code..

    06-17-2008, 8:13 AM
    • Loading...
    • Jigzy
    • Joined on 02-10-2008, 12:32 PM
    • Multan, Pakistan
    • Posts 117

    well sure i'll c that .... if any1 can convert it to ASP.net with C#, i dunt want 100%, atleast 50-70% of the code?

    -Jigzy-

    Please remember to click “Mark as Answer” on the post that helps you.

    This can be beneficial to other members reading the thread.
  • Re: can anyone please help me with this code..

    06-20-2008, 11:31 AM
    Answer
    • Loading...
    • Jigzy
    • Joined on 02-10-2008, 12:32 PM
    • Multan, Pakistan
    • Posts 117

    Well, i myself has converted the code.. thanks for the support guyz.

    -Jigzy-

    Please remember to click “Mark as Answer” on the post that helps you.

    This can be beneficial to other members reading the thread.
Page 1 of 1 (4 items)
Microsoft Communities
Page view counter