Jump to content

MadPotato

Members
  • Posts

    72
  • Joined

  • Last visited

Everything posted by MadPotato

  1. if you do, you can write a form with PHP, with the 'action' that you want...if not, i have another suggestion...when the guy select the item, you refresh the page, with an GET argument (like index.php?server=1), so you have the chance to re-write the action with PHP...the big problem is: the <input type="file"> isn't a common input, the string isnt all that matters...i dont understand it very well and maybe i'm wrong, but take a look in that part of the code:$uploadfile = $uploaddir . $_FILES['userfile']['name'];if it was a simple text box, you could use $_GET["userfile"] or $_POST["userfile"], but that $_FILE seems quite 'specific'...i'm pertty sure there are another ways to do it, but i just cant figure out...if i come to figure it out i'll tell you
  2. the name matters of course, but if you change it in both files it will workand the file name wont appear in the url, cuz you're using "post", not "get" methodand sorry for my mistake, i can hardly understand what you talk in english , but i'll give you a suggestion this way:i dont know if you can just 'move' a file throught servers, i guess not...then, you think that is acceptable an intermediate page? something like:Selected file: "your_file_name.zip"Confirm Upload? [Yes]
  3. i'm not sure if I understood your doubt, but if you have 3 servers to send the files, the 'action=uploaded.php' should link to 3 diferent servers (like 'www.server1.com/uploaded.php', 'www.server2.com/uploaded.php'...) , and the 'name' really doesnt matter, if you change it in both files...put a 'uploaded.php' in each server...got it?
  4. lol i thought you already had the code to upload files...well, thats a little harder to do, then i'll send you an example and you try to implement it by yourself, ok? If you got trouble, just go back here and scream :)save this content as "index.php"<form enctype="multipart/form-data" action="uploaded.php" method="post"><input type="hidden" name="MAX_FILE_SIZE" value="3000000" />Send this file: <input name="userfile" type="file" /><input type="submit" value="Send File" /></form> save this content as "uploaded.php <?php// In versions of php < 4.1.0, use $HTTP_POST_FILES// isntead of $_FILES.$uploaddir = 'C:/apache/htdocs/misc/upload/';$uploadfile = $uploaddir . $_FILES['userfile']['name'];print "<pre>";if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name'])) { print "File is valid and has been uplead sucessful. Here some info:\n"; print_r($_FILES);} else { print "Oh Oh! Something is wrong here...dont try anything funny lammy mother######er! Some info:\n"; print_r($_FILES);}print "</pre>";?> int the "if", if you cant move the file, maybe the user is trying a "upload attack"...but we are smart guys and won't let them in! :(hope I helpedPS.: Brazilians speak Portuguese, not Spanish!
  5. MadPotato

    Comments!

    Well, maybe your doubt is a doubt of more users. The tutorials teach it, but i'll show a simple code of a GuestBook...first, create a dabatase with the name 'simplegb', and run this SQL to creat the structure: CREATE TABLE posts ( id int(11) NOT NULL auto_increment, userName varchar(25) NOT NULL default '', comment text NOT NULL, KEY id (id)) TYPE=MyISAM; Then, here goes the 3 files of the system. The first, index.php will show all the comments and display a link to post new ones.save this content as "index.php" <!-- Simple Guestbook System - By Bruno Daniel "MadPotato" --><!-- madpotato@gmail.com --><html><body><?//Connect to the DB $oConDB = mysql_connect("127.0.0.1","root","");//Select your DataBasemysql_select_db("simplegb",$oConDB);//Get all the comments...$cSQL = "SELECT * FROM posts ORDER BY id";$oRS = mysql_query($cSQL,$oConDB);//...and print them in a tablewhile($aRow = mysql_fetch_assoc($oRS)) { //PS.: each time 'mysql_fetch_assoc' is used, it takes a row from the resource // and puts it in an associative array echo $aRow["comment"]."<br />"; echo "<small> By: ".$aRow["userName"]."</small><br /><hr>";}//close database connection (very important! :P)mysql_close($oConDB);?><br /><br /><a href="post.php"> Post </a></body></html> The second is a form to be used by the users to post:save this content as "post.php" <html><body><form action="execute.php" method="post"> Your Name:<br /> <input name="userName" id="userName" type="text" size="35" maxlength="25" /><br /><br /> Your Comment:<br /> <textarea name="comment" id="comment" rows="10" cols="35"></textarea><br /><br /> <input type="submit" /></form></body></html> and the last one will insert the new post in the database:save this content as "execute.php" <html><body><?//Connect to the DB $oConDB = mysql_connect("127.0.0.1","rot","");//Select your DataBasemysql_select_db("SimpleGB",$oConDB);//insert new comment$cSQL = "INSERT INTO posts (userName,comment) VALUES ('".$_POST["userName"]."','".$_POST["comment"]."')";mysql_query($cSQL,$oConDB);//small Javascript Code to redirect user to indexecho "<script type=\"text/javascript\"> location.href='index.php' </script>";//close database connection (very important! :P)mysql_close($oConDB);?></body></html> Please notice that the code isn't optimized since its an example writen as easier to understand as possible. I've included lots of comments in the PHP functions. Hope it helped somebody.
  6. MadPotato

    Sql Query

    I cant see why you cant just store the image url, like "ww.anysite.com/images/icon.gif"...
  7. MadPotato

    ASP vs PHP

    Choose PHP. Belive me, its better for your health.
  8. anyway, flash will be aways larger then html om bytes, what takes bandwidth, an users patience
  9. 404 means the browser dont found the page...the site should be under maintenance or something
  10. well...i live in Brazil, so this is a monster lol just kiddin...the point is: what you'll gonna do with it? if its for webdesign only, its more then enough, but you will not play Doom III in it, be sure
  11. Second, I suggest you use Switch...Case instead of If...Else If. The 'Switch' controll verify a variable value (or a property of an object, like a 'select' value) and specify a set of actions to do in each case (specified values). Here how it will look like: <script type="text/javascript">function Send2Server() { Switch(document.getElementById("selecting").value) { case "form_1": //Here comes the code to upload to server 1 break; case "form_2": //Here comes the code to upload to server 2 break; case "form_3": //Here comes the code to upload to server 3 break; }}</script><form name="combined" action=""> <input type="file" name="filename" id="filename" /> <select name="selecting" id="selecting"> <option value="">select the server</option> <option value="form_1">upload to site 1</option> <option value="form_2">upload to site 2</option> <option value="form_3">upload to site 3</option> </select> <input type="button" value="Upload!" onclick="Send2Server()" /></form> hope I helped you solve your problem
  12. First, as Chocolate570 said, use a function. to do so, open the tags <script> </script> with a content like this: <script type="text/javascript">function YourFunctionName(target) { if (target.selectedIndex = 0) { alert('you didnt select a server!') } else if (target.form.file.value = 0) { alert('you didnt select a file to upload!') } else if (target.options[target.selectedIndex].value = form_1) { here goes the code to submit form 1 } else if (target.options[target.selectedIndex].value = form_2) { here goes the code to submit form 2 } else if (target.options[target.selectedIndex].value = form_3) { here goes the code to submit form 3 }}</script> As you can see, i changed little in your code, put it in a function and add some tabulation. Much easier to read now, dont you think?Now, in your 'onclick' event, you should put something like onclick="YourFunctionName(this)". Notice that the 'this' is sent to the function, that calls it 'target', and use 'target' instead of 'this'. Another change is the 'elseif'...javascript dont know what it means, whe just know 'else' and 'if', so you can use it in the same context as 'else if'
  13. sjxun, relaxyou are not the only one here who doesn't speak english :)welcome aboardso, what have you already learned?
  14. try document.getElementById("text").value = "xxxxx"
  15. hmm...nice dude, i'm brazilian and people here who doesn't speak english can learn much more in spanish...good luck
  16. not sure about what is easier to learn, both JS and PHP are simple languages if you want to do simple things, hard if you want a good DOM handling/multi-browser compatibility, and database handling...maybe PHP is a bit easier in this point cuz you dont have to worry about the user browser/browser version...but JS for sure is a lot more useful if you are a begginer, so it come first
  17. MadPotato

    Form validation

    for the colored border, use document.getElementById("field_id").style.borderColor="#FF0000" for a red border, for example...and on the onkeypress, call a function that verify the document.getElementById("field_id").value.length, if its >= 3 you change the color of the border, else you turn it back to the original color...maybe you can change the size of the border also, but it can deform your formif you need some more specific code, just ask...but i hope you can solve your problem now
  18. or you can put in an external file, with extension .css, and link it to your page (any number of pages)in each page that you want to link to an .css file, use: <link type="text/css" rel="stylesheet" href="file_name.css"> try to save the file with this content:file_name.css body { background-color: black; font-family: verdana; font-size: 25px; } doing this, you'll have the config. of the layout from a entire web system in a single file, and changing it, you'll change all the pages
  19. why the "@"?ps.:use code instead of quote so you can get tabulation, tabing, whatever (dont know the word in english lol )
  20. sorry the off-topic, and sorry the bad english! in this code: <info> <jokes> <joke> <title>Joke of the Day from MySite.com</title> <link>http://mysite.com</link> <question>Q: What do you get when you goose a ghost></question> <answer>A: A hand full of sheet</answer> <date>2005-10-20</date> </joke> </jokes></info> how can i get the data, in a spam, div or table, of the joke? (darn, i'm a noob )
×
×
  • Create New...