RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 3461 | Replies: 15 | Thread Tools  Display Modes
Reply
Join Date: Aug 2004
Location: Los Angeles
Posts: 347
Reputation: Ghost is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: How To Create A Free Web Host

  #11  
Sep 5th, 2005
Hi Zippee,

First, thanks for all your help. Second, I was wrong about knowing how to upload files! Do you know how? I already made a form with a file field.

Thanks again.
Reply With Quote  
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: How To Create A Free Web Host

  #12  
Sep 5th, 2005
Ecommerce-Web-Store.com Building Your e-Business.
Reply With Quote  
Join Date: Aug 2004
Location: Los Angeles
Posts: 347
Reputation: Ghost is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: How To Create A Free Web Host

  #13  
Sep 5th, 2005
Hi Zippee!

Thanks! I get some errors so I attached the code:
login.php:
[PHP]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CinnaHost Login</title>
</head>

<body bgcolor="#3366FF">
<img src="logo.png" width="939" height="61" />
<br />
<table width="940" height="215" border="1">
<tr>
<td width="103" height="209"><center>
<h3>CinnaHost<br />
<br />
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="20">
<param name="BGCOLOR" value="#3366FF" />
<param name="movie" value="button1.swf" />
<param name="quality" value="high" />
<embed src="button1.swf" width="100" height="20" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#3366FF" ></embed>
</object>
<br />
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="20">
<param name="BGCOLOR" value="#3366FF" />
<param name="movie" value="button4.swf" />
<param name="quality" value="high" />
<embed src="button4.swf" width="100" height="20" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#3366FF" ></embed>
</object>
<br />
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="20">
<param name="BGCOLOR" value="#3366FF" />
<param name="movie" value="button2.swf" />
<param name="quality" value="high" />
<embed src="button2.swf" width="100" height="20" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#3366FF" ></embed>
</object>
<br />
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="20">
<param name="BGCOLOR" value="#3366FF" />
<param name="movie" value="button3.swf" />
<param name="quality" value="high" />
<embed src="button3.swf" width="100" height="20" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#3366FF" ></embed>
</object>
<br />
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="20">
<param name="BGCOLOR" value="#3366FF" />
<param name="movie" value="button5.swf" />
<param name="quality" value="high" />
<embed src="button5.swf" width="100" height="20" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" bgcolor="#3366FF" ></embed>
</object>
</h3>
</center></td>
<td width="821" bgcolor="#0000FF"><center>
<h2>CinnaHost Login/Upload:</h2>
</center>
<form action="in.php" method="post" enctype="multipart/form-data">
<p><strong> <font color="#FFFFFF">Site Name:</font><br />
<input name="site" type="text" />
<br />
<br />
<font color="#FFFFFF">Password:</font><br />
<input type="password" name="password" />
</strong><strong></strong>
<strong> <br />
<br />
<font color="#FFFFFF">File To Upload:</font>
<br />
<input type="file" name="updelfile" />
<br />
<br />

<input type="submit" value="Login" />
</strong></p>
</form></td>
</tr>
</table>
</body>
</html>
[/PHP]

in.php:
[PHP]<html>
<head>
<title>CinnaHost Login</title>
</head>
<body bgcolor="#3366FF">
<center><h1><font color="#FFFFFF">Uploading...</font></h1>
<h2><font color="#FFFFFF">To Upload More Files, Click <a href="login.php"><font color="#FFFFFF">Here</font></a>.</font></h2>
</h1></center>


<?php
$filename = "../public/$_POST[site]/pswrd.pswrd";
$fp = fopen($filename,"r") or die ("Login Not Working - please try again.");
$pswrd = fgets($fp);
$attempt = "$_POST[password]";
if($pswrd == $attempt) {
echo "Login Successful!";


//START UPLOAD

$file = $_FILES["$_POST[updelfile]"];
// set the file type you will allow to avoid abuse to your server
$accept = array('pdf','doc','xls','ppt','txt','zip','jar','html','html','php','rtf','jpg','png','gif','txt','java','cpp');
if($file["size"] > 0) {
$file_name = basename($file["name"]);
$ext = substr($file_name, -3, 3);
}
// validate file
if ($file["size"] > 5000000) {
echo "Filesize over 5 mb limit.<br>\n";
}
elseif(!in_array($ext, $accept)) {
echo "Invalid file format. <br>\n";
}
else {
// set folder path to which image uploaded
$uploaddir = "../public/$_POST[site]";
//copy the file to some permanent location
if (move_uploaded_file($file['tmp_name'], $uploaddir.$file['name'])) {
echo "File has been uploaded.<br>\n";
}

//END UPLOAD


else {
echo "Error found. Please try again. <br>\n";
}
}
}
else {
echo "Login Failed - please try agin.";
}
?>

</body>
</html>[/PHP]

Thanks!
Reply With Quote  
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: How To Create A Free Web Host

  #14  
Sep 5th, 2005
What errors you get?

You may want to use echo or print at each stage to find out where the errors were. I would suspect your $filename may be an error and always use $_POST['something'].
Ecommerce-Web-Store.com Building Your e-Business.
Reply With Quote  
Join Date: Aug 2004
Location: Los Angeles
Posts: 347
Reputation: Ghost is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: How To Create A Free Web Host

  #15  
Sep 6th, 2005
actually, $filename works. Here's the errors:
[PHP]
Notice: Undefined index: updelfile in c:\phpdev5\www\public\in.php on line 22

Notice: Undefined index: in c:\phpdev5\www\public\in.php on line 22

Notice: Undefined variable: ext in c:\phpdev5\www\public\in.php on line 33
Invalid file format.
[/PHP]

If you want to view the page, go to http://192.168.1.42/public/login.php You can use "cinnatech" for a site name and "pwrd" for the password. If you try to upload a file and click login, you'll see the error messages.
Reply With Quote  
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: How To Create A Free Web Host

  #16  
Sep 6th, 2005
I can't access the site as 192 is your localhost address, not the true IP address.
I have no idea about the first two. The thrid may be because you upload files that wasn't define in the script (in my other post http://www.daniweb.com/techtalkforums/thread31803.html there is something called $accept that prevent undefined file being upload).
Ecommerce-Web-Store.com Building Your e-Business.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the PHP Forum
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 6:48 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC