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 .
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.
<?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: