Hello and thanks in advance for the help. I am running a LAMP server on my raspberry pi and I need help creating a registration and login page using mysql database. All my php files have to be in the /var/www/html. I've been googling this for about a week and I have some questions.
Where do I save css files
Can I make a subdirectory in the html that will create a website (I have tried to do this already but when i navigate to the site it tells me the page isnt working)
How do I make it secure (this is for a personal project so it doesnt have to be extremely secure I just want to know some common security issues)
I tried to follow http://www.allphptricks.com/simple-user-registration-login-script-in-php-and-mysqli/ steps and it showed nothing but a blank page.
I am not asking someone to just write all the code for me, I want to learn and understand what I am doing wrong so if you could direct me to a better tutorial or explain it that would be great.
Thanks
First off make sure all of your CSS files paths are set correctly in the HTML files that you are trying to style. As long as the CSS files are included correctly then it should style your page. The final destination of the CSS files should not matter as long as you have the correct path set to the CSS file in the HTML file.
Linking a CSS file to an HTML file W3Schools
All I did was search "mysql php security best practices" I'm sure you can find more but here is what I found (the first link in my case) OWASP
I've had a look around and I can't find a neat solution;
Trying to use readdir() or scandir() to get the names of files in a folder
The problem is this function (as I understand it) queries the root folder of the server and doesn't take web addresses, so therefore the path I need to pass to this function has to change from when I am developing on my localhost, to when I deploy it onto a live web server.
Is there a better function to use or something I am missing so that I can write one bit of code that works for finding files in a folder, regardless of whether it is deployed locally or on a web server? Do I have to turn to Java?
hope everyone gets what I'm on about, cheers in advance!
What I have to be able to do is copy an entire folder from a remote source to the local server executing the PHP file. I can do that fine except for one problem, PHP files. Obviously, I can't just go copying the source code of a PHP file using regular commands as they will interpret the code and give me the returned stuff. What I have to have is the code. Is there any way to do that?
Hope I'm clear enough, my problem isn't something very hard to understand, I just want to know if it's actually possible. If not, maybe someone may have an idea of an optimal way of storing the source code alongside the executable php? I was thinking simply saving it as text when I'm done developing but if there is a way to do it completely automatically then that would be much more awesome. Best case scenario, I can just copy the folder with php files and then execute it from local. I need to know if that's even possible... Worst case scenario, I have to duplicate files in order copy the text version of them to the local server and discard the php ones since th e executed files are not relevant to my program. I don't want that, but I just don't know if PHP is able to do what I want.
Edit: sorry for not specifying! I am the admin of the remote server and have total access. I can and was expecting to make a php file on the server itself. That's the kind of system I have at the moment! I zip a folder and return it when requested from my local source. My only problem is the php executing.
You cannot do that unless you:
have FTP access (or anything else that is not HTTP-based)
have access to a script on the server that is designed to return the sourcecode of a given file
use an exploit such as the ?-s bug in the CGI SAPI
So you are most likely out of luck.
Im relatively new to silverstripe cms and Im trying to move a site to a new host.
I followed all the instructions I could find on their official forums but to no avail.
Here is what I mean.
Here you can see what the site should look like
http://www.efekto.co.za
But this is what it looks like after I have moved it (copied everything to my public_html folder on the new site, set up the db username and passwords etc)
Please help cause I'm utterly and truly stuck at the moment.
Since someone else initialy moved the site so I decided to delete everything and move everything myself. Its hard to explain otherwise what I have tried or not tried.
First I tried to install just a base silverstripe. Got that right pretty much but only after I specified the database ip as 127.0.0.1 and not the external ip. So I deleted the base install again, copied over all the site files again and this time modified the db params to use 127.0.0.1 Some of the pages now actually reflect valid content but it seems that everything is not this light blue kind of color (seems to be a default of SS? ) It is as if it's missing some kind of master page or something as I can see content, but no module thingies like menus, blog section etc.
I also have to mention that to test this I change my hosts file so that www.efecto.co.za resolves to the sites new ip address with our new host. So from my machine it resolves to new ip but from the servers perspective when it fetches things like css its obviously going to fecth it from where www.efekto.co.za is currently hosted. Hope that makes sense?
So 1 step in the right direction at least. We have content and no more errors. Now whats up with this blue color scheme??
http://www.efekto.co.za seems to be fine now.
My guess: You've had a silverstripe-cache folder on your old server, which you've copied. It contains (as you might suspect) cached files with absolute paths. If your path structure is not exactly the same on both servers, you will run into problems. So always remove everything from the cache folder when moving sites around.
If that isn't the problem, take a look at the Apache log file (probably /var/log/apache2/error.log, but this can vary). As it's a server error, it should tell you what the problem is...
Check the error log in cpanel or whatever, perhaps a PHP or APACHE directive is different on this server. You'll find out from the logs what the problem is.
I got this once and the problem was that /dev/build wouldn't run because the php memory upper limit was set higher in SS than it was on the server.
Also go into _config and set the environment directive to 'debug', this will display as much output as SS can give you on the page.
I'm starting a project in PHP, and I want to structure my files properly from the start (unlike my last project, which had almost every file in a single directory). The problem is the following, which I will describe with an example:
Take the following files: index.php, includes/header.php, and css/common.css. index.php 'includes' the header (as will many other php files). The header then calls common.css so that its html elements can be placed properly. common.css will also provide styling for general elements in index.php and other files.
Notice that since the header is being included, when the header calls common.css, it does so from the location of the file calling it; in this case, index.php. But if I add, say, modules/friends.php and call the header with it, it will be looking for the CSS file in the wrong spot!
Initially I tried to remedy this by using the actual path for when I call CSS files. However, my local machine and web server have a different layout of directories, and therefore I cannot simply call /var/www/whatever.
Can anyone help me or redirect me to a place where this sort of thing is documented?
Thanks,
Paragon
Always specify absolute paths to all your resources: .css, .js, images, etc...
http://en.wikipedia.org/wiki/Absolute_path
However, my local machine and web server have a different layout of directories, and therefore I cannot simply call /var/www/whatever.
You can. Web paths is not the same thing as local filesystem paths. When you specify path in web - the root sign / specifies to the webroot (the directory your project is placed at), not your filesystem root.
Congratulations on recognizing a huge problem.
Yes, this is always the big, important question that you need to answer at the start.
I've finally learned -- and this is after quite a few years -- to try my best to make the file structure on the development machine (my PC, say) be exactly like the file structure on the host machine (a Linux host, for example). That one thing alone has saved me unending hours of grief.
If you can accomplish that, then the rest is a piece of cake, believe me. You can put files in whatever directories you want, wherever it makes sense to you, on both machines. You can figure out what files should go where.
If you don't bother to try for near-identical file-directory setups on both machines, you are forever going to be wondering, as you edit away, "Hey, what machine am I on? If I'm on the host, then very-important-file.php is in /toplevel, and everything else is under it. But if I'm on the PC, then very-important-file.php is over here in /my-files, see, and then other files are on different levels and did I delete that file and ..." My God, don't make me think, much less think about that mindless crap.
You can handle and remember just the root being in different spots on different machines, but other than that, forget it.
Now when you come to run your stuff, you will always know where the pieces of that stuff are: CSS files, JS files, whatever. PLUS you can (maybe; if you're lucky) debug your code on the PC or the host equally well, with no differences and with no changes anywhere. PLUS when you upload your new code, you can FTP it up to the host in one big chunk rooted where you like. (Which has the very nice ancillary benefit of your being able to move files around wherever you want on the development machine.)
Piece of cake! Don't pass up this chance to save yourself days or weeks (literally) of time.
Always IMHO.