Any suggestions on what I should start with? :)
Moderator: General Moderators
Any suggestions on what I should start with? :)
Anyone have some suggestions on what I should try and learn to do first with PHP? I am starting out learning the basics of user authroization and sending/retrieving info with mysql, but I feel like I'm not starting where I should. Anyone have some pointers? Thanks! 
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
http://www.php.net/array
arrays.
then mysql/filesystem
http://www.php.net/mysql
http://www.php.net/filesystem
arrays.
then mysql/filesystem
http://www.php.net/mysql
http://www.php.net/filesystem
I know some may disagree, but regardless, my suggestion is after you get a comfortable handle on the syntax of PHP (very similar to C), I suggest going OOP (Object Oriented Programming) immediately. Once you go OOP, there is no going back - and you won't want to go back. 
Check out classes, methods, functions, lions, tigers, bears, (oh my!) and learning to use objects to limit randomness in your code. If there are two instances in your script where the same code sniplet is used, it should be an object.
I know this may seem a bit daunting and confusing at first, but if you go through the growing pains and stick with it you will find your PHP (and any other language) scripts to do what scripting/programming was meant to do - make your life easier. On the contrary, bad scripting/programming can make your life hell.
Output:
U'can dew eht!
It's actually quite simple!
Good luck! If you run across stumbling blocks, just post a question or get your keyboard dirty poking around on http://www.php.net
http://www.php.net/manual/en/language.oop.php
Check out classes, methods, functions, lions, tigers, bears, (oh my!) and learning to use objects to limit randomness in your code. If there are two instances in your script where the same code sniplet is used, it should be an object.
I know this may seem a bit daunting and confusing at first, but if you go through the growing pains and stick with it you will find your PHP (and any other language) scripts to do what scripting/programming was meant to do - make your life easier. On the contrary, bad scripting/programming can make your life hell.
Code: Select all
<?php
class theBasics {
var $not_so_sure;
function theBasics() {
echo "U'can dew eht!<br>\n";
$this->not_so_sure = 1;
}
function verySimple() {
if(is_numeric($this->not_so_sure)) echo "It's actually quite simple!<br>\n";
}
}
$theBasics = new theBasics;
$theBasics->verySimple();
?>U'can dew eht!
It's actually quite simple!
Good luck! If you run across stumbling blocks, just post a question or get your keyboard dirty poking around on http://www.php.net
http://www.php.net/manual/en/language.oop.php
Hey, thanks for the info! Yeah, PHP is a mind in it's own, and I'm loving it. Never had so much fun getting lost and then finding myself again hehe 
However, I do seem to have a problem. Will probably seem kinda simple to the rest of ya, but to me, it's mind boggoling...
As I stated, I am using a script with the following code :
I have indeed created the databases needed ( in my case, my db is called auth, and table called userinfo, with the field names of username and password ).
Now, I can connect fine with NO PROBLEMS to the databse...
However, it's not pulling the data, comparing, or handling like it should.
In other words, I did a basic Insert INTO table userinfo values ('bob','bob');
it saves the info, and places a line in the table with bob under the username, and bob under the password.
i do a select * from userinfo and it dispays that I have bob and bob under the correct fields. However, when I try and log in with bob and bob with the login, i only get the message Please Enter In THe Correct Name.
which is what happens if one uses the incorrect username/password.
Now, I found out whilie reading my manual that in order to use $num = mysql_numrows($result) successfully, I have to run a php command in order to do this?? I dunno, I'm confused.
I have done NOTHING except install apache, edit the http.conf file, and install mysql. Is there something special I need to do with mysql or php in order to have it correclty read/display database information?
for those of you wondering, i did log in with a mysql username, and changed the password, and then edited that in the above script. thanks for any information you can provide me with!
However, I do seem to have a problem. Will probably seem kinda simple to the rest of ya, but to me, it's mind boggoling...
As I stated, I am using a script with the following code :
Code: Select all
<?
# Login Code Written by Matt Slavin
# Email Me At neophite17@hotmail.com for questions or comments.
if((!$Username) | (!$Password)) {
print ("Please Enter In THe Correct Name");
}
mysql_connect("localhost","User_Name_here","Password_Here");
mysql_select_db("My_Database_Here");
# This part is sort if ya want to. I would suggest it.
# Make your login page have the main value of Password
#Comment Out if you Want too
$Password = md5($Password);
$sql = "select * from My_Table where Password=$Password and Username=$Username";
$result = mysql_query($sql);
$num = mysql_numrows($result);
# If Login Is Okay Do What You Want TO DO to Them
if ($num == "1") {
print ("Logged in okay");
#Or you can send them somwhere nice like hawaii
header("Location: http://localhost/bob/success.htm");
exit;
# or even fetch feild about them or save sessions
session_start();
session_register(Username);
}
# And we must a have a default error message if login fails
if ($num == "0"){
print ("Sorry Bub You Need Some Manners In Password");
}
?>Now, I can connect fine with NO PROBLEMS to the databse...
However, it's not pulling the data, comparing, or handling like it should.
In other words, I did a basic Insert INTO table userinfo values ('bob','bob');
it saves the info, and places a line in the table with bob under the username, and bob under the password.
i do a select * from userinfo and it dispays that I have bob and bob under the correct fields. However, when I try and log in with bob and bob with the login, i only get the message Please Enter In THe Correct Name.
which is what happens if one uses the incorrect username/password.
Now, I found out whilie reading my manual that in order to use $num = mysql_numrows($result) successfully, I have to run a php command in order to do this?? I dunno, I'm confused.
I have done NOTHING except install apache, edit the http.conf file, and install mysql. Is there something special I need to do with mysql or php in order to have it correclty read/display database information?
for those of you wondering, i did log in with a mysql username, and changed the password, and then edited that in the above script. thanks for any information you can provide me with!
ok, n/m, i found out what you are talking about. MD5 is just an encryption method used in php... doesn't really effect the password at all, just a way to use it, so wouldn't matter if i used it or not. but, for the sake of argument, yes i took that line out as I did not know what it was before ( and since the comments say I can comment it out, didn't think it would hurt ).
I think there is a module I have to load, or some type of command I have to use when installing php, in order to get this to work ( ie php --mysql_somethingoranother ) or something to this effect... Dunno, just know I'm clueless and loving is
any info though would be appreciated
I think there is a module I have to load, or some type of command I have to use when installing php, in order to get this to work ( ie php --mysql_somethingoranother ) or something to this effect... Dunno, just know I'm clueless and loving is
any info though would be appreciated