• Web Dev Questions That Don't Need Their Own Thread v4
    5,001 replies, posted
[QUOTE=atomiku;46535893]Anyway, as for file structure, I'll show you mine. It's the file/directory structure my MVC framework uses, but its similar to most other PHP MVC frameworks[/QUOTE] You usually put css/img/js/whatever into a public folder and use nginx's try_files or the apache equivalent
[code] //index.php <!DOCTYPE html> <html> <head> <title>Login</title> </head> <body> <form action="login.php" method="POST"> <b>name: </b><input type="text" name="username"> <br/><b>Password: </b><input type="password" name="password"> <br/><input type="submit" value="Submit" name="submit"> </form> </body> </html> // login.php <?php // Set up MySQL $accounts = mysql_connect("localhost", "robharding", "raisethedongs") or die(mysql_error()); mysql_select_db("robhardi_accounts", $accounts); $result = mysql_query("SELECT * FROM users", $accounts); $user = $_POST["username"]; $pass = $_POST["password"]; function login() { echo 'Logged in!'; } for($row = 0; $row = mysql_fetch_array($result); $row++) { if($user == $row['USERNAME'] && $pass == $row['PASSWORD']) { login(); exit; } else { echo $user . $pass; echo 'Username and/or password is incorrect'; exit; } } ?> [/code] for some reason its saying im typing in wrong info every time :/
[QUOTE=BOT Ferris;46543227][code] //index.php <!DOCTYPE html> <html> <head> <title>Login</title> </head> <body> <form action="login.php" method="POST"> <b>name: </b><input type="text" name="username"> <br/><b>Password: </b><input type="password" name="password"> <br/><input type="submit" value="Submit" name="submit"> </form> </body> </html> // login.php <?php // Set up MySQL $accounts = mysql_connect("localhost", "robharding", "raisethedongs") or die(mysql_error()); mysql_select_db("robhardi_accounts", $accounts); $result = mysql_query("SELECT * FROM users", $accounts); $user = $_POST["username"]; $pass = $_POST["password"]; function login() { echo 'Logged in!'; } for($row = 0; $row = mysql_fetch_array($result); $row++) { if($user == $row['USERNAME'] && $pass == $row['PASSWORD']) { login(); exit; } else { echo $user . $pass; echo 'Username and/or password is incorrect'; exit; } } ?> [/code] for some reason its saying im typing in wrong info every time :/[/QUOTE] -mysql_ is deprecated. Please pick up PDO/mysqli, or one day you'll find your page stopped working and you won't know why. -Getting all users ever just to check a single one is a really bad idea that will lag your page in the future. You should condition your query to only select the data that you want (select everything from accounts WHERE username is x (pseudocode, don't actually copy&paste that)) -Use some kind of salt for the passwords. I only need a slip up to be able to get all users and passwords in plain text off your server. I shouldn't be able to do that. [URL="http://php.net/manual/en/faq.passwords.php#faq.passwords.bestpractice"]Here are PHP's best practices for it.[/URL] -That login function seems pretty useless, if you ask me. You might expand it on the future, so I'm not going to give it further thinking.
Is it just me or does Vagrant have folder sync delay sometimes? It feels like when I work in an MVC structure when changing a controller or something that links together it has over 30 seconds delay to make a change when I refresh my browser. Any ideas? I currently generate my box via [URL="https://github.com/fideloper/Vaprobash"]Vaprobash[/URL].
[QUOTE=Moofy;46543893]Is it just me or does Vagrant have folder sync delay sometimes? It feels like when I work in an MVC structure when changing a controller or something that links together it has over 30 seconds delay to make a change when I refresh my browser. Any ideas? I currently generate my box via [URL="https://github.com/fideloper/Vaprobash"]Vaprobash[/URL].[/QUOTE] The problem probably comes from the virtual box or whatever visualization you're using. maybe there's a setting to sync every few seconds. (which sounds awful)
[QUOTE=jung3o;46543948]The problem probably comes from the virtual box or whatever visualization you're using. maybe there's a setting to sync every few seconds. (which sounds awful)[/QUOTE] I have no clue, I tried to Google around for some time but every solution seemed rushed and only worked for a few people here and there. It's just weird because it syncs super fast but whenever I update a file that chains through a couple of other files like extending the BaseController in Laravel it will just take a minute or so before it updates, it's madness.
[QUOTE=Moofy;46544032]I have no clue, I tried to Google around for some time but every solution seemed rushed and only worked for a few people here and there. It's just weird because it syncs super fast but whenever I update a file that chains through a couple of other files like extending the BaseController in Laravel it will just take a minute or so before it updates, it's madness.[/QUOTE] that sounds like an awful way to develop. :v:
[QUOTE=jung3o;46544045]that sounds like an awful way to develop. :v:[/QUOTE] Yea, I don't know if it's something in the Vaprobash config that I've missed. I'm pretty sure it's not. It even says to remove the NFS on Windows systems so I can't blame that either. Tried on both Mac and Windows :suicide:
[QUOTE=BOT Ferris;46543227][code] //index.php <!DOCTYPE html> <html> <head> <title>Login</title> </head> <body> <form action="login.php" method="POST"> <b>name: </b><input type="text" name="username"> <br/><b>Password: </b><input type="password" name="password"> <br/><input type="submit" value="Submit" name="submit"> </form> </body> </html> // login.php <?php // Set up MySQL $accounts = mysql_connect("localhost", "robharding", "raisethedongs") or die(mysql_error()); mysql_select_db("robhardi_accounts", $accounts); $result = mysql_query("SELECT * FROM users", $accounts); $user = $_POST["username"]; $pass = $_POST["password"]; function login() { echo 'Logged in!'; } for($row = 0; $row = mysql_fetch_array($result); $row++) { if($user == $row['USERNAME'] && $pass == $row['PASSWORD']) { login(); exit; } else { echo $user . $pass; echo 'Username and/or password is incorrect'; exit; } } ?> [/code] for some reason its saying im typing in wrong info every time :/[/QUOTE] where are you learning to do this? try learning php again from here [url]http://www.codecademy.com/en/tracks/php[/url] [editline]21st November 2014[/editline] [QUOTE=Moofy;46544064]Yea, I don't know if it's something in the Vaprobash config that I've missed. I'm pretty sure it's not. It even says to remove the NFS on Windows systems so I can't blame that either. Tried on both Mac and Windows :suicide:[/QUOTE] if you're using laravel, i suggest you use homestead. it's a vagrant box that laravel provides [url]http://laravel.com/docs/4.2/homestead[/url]
[QUOTE=jung3o;46544075] if you're using laravel, i suggest you use homestead. it's a vagrant box that laravel provides [url]http://laravel.com/docs/4.2/homestead[/url][/QUOTE] Sorry, I didn't actually mean this is a Laravel specific problem I was just trying to give an example of what I would do and what would happen. I actually stumbled upon this problem when I was creating a class on my own that extended another class. Either way, I'm totally screwed for now :v:
[QUOTE=Moofy;46544109]Sorry, I didn't actually mean this is a Laravel specific problem I was just trying to give an example of what I would do and what would happen. I actually stumbled upon this problem when I was creating a class on my own that extended another class. Either way, I'm totally screwed for now :v:[/QUOTE] well it doesnt even have to laravel. it works for most of similar php development.
[QUOTE=jung3o;46544150]well it doesnt even have to laravel. it works for most of similar php development.[/QUOTE] I feel like such an idiot for thinking this was just related to Laravel, anyways just tried to have a go at it, was pretty straight forward and worked like charm! [t]http://i.imgur.com/afSw3vM.png[/t] Will have it for a spin and see if the syncing is still fucking me over, thanks!
[QUOTE=Moofy;46544471]I feel like such an idiot for thinking this was just related to Laravel, anyways just tried to have a go at it, was pretty straight forward and worked like charm! [t]http://i.imgur.com/afSw3vM.png[/t] Will have it for a spin and see if the syncing is still fucking me over, thanks![/QUOTE] Thought you said you didn't like vagrant. What made you change your mind?
Not really a programming question, but does anyone know any good free places to host? I'm making a website for someone and need somewhere to host the prototype page to show them.
How would you suggest to do a form result page with lots of steps that depend on each other? -big if else fountains that become spaghetti code soon? -short ifs with variables like $step1_success = true; ? -dinosaur invoking with GOTOs? -other? I tried the two first already, and while the second one is more reliable, it still allows for lot of trouble to happen if it's not short enough.
Also, another question. I've followed this tutorial [URL="http://brandonsummers.name/blog/2012/02/10/using-bitbucket-for-automated-deployments/"]http://brandonsummers.name/blog/2012/02/10/using-bitbucket-for-automated-deployments/[/URL] to get a php deployment script. I already have the hook pointed to it. The file it generates, deployment.log, exists and has everything as it should, but it doesn't seem to execute the commands. If I run that php file from command-line, though, it works. If exec was disabled, it would've raised an exception or I wouldn't be able to make it work from shell, right? And if it weren't working, deployment.log wouldn't be modified... What could be going on?
[QUOTE=Coment;46552081]Also, another question. I've followed this tutorial [URL="http://brandonsummers.name/blog/2012/02/10/using-bitbucket-for-automated-deployments/"]http://brandonsummers.name/blog/2012/02/10/using-bitbucket-for-automated-deployments/[/URL] to get a php deployment script. I already have the hook pointed to it. The file it generates, deployment.log, exists and has everything as it should, but it doesn't seem to execute the commands. If I run that php file from command-line, though, it works. If exec was disabled, it would've raised an exception or I wouldn't be able to make it work from shell, right? And if it weren't working, deployment.log wouldn't be modified... What could be going on?[/QUOTE] exec doesn't throw an exception in case of a shell error, like "permission denied", etc. Rewrite it to be using passthru instead of exec and dump the output and review what's really happening.
[QUOTE=meek;46549230]Not really a programming question, but does anyone know any good free places to host? I'm making a website for someone and need somewhere to host the prototype page to show them.[/QUOTE] I'm currently using [URL="http://ramnode.com"]RamNode[/URL]. I paid $15.00 for the 128mb plan. ( One Year ) I host a Teamspeak 3, and my website on it, and I've never had any trouble with it.
Quick question, when I redirect someone using header("Location: website.com"); will everything below it will be executed or will header(); act like exit();. I'm asking because I working on a small website that let's you upload CSV files with phone numbers so you can send SMS to everyone listed in the CSV file and the process is quite lengthy and I don't want peoples thinking it's not working.
[QUOTE=_FR_Starfox64;46561910]Quick question, when I redirect someone using header("Location: website.com"); will everything below it will be executed or will header(); act like exit();. I'm asking because I working on a small website that let's you upload CSV files with phone numbers so you can send SMS to everyone listed in the CSV file and the process is quite lengthy and I don't want peoples thinking it's not working.[/QUOTE] Read the [URL="http://php.net/manual/en/function.header.php"]docs[/URL] first... [code] <?php header("Location: http://www.example.com/"); /* Redirect browser */ /* Make sure that code below does not get executed when we redirect. */ exit; ?> [/code]
What do you guys think of the navigation on the left for a documentation page [url]http://fuccboi.moe/documentation/tilemap/?[/url]
[QUOTE=adnzzzzZ;46561965]What do you guys think of the navigation on the left for a documentation page [url]http://fuccboi.moe/documentation/tilemap/?[/url][/QUOTE] Looks good, but you should do the same as bootstrap, and highlight at which section you currently are.
Javascript: [code]function mapDraw() { var tiley = 16; var tilex = 16; var xpos = 0; var ypos = 0; while (tiley !== 0) { while (tilex !== 0) { bg.drawTile(tileDict[map[tiley][tilex]], xpos, ypos, 16 * 2, 16 * 2); xpos += 32; tilex--; } tiley--; xpos = 0; ypos += 32; } }[/code] Why is ypos always 0 inside the interior while loop? jsFiddle: [url]http://jsfiddle.net/m963kfkv/[/url]
[QUOTE=01271;46572492]Javascript: [code]function mapDraw() { var tiley = 16; var tilex = 16; var xpos = 0; var ypos = 0; while (tiley !== 0) { while (tilex !== 0) { bg.drawTile(tileDict[map[tiley][tilex]], xpos, ypos, 16 * 2, 16 * 2); xpos += 32; tilex--; } tiley--; xpos = 0; ypos += 32; } }[/code] Why is ypos always 0 inside the interior while loop? jsFiddle: [url]http://jsfiddle.net/m963kfkv/[/url][/QUOTE] So, basically your loop goes like this: [code] - Start first while loop, everything is at default values - Start second while loop, everything standard values do 16 times: draw tile increase xpos (final value is 32 * 16) - Exit second loop tilex is 0, xpos = 32 * 16, no other values are changed. - tiley--; - xpos is set to 0. - ypos is increased. - Okay cool, back to the start of first loop - tilex === 0 - don't actually do anything in the second while loop, because the values are not increased. [/code] Blabla, I guess that you want to generate a tile grid of size 16 x 16, so you might just want to reset tilex to the gridwidth (16) after you increase your ypos value. What I would do in a situation like this is use for loops instead of whiles. You know how often it's going to loop before you start the iteration. [code] function mapDraw() { var gridsizex = 16; var gridsizey = 16; var tilesize = 32; for(var x = 0; x < gridsizex; ++x) { for(var y = 0; y < gridsizey; ++y) { bg.drawTile(tileDict[map[y][x]], x* tilesize, y* tilesize, 16 * 2, 16 * 2); } } } mapDraw(); [/code] Also, looking back at your tileDict[map[y][x]] it appears you're filling it in absolute reverse now? [16, 16] is now tile position [0, 0]. If that was what you intended, then go map[16 - y][16 - x], but I'm guessing it was not.
[QUOTE=eternalflamez;46574226] Also, looking back at your tileDict[map[y][x]] it appears you're filling it in absolute reverse now? [16, 16] is now tile position [0, 0]. If that was what you intended, then go map[16 - y][16 - x], but I'm guessing it was not.[/QUOTE] I ended up doing that about an hour ago and yeah, it was backwards but it's really strange that the while loop forgets what the variable is.
Anyone that has an idea what exactly I should edit in order to change the highlight colour for my Sublime Text sidebar? Been browsing the .tmTheme for some time but I can't really find what does it.
[QUOTE=01271;46574461]I ended up doing that about an hour ago and yeah, it was backwards but it's really strange that the while loop forgets what the variable is.[/QUOTE] It doesn't forget it. It sets the value back to 0, and is not reset. So it actually remembers it better than you thought it did?
I still don't get it. I see it as: The value is set to 0 Start loop Start loop The value is used but it's zero End loop The value is incremented by 32 End loop
[QUOTE=01271;46581341]I still don't get it. I see it as: The value is set to 0 Start loop Start loop The value is used but it's zero End loop The value is incremented by 32 End loop[/QUOTE] The inner loop is only run for the first iteration of the outer loop because you aren't resetting tilex, thus ypos is being updated correctly, but the code inside the inner loop is never run after ypos has been incremented. If you change [code] while (tiley !== 0) { while (tilex !== 0) { [/code] to [code] while (tiley !== 0) { tilex = 16; while (tilex !== 0) { [/code] It should work as you would expect.
[QUOTE=Moofy;46577903]Anyone that has an idea what exactly I should edit in order to change the highlight colour for my Sublime Text sidebar? Been browsing the .tmTheme for some time but I can't really find what does it.[/QUOTE] You want to navigate to: [code]~/Library/Application Support/Sublime Text 2/Packages/Theme-Default/Default.sublime-theme[/code] Then, edit these: [code]"class": "sidebar_container" "class": "sidebar_tree" "class": "sidebar_heading" "class": "sidebar_label"[/code] If you have a custom theme installed I'm guessing it'll be [code]themename[/code] instead of [code]Theme-Default[/code]
Sorry, you need to Log In to post a reply to this thread.