JacobMarshall Posted July 5, 2009 Share Posted July 5, 2009 I would like to know how to change the page or a part of a page. e.g This is an example: This is the default define("VAR_UPLOAD_FOLDER", "g452811/"); But if the URL is http://testURL.net/index.php&id=blabla The script will change to define("VAR_UPLOAD_FOLDER", "g795222/"); Thanks Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/ Share on other sites More sharing options...
trq Posted July 5, 2009 Share Posted July 5, 2009 Kinda defeats the purpose of using a constant so I wont. if (isset($_GET['id'] && $_GET['id'] == 'blabla')) { $uploaddir = 'g795222/'; } else { $uploaddir = 'g452811/'; } Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-869099 Share on other sites More sharing options...
JacobMarshall Posted July 5, 2009 Author Share Posted July 5, 2009 Could you explain the script, Please? Thank you Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-869101 Share on other sites More sharing options...
trq Posted July 5, 2009 Share Posted July 5, 2009 Its a simple if statement that checks a value within the $_GET array. The $_GET array contains arguments passed via the url. Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-869103 Share on other sites More sharing options...
JacobMarshall Posted July 5, 2009 Author Share Posted July 5, 2009 it doesn't work http://jmarshall.uuuq.com/tests/uploads/file.php Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-869104 Share on other sites More sharing options...
trq Posted July 5, 2009 Share Posted July 5, 2009 You have a syntax error. Post the relevent code. Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-869106 Share on other sites More sharing options...
JacobMarshall Posted July 5, 2009 Author Share Posted July 5, 2009 Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ',' or ')' in /www/uuuq.com/j/m/a/jmarshall/htdocs/tests/uploads/file.php on line 97 <?php #********************************************** # Multiple File Upload * #********************************************** #********************************************** # Change history * # ============== * # 10/10/2007 - WebDevBoost.co.uk * # * #********************************************** # Description # =========== # The script is designed to allow you to upload multiple files in one go, the script also presents you with the variable option # of keeping a files name or randomly renaming it. # Remember, there maybe a a upload limit set by the server of 2MB, you can change this by changing the php.ini if you have access #************************************************************************************************** ###/ VARIABLES - CHANGE ACCORDINGLY define("VAR_BASE_DIRECTORY", ""); #/ Your webhosting directory define("VAR_UPLOAD_FOLDER", "g452811/"); #/ Chmod directory 777 for successful upload define("VAR_UPLOAD_DIRECTORY", VAR_BASE_DIRECTORY.VAR_UPLOAD_FOLDER); #/ DO NOT EDIT define("VAR_UPLOAD_FIELDS", 3); #/ Set number of upload fields define("VAR_FILENAME_KEEP", 0); #/ If set to 0 (Zero) the filename will generate randomly, if 1 (One) it will maintain filename ##/ Function that displays forms and is called by default function defaultForm() { echo "<form method=\"post\" enctype=\"multipart/form-data\">\n"; for($i=0; $i < VAR_UPLOAD_FIELDS; $i++) { echo "<input name=\"file[]\" type=\"file\" id=\"file[]\" /><br />\n"; } echo "<input name=\"Submit\" type=\"submit\" value=\"Submit\">\n"; echo "<input name=\"filter\" type=\"hidden\" value=\"processForm\">\n"; ##/ hidden value points the switch to processing echo "</form>\n"; return; } #/ End of defaultForm ##/ Function that displays forms and is called by default function processForm() { for($i=0; $i < VAR_UPLOAD_FIELDS; $i++) { echo ""; if(!empty($_FILES[file][size][$i])) { if(VAR_FILENAME_KEEP==1) { ##/ File maintaining upload name $fileName = $_FILES[file][name][$i]; } else { ##/ Filename randomized $fileName = rand(1,4000).rand(1,4000).rand(1,4000).rand(1,4000).rand(1,4000).'.' . substr($_FILES[file][name][$i], -3); } ##/ Creating reference address $newLocation = VAR_UPLOAD_DIRECTORY.$fileName; if(!copy($_FILES[file][tmp_name][$i],$newLocation)) { echo "<b>Failed - ".$_FILES[file][name][$i]." would not copy to ".$newLocation."</b> (Check your upload directory and permissions)"; } else { ###/ SUCCESS /### #/ Stripping of VAR_BASE_DIRECTORY for better viewing and linking $urlShow = str_replace(VAR_BASE_DIRECTORY,'',$newLocation); echo "<b>Uploaded successfully - <a href=\"$urlShow\" target=\"_blank\">$urlShow</a></b>"; } } else { echo "<b>No file uploaded</b>"; } echo "<br />"; } return; } #/ End of processForm if (isset($_VAR_UPLOAD_FOLDER['id'] && $_VAR_UPLOAD_FOLDER['id'] == 'blabla')) { $uploaddir = 'g795222/'; } else { $uploaddir = 'g452811/'; } ##/ This object handles which function the application should call switch($_POST[filter]) { case "processForm": processForm(); break; default: defaultForm(); break; } #/ End of Handling ?> Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-869107 Share on other sites More sharing options...
trq Posted July 5, 2009 Share Posted July 5, 2009 I think you need to learn some basics. As I said, the $_GET array holds variables passed via the url. Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-869109 Share on other sites More sharing options...
trq Posted July 5, 2009 Share Posted July 5, 2009 Hehe, the parse error is also in my example. This.... if (isset($_GET['id'] && $_GET['id'] == 'blabla')) { should be.... if (isset($_GET['id']) && $_GET['id'] == 'blabla') { Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-869110 Share on other sites More sharing options...
JacobMarshall Posted July 5, 2009 Author Share Posted July 5, 2009 can you just give me the source? PLEASE! Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-869119 Share on other sites More sharing options...
haku Posted July 5, 2009 Share Posted July 5, 2009 Chill out Mr. Demandy. Thorpe just showed you where the error was. Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-869135 Share on other sites More sharing options...
JacobMarshall Posted July 5, 2009 Author Share Posted July 5, 2009 it still doesn't work, you try: http://jmarshall.uuuq.com/tests/uploads/file.php?id=blabla Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-869328 Share on other sites More sharing options...
newbtophp Posted July 5, 2009 Share Posted July 5, 2009 it still doesn't work, you try: http://jmarshall.uuuq.com/tests/uploads/file.php?id=blabla works great here Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-869339 Share on other sites More sharing options...
JacobMarshall Posted July 5, 2009 Author Share Posted July 5, 2009 It uploads in g452811/ and I want to upload it in g795222/ Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-869343 Share on other sites More sharing options...
sKunKbad Posted July 5, 2009 Share Posted July 5, 2009 You should spend some time learning about php, uploads, and upload security before putting code like you have started on a production website. If you are just looking for somebody to write code for you, there are many tutorials online, and you could just use their code. If you don't want to learn, and simply need code, try phpclasses.org. Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-869348 Share on other sites More sharing options...
JacobMarshall Posted July 5, 2009 Author Share Posted July 5, 2009 I would just be so happy is someone will just make the script or edit the script that is wrong or needs replacing! Sorry I am so demanding I am doing this for my boss and he has gone away and I know no PHP. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-869360 Share on other sites More sharing options...
JacobMarshall Posted July 7, 2009 Author Share Posted July 7, 2009 You guys are no use, I had to use a different topic http://www.phpfreaks.com/forums/index.php/topic,259355.0.html Thanks anyway! Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-870662 Share on other sites More sharing options...
trq Posted July 8, 2009 Share Posted July 8, 2009 You guys are no use, I had to use a different topic http://www.phpfreaks.com/forums/index.php/topic,259355.0.html Thanks anyway! Ever thought that maybe your just not asking your question the right way. Were not here to write code for people. Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-870736 Share on other sites More sharing options...
JacobMarshall Posted July 8, 2009 Author Share Posted July 8, 2009 I know, but I looked everywhere and they were all wrong! Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-870737 Share on other sites More sharing options...
trq Posted July 8, 2009 Share Posted July 8, 2009 But I gave you a good example in my very first reply. You simply failed to take that example and apply it to your own problem, thats not anybody's fault but your own I'm afraid. Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-870741 Share on other sites More sharing options...
JacobMarshall Posted July 8, 2009 Author Share Posted July 8, 2009 I am so sorry thorpe Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-870748 Share on other sites More sharing options...
haku Posted July 9, 2009 Share Posted July 9, 2009 You guys are no use Heh, apparently we're almost as useless as you. The difference being of course that we actually do know how to code. If you are that desperate, send me a PM and we can discuss how much I will charge you to fix your problem. Quote Link to comment https://forums.phpfreaks.com/topic/164819-solved-change-page-with-url/#findComment-871778 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.