Jump to content

www.mihalism.com

Members
  • Posts

    68
  • Joined

  • Last visited

Everything posted by www.mihalism.com

  1. Here is a code to upload, check file type, and sizeNow for file types a lot of people i know use $_FILES['userfile']['type'] to limit the file type but in the past i have seen problems happen with that when it actual does not block file types so i gave you another method for checking itI tested it on localhost so it should work <?php//define variables$filetmp = $_FILES['userfile']['tmp_name'];$filename = $_FILES['userfile']['name'];$filesize = $_FILES['userfile']['size'];$max_size = 1075000; // 1050 KB$type_allowed = array('jpeg', 'jpg', 'gif', 'png', 'psd', 'ico', 'bmp');$path = "images/";//variables to get file type$path_chunks = explode("/", $filename);$thefile = $path_chunks[count($path_chunks) - 1];$dotpos = strrpos($thefile, ".");$extension = substr($thefile, $dotpos + 1);//check uploadif(!$filename){echo "No file selected !";exit;}elseif($filesize>$max_size){echo "Filesize is too large !";exit;}elseif(!array_search(strtolower($extension), $type_allowed) !== false){echo "Wrong file type !";exit;}else{//do uploadmove_uploaded_file($filetmp, $path.$filename);chmod($path.$filename, 0777);}//show result$url = $path.$filename;echo 'Your file is located at <a href="'.$url.'">'.$url.'</a>';?>
  2. Yeah for the move_uploaded_file function i did notice my mistakeit should be like move_uploaded_file($filetmp, "images/".$filename); or use the one the other guy posted
  3. Uploading is more a php code not HTML but for a simple one it would look something like thisHTML form <form method="post" enctype="multipart/form-data" action="upload.php"> <input type="file" name="userfile"> <br/><input type="submit" value="Start uploading"></form> Upload.php PHP code <?php//define variables$filetmp = $_FILES['userfile']['tmp_name'];$filename = $_FILES['userfile']['name'];//move file to directorymove_uploaded_file($filetmp, "images/.$filename);//display resultecho 'Your file is located at <a href="images/'.$filename.'">images/'.$filename.'</a>';?>
  4. .htmlIs for webpages.txtIs just plain text
  5. That is true and this is not really for the PHP forum you should try javascript forum
  6. By publish a script a mean allow others to download it
  7. Well i am about to publish a forum hosting script for IPB but im going to make it a demo script and because i am going to make it a demo im going to have a limit of 20 forums allowed to be hosted at once my idea for limiting is having the script count the total number of databases used by the forums each database created will have a unique id with it so it wont mix up any non forum databases and i just want to know if you people think that would be the best way to limit itsorry if the grammar does not look good im too tired to care
  8. Its up to you but instead of using a die() with your own message you should use mysql_error() so you know a better detail of what the problem is something like this <?php$con = mysql_connect("localhost", "username", "password");if(!$con){ die( mysql_error() ); }mysql_select_db("the_db", $con);$result = mysql_query("SELECT * FROM `no_value`", $con) or die( mysql_error() );while($row = mysql_fetch_array($result)){$var = $row['column_1'];echo $var;}mysql_close($con);?>
  9. For the random passcode you could do something simple like <?php$uni = md5 (uniqid (rand()));$echo = substr($uni, 0, 10);echo $echo;?>
  10. Heres a nice clean data fetching code try it <?php//connect$con = mysql_connect("localhost","usernmae","password");if(!$con){ echo mysql_error(); }//pick databasemysql_select_db("database_name", $con);//database query$result = mysql_query("SELECT `pdedecker` FROM `votes` WHERE `id` = '0'", $con) or die(mysql_error());//fetchwhile($getrating_listing = mysql_fetch_array($result)){$getrating_rating = $getrating_listing['pdecker'];}//close connectionmysql_close($con);?>
  11. <?php$con = mysql_connect("localhost","peter","abc123");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("my_db", $con);$result = mysql_query("SELECT * FROM person");while($row = mysql_fetch_array($result)) { echo $row['FirstName'] . " " . $row['LastName']; echo "<br />"; }mysql_close($con);?>
  12. http://us2.php.net/manual/en/function.count.php
  13. Nevermind i found the problem
  14. Your hidden field will work with $_POST because its nothing special just a hidden field i dont even see a reason for it why not just define it in the php instead of using a hidden field
  15. There are many ways to do that and most are simple my site uses css to make those kind of menus but a easy way would to use frames like <html> <head> <title>My site</title> </head> <body> <frameset cols='185, *' frameborder='no' border='0' framespacing='0'> <frame name='menu' noresize scrolling='auto' src='menu.html'> <frame name='body' noresize scrolling='auto' src='main.html'> </frameset> <noframes> Your browser does not support frames </noframes> </body></html>
  16. When using file inputs dont use $_POST[''] use $HTTP_POST_FILES['']; like to display the file name of the selected file you would do $HTTP_POST_FILES['userAvatar']['name']
  17. Cookies not working because your cookie name that is set is "User" and when you are trying to echo it you wrote "user" as the cookie name when you have to capitalize, the u
  18. So what i think your saying is you want a form that when submited will send the message and name to your email well here would be the HTML code for the form you can edit it any way you want it <FORM action="" method="post"><TABLE WIDTH="90%" BGCOLOR="#FFFFFF" ALIGN="center" CELLSPACING="1" CELLPADDING="4" BORDER="1"><TR><TD>Name</TD><TD><input type="text" name="name" style="width:250px"></TD></TR><TR><TD>Message</TD><TD><textarea cols="50" rows="10" name="msg"></textarea></TD></TR><TR><TD> </TD><TD><input type="submit" name="submit" value="Submit form"></TD></TR></TABLE></FORM> but when it comes time to processing the form i would recommend PHP but its up to you but if you were going to use PHP for the sending part you could use a mail() function it would look something like <?phpif($_POST['submit']){$name = $_POST['name'];$msg = $_POST['msg'];if(!$name){echo "<script language=javascript1.1>alert('Please enter a name'); java script:history.back();</script>";}elseif(!$msg){echo "<script language=javascript1.1>alert('Please enter a message'); java script:history.back();</script>";}else{mail("youremail@yoursite.com", "Form", "Name : $nameMessage : $msg");echo "<script language=javascript1.1>alert('Your message has been sent'); java script:history.back();</script>";}}?>
  19. No reason to have it because there are so many ways around itwell heres the script <script language=JavaScript><!--var message="Sorry, no right-clicking allowed.";function clickIE4(){if (event.button==2){alert(message);return false;}}function clickNS4(e){if (document.layers||document.getElementById&&!document.all){if (e.which==2||e.which==3){alert(message);return false;}}}if (document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS4;}else if (document.all&&!document.getElementById){document.onmousedown=clickIE4;}document.oncontextmenu=new Function("alert(message);return false")// --></script>
  20. www.mihalism.com

    Blog

    http://www.phpbb.com/phpBB/viewtopic.php?t...;highlight=blog
  21. CSS body {SCROLLBAR-ARROW-COLOR: #000000;SCROLLBAR-BASE-COLOR: #666666;SCROLLBAR-FACE-COLOR: #696969;SCROLLBAR-HIGHLIGHT-COLOR: #A9A9A9;SCROLLBAR-SHADOW-COLOR: #778899;SCROLLBAR-3DLIGHT-COLOR: #778899;SCROLLBAR-TRACK-COLOR: #808080;SCROLLBAR-DARKSHADOW-COLOR: #778899;}
  22. Script Author: Ash Young <ash@evoluted.net>. www.evoluted.nethttp://mihalism.com/images/downloads/php_f...tory_script.zip
  23. here i made your code the way i think you want iti dont really see a reason for the isset() so i did not put it in the code <?php//include main.php if no var is selectedif(!$_GET['page']){include('main.php');}//include other pageselseif($_GET['page'] == ""){include("menu.php");}elseif($_GET['page'] == "form"){include("formular.php");}else{echo "This page doesnt excists!";}?>
  24. http://www.upsdell.com/BrowserNews/stat_trends.htm
×
×
  • Create New...