user management, need simple php code

Discussion in 'PHP' started by justinlorder, Jun 9, 2009.

  1. #1
    hello, guys.
    I have found an easy php scripts to manage subdomains of my site.
    The script is just several pages and a form for submitting.

    The problem is many spammers are trying to submit spams from the form.
    I would like the form can only be used/submitted/managed by me.
    In other word, I would like to password protect the page. So I can manage the script and no one else/spammer can.

    I need just a couple lines of php code, no database is needed .
    Thanks for your help. Gurus .
     
    justinlorder, Jun 9, 2009 IP
  2. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #2
    it wouldnt be a couple lines of code. If it was you could've found it on the Internet lol.

    You'd be better of using a database, if you dont you'll still want at least a .txt file with a denied permissions to the folder its in, because you'll want a stored password/ username combination, at least. If you dont, the easiest way to do it would be almost as insecure as what you have now. (Example: checking tha a username variable is being used.. but anybody could open two windows in a tab and have one with a username variable that your script is asking for.. even if its not the same one you use.

    Usually the way the forum works, is that you post code you have and ask about help with errors or how you might do it differently. You're doing the 'code monkey' thing.. where you flat out ask for somebody to code for you and that's viewed as an insult by some or many.
     
    ezprint2008, Jun 10, 2009 IP
  3. justinlorder

    justinlorder Peon

    Messages:
    4,160
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The php script is not written by me. I know only html/css but have very little idea of php .
     
    justinlorder, Jun 10, 2009 IP
  4. SHOwnsYou

    SHOwnsYou Peon

    Messages:
    209
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    
    <?php
    function showLogin ()
    {
    ?>
    <form method='post' action=' <?php $_SERVER[PHP_SELF] ?>'><input name='password' type='password' /><input type='submit' name='submit' />
    <?
    }
    
    if(isset($_POST['submit']))
    {
    $pwcheck = "PUT THE SHA1 HASH OF YOUR PASSWORD"
    $pw = $_POST['password'];
    $pw = sha1($pw);
    if ($pw == $pwcheck)
    {
    show your form
    }
    showLogin();
    }
    showLogin();
    ?>
    
    PHP:
     
    SHOwnsYou, Jun 10, 2009 IP