View Full Version : Need help with forms :(
--ss--
14-10-2007, 07:40 PM
Well i suck at coding and I want a form for a basic name+pass script but I can't find one :'(
I also want the code for the uploader bar thingy for upload sites , Someone help me :(
Here's an image of basically what i want for people who didn't get what I typed above.
http://www.tehupload.com/10670129554.png
+37 rep to people who help.
Trigs
17-10-2007, 11:29 PM
Dynamicdrive.com for the bar. I know I saw it somewhere before? Use the search tool.
Ill do a form for you but the handler is up to you.
Is that ok?
MrCraig
18-10-2007, 09:25 AM
Name your username and password filed to user and pass and then set up a mysql table to include it.
then use this =]
<?
session_start();
function clean($st)
{
$var = strip_tags(addslashes(stripslashes(htmlspecialchar s($st))));
return $var;
}
$login = clean($_GET[login]);
if(!$login) {
?>
<form action="?login=login" method="post">
<label for="user">Username:</label>
<input type="text" name="user" />
<label for="pass">Password:</label>
<input type="password" name="pass" />
<input type="submit" value="Login" />
</form>
<? }
else
{
$user = clean($_POST[user]);
$pass = clean($_POST[pass]);
$pass = md5($pass);
$ck = mysql_num_rows(mysql_query("select * from users where username = '$user' AND password = '$pass'"));
if($ck==1)
{
$_SESSION[username] = $user;
echo('You have now logged in... Bla Bla Bla, you can put whatever content you want here');
}
else
die("Sorry, Your username or password were not correct");
}
?>
Galaxay1
18-10-2007, 09:50 AM
<?
$serverpath = "ServerPathHere";
$urltoimages = "URLHere";
$maxsize = "500000";
$uniq = uniqid("");
$mode = $_GET['mode'];
if ($mode == "") { $mode = "form"; }
if ($mode == "form") {
echo "<form enctype='multipart/form-data' method='post' action='?mode=upload'>\n";
echo "Upload file: <input type='file' name='file'>\n";
echo "<br><input type='submit' name='Submit' value='Upload'>\n";
echo "<br>Maximum File Size: $maxsizeb Bytes";
echo "<br>$file";
}
if ($mode == "upload") {
$file = $_FILES['file']['name'];
$name = time() . substr($file, -4);
$allowedfiles[] = "gif";
$allowedfiles[] = "jpg";
$allowedfiles[] = "jpeg";
$allowedfiles[] = "jfef";
$allowedfiles[] = "jpe";
$allowedfiles[] = "png";
$allowedfiles[] = "GIF";
$allowedfiles[] = "JPG";
$allowedfiles[] = "JPEG";
$allowedfiles[] = "JFEF";
$allowedfiles[] = "JPE";
$allowedfiles[] = "PNG";
$allowedfiles[] = "PDF";
$allowedfiles[] = "pdf";
$allowedfiles[] = "PSD";
$allowedfiles[] = "psd";
$allowedfiles[] = "bmp";
$allowedfiles[] = "BMP";
$allowedfiles[] = "tif";
$allowedfiles[] = "tiff";
$allowedfiles[] = "TIF";
$allowedfiles[] = "TIFF";
$allowedfiles[] = "dib";
$allowedfiles[] = "DIB";
if($_FILES['file']['size'] > $maxsize)
{
print "What to say if files too big";
}
else {
$path = "$serverpath/" . $name;
foreach($allowedfiles as $allowedfile) {
if ($done <> "yes") {
if (file_exists($path)) {
echo "What To Say If File Already Exists";
exit;
}
}
if (substr($file, -3) == $allowedfile) {
move_uploaded_file($_FILES['file']['tmp_name'], "$path");
$done = "yes";
echo "<p>What to say once its been uploaded</p>";
echo "<p><img src='$urltoimages/$name' border='0'>";
echo "<p>Direct Link: <input name='direct' type='text' size='75' value='$urltoimages/$name'></a></p>";
}
}
if ($done <> "yes") { print "<p><b>Error:</b>What to say if the file isnt one of your allowed ones.</p>"; }
}
}
?>
Thats a basic code for uploading the images but no usersystem.
(reason i used [code] instead of [php] was to show where he needs to imput stuff by embolden and larger font which cant be done in php tags.)
For above, you script does not support file types with a extension longer that 3 characters.
Galaxay1
18-10-2007, 03:11 PM
That was just for uploading images, so not many things have more than 4 characters in extension? :S
Sorry, I meant three.
That was just for uploading images, so not many things have more than 4 characters in extension? :S
MrCraig
18-10-2007, 03:27 PM
Change
$name = time() . substr($file, -4);
to
$name = time() . substr($file, -5);
Galaxay1
18-10-2007, 03:27 PM
and
if (substr($file, -3) == $allowedfile) {
--ss--
19-10-2007, 03:15 PM
I've actually got a fully working upload script but i don't actually want an upload script , I just want the bar to type in where the file is if you get what i mean , anyway + rep who have posted.
grrr need to spread for scott :(
MrCraig
19-10-2007, 03:22 PM
I've actually got a fully working upload script but i don't actually want an upload script , I just want the bar to type in where the file is if you get what i mean , anyway + rep who have posted.
grrr need to spread for scott :(
Erm.. just set the input type to file?
<input type="file" name="upload" />
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.