PDA

View Full Version : requesting help.


hmm
10-31-2006, 05:19 AM
i have included an attachment.
its a simple php upload script, and im wondering if anyone can tell me how to add a username and password form, so only those who know it can use it, ex: me.

also, how could i make this check if the file already exists?

if anyone knows of good php tuts online, please send me that way too.

btw, great hosting =)

UnlimitedMB
10-31-2006, 03:41 PM
Why not just use the file manager?

You can only upload 500KB per file with upload scripts, with the file manager you can upload 2MB per file.

hmm
11-01-2006, 02:46 AM
alright, i was just entertained with this type of stuff yesterday, so yeah.
thanks though:P

arenlor
11-01-2006, 03:33 AM
Just to answer the question, make a mysql database (or use an existing one) and put a table in it that has username and password.

the code is
<?php
$conn = mysql_connect('mysql','username','password');
$db = mysql_select_db('databasename');
$username = $_POST['username'];
$password = $_POST['password'];
if($password != '' && $username != '')
{
$query = "select * from TABLENAME where username = '$username' and password = '$password'";
$result = mysql_query("$query");
$num = mysql_num_rows("$result");
if($num == 1)
{
whatever you want it to do such as header("location:file");
}
}
else
{
echo "<form action=\"$PHP_SELF\" method=\"post\">
<label for=\"username\">Username<input type=\"text|password\" name=\"username\" /></label><br />
<label for=\"password\">Password<input type=\"text|password\" name=\"password\" /></label><br />
<input type=\"submit\" value=\"Login\" /></form>";
}
?>

note where I put text|password you need to choose one.