Instructables

Step 5: Web Page Setup

Okay - the final step before you can use this is to set up the webpage.

For this, type the following commands, ensuring you are logged in as root. (type sudo -i if you're not).
wget http://raspberrypi-gpio.googlecode.com/files/control.php and hit Return / Enter.
wget http://raspberrypi-gpio.googlecode.com/files/off.jpg and hit Return / Enter.
wget http://raspberrypi-gpio.googlecode.com/files/on.jpg and hit Return / Enter.

Once they have downloaded, type in:
mv control.php /var/www/control.php and hit Return / Enter.
chmod 755 /var/www/control.php and hit Return / Enter.
mv off.jpg /var/www/off.jpg and hit Return / Enter.
chmod 755 /var/www/off.jpg and hit Return / Enter.
mv on.jpg /var/www/on.jpg and hit Return / Enter.
chmod 755 /var/www/on.jpg and hit Return / Enter.

You must edit a few variables in the file before use, so type:
nano /var/www/control.php and hit Return / Enter.

Change the following variables:
$MySQLUsername = "USERNAME HERE";
$MySQLPassword = "PASSWORD HERE";

Now, navigate in your web browser to the control.php page. (mine is http://raspberryPi/control.php) where raspberryPi is your host name.

It will ask you to login with the following credentials:
Username: admin
Password: gpio


I recommend clicking the "Change Password" link at the top of the page, and changing the password for obvious reasons.

That's the end of the Web Page section.
 
Remove these adsRemove these ads by Signing Up
jeryhawj9 months ago
when i put in http://raspberryPi/control.php(raspberryPi=my ip address), all i get is an invalid request. can someone tell me if i need to do something else. i have followed every instruction on here... and even went back to all the old pages to make sure i did everything correct. i even have access to "phpmyadmin" account. i dont know why i cannot get into this last part. any help and or reply will be appreciated. thank you.
buteman11 months ago
Running control.php doesn't seem to do anything. I have edited control.php and put a username and password in but when I enter them on running control.php it just goes straight back to asking for user name and password. I tried refreshing the web page to ensure I was running the modified version, I restarted both mysqld and apache2 but it just doesn't work. Any ideas?
sdobbie1 year ago
I can't log in. It just changes the user back to root and doesn't work.
freakqnc1 year ago
Daniel, did as suggested and that and it's a no go

User ID:
1

Username:
admin

Password:
c56a280f30e3cfa08f6b6646b0593dee3ce3c4728b4562d0f7d827244167a2fd

Salt:
5652ccfa

Will not allow to login with admin/gpio credentials... any suggestions on how to fix this? Thanks! :)

PS: I would have replied to the comment all the way at the bottom but the instructable system would keep asking to fill in the captcha even when I did... so because that won't work I added the comment as a new one although it's really a reply to your original comment about resetting the pass and salt
Update... found the problem peeps :)

Do not use "admin" and "gpio" in

////////////////////////////////////////////////////////////
//  EDIT THESE TWO VARIABLES  //
///////////////////////////////////////////////////////////
$MySQLUsername = "USERNAME HERE";
$MySQLPassword = "PASSWORD HERE";


YOU MUST USE the username and password you created in Step 3 as the DATABASE USER and NOT use the value of the username in the gpio database!

I believe in this example that would be user gpio and password pr03ND2. Not very intuitive and quite confusing... perhaps should've been pointed out in the instructions.

Hope this helps who got stuck at this point.
jduffas1 year ago
hi !
I love your script, and I have 2 questions :

1 - where do you put the script GPIOServer.sh ? do you leave it in /root ?
2 - I would like it to start on boot of the raspberry, but I don't really know to create a init.d file... I did try but had an error when updating rc.d :

insserv: warning: script 'K01GPIOServer' missing LSB tags and overrides
insserv: warning: script 'GPIOServer' missing LSB tags and overrides

thank you

jean
H_C1 year ago
Thanks for great tutorial :)
I've got one question about it.
Is there possibility to add another button "pulse" to each GPIO on control.php?
When I press the button I need 2 secs of signal
Many thanks :)
drcurzon (author)  H_C1 year ago
Hi there,
With the way I've set the scripts up, EXACT timing is not possible - but you could get near 2 seconds (maybe half a second out).
There are 2 ways of doing this:
Javascript in the browser
Modify the shell script and database and browser files.

The javascript method is probably the easiest and you'd have to add a button to the file with a javascript timer so that it automatically changes the database variable after 2 seconds.

For this, there is probably a better solution out there using python to perform the actions you request.

Many thanks, Dan.
abishur1 year ago
Hey this is abishur over on the r-pi forum I had two questions. One I wanted to add some features to the code you've provided, do you have any restrictions on reuse of your code and if you're okay with it, how would you like to be notated as the originator of the code?

Second, I *really* don't know much about php, how secure is the transmission of the password?
drcurzon (author)  abishur1 year ago
Hi there.
It's great that you want to build off of this! :)
No restrictions on the code - use it as you wish.
If you could link to the instructable, that'd be great thanks.
The password should be fine for transmission over the Internet as it's hashed and salted, so should be fine.
Let me know how it goes?
Many thanks, Dan.
richiep1 year ago
I tried updating the user id, username, password and salt but it still doesn't work:(

I just spent the past week setting up my Pi as a LAMP server for this so I'm super bummed. Does anyone know how to get around this?

Thanks
Rich
Well, I haven't fixed my problem, but I have got around it. My problem lies in the control.php code. I commented out some code, it works now, but at the expense of no security. Here is the code I commented out to make it work.

/* If ($loginHash != $loginData['password']){
mysql_close();
header('location: control.php?error=incorrectLogin2');
} else {
*/
Hey, thanks for the great tutorial! I'm having trouble with the username and password in the control.php. When I try to login it says incorrect login.

I have edited the variables in /var/www/control.php:
mysqlusername = "admin"
mysqlpassword = "gpio"

and I have also entered phpMyAdmin and made sure I had the same username and password for the gpio table........

Any clue where to begin troubleshooting? I'm so new to linux......
RickNLD2 years ago
Hi Daniel,

Thank you for your great work! But i've a problem, actually the same as 'neovin', I can't login to the control page.
I already did the reset in the database, but it has no effect.

Can you help me with this?
regards,
Rick
drcurzon (author)  RickNLD2 years ago
Hi there,
Sorry to hear that it's not working.
What is the error you are getting?
What URL does it redirect you to?
Can you also copy and paste the database info into the reply?

Many thanks, Daniel.
Hi Daniel,
Thank you for your quick reaction! I found out what I did wrong, when changing the variables in the control.php file (so username and password) I did use the one created in step 3 instead of the username and password for the MySQL database. It now works fine.
Many thanks.

Rick
neovin2 years ago
Hi I'm having a problem logging into the gpio page on the pi from a browser on my pc, I have tried logging in with the username and password provided but it gives me is incorrect login details i have changed all the details to the same login and password but it just fails
drcurzon (author)  neovin2 years ago
Hi there,
the password is stored in the database and is encrypted.
If you can access the "users" table in the "gpio" database, set the user to:

1
admin
c56a280f30e3cfa08f6b6646b0593dee3ce3c4728b4562d0f7d827244167a2fd 5652ccfa

In order of User ID, Username, Password, Salt.
This will reset the account so that the username and password will be:
Username: admin
Password: gpio

Hope this helps, Daniel.