PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
session_start();
if((isset($_SESSION['log'])) && ($_SESSION['log'] == 1))
{
echo "already logged";
}
$username = $_POST['username'];
$pwd = $_POST['pwd'];
mysql_connect($mysql_host, $mysql_user, $mysql_pwd);
mysql_select_db($mysql_db);
$query = "SELECT * FROM `users` WHERE `user` = '".$username."'"; //Lets say that `user` is UNIQUE
$result = mysql_query($query);
$pwd_result = mysql_result($result, 0, "pwd"); //Select the first result and col `pwd`. (`user` is UNIQUE so there is only one result).
if($pwd_result == $pwd)
{
$_SESSION['log'] = 1; //Means for the script that the user is logged.
echo "logged";
}else{
echo "bed login in, go back to the login screen and try again";
}
?>
You should try searching these forums for what you want to do. Then, search google for what you want to do. Then, try something and when that fails, ask us why it failed. I am not intending to be rude (though it almost sounds that way ) but it appears as though you want a personal tutor to guide you through learning PHP development (which I am sure some here would gladly do for you at the right price). But what you are asking are things that are usually spelled out in PHP books and tutorials.
You may want to also look at Kevin Yank's (Sitepoint) book Build Your Own Database Driven Website Using PHP & MySQL. Download the sample chapters and practise what he mentions in the examples. My very first PHP app was taken straight from those examples and within a week I had managed to make my own PHP app.
Try it. If it doesn't work, post back here with the problems you are facing.
thank you so much everah for your advice, i really appreciate it. I dont care for who want angry with me but i take it as my spirit to achieve my goal.
ok guru. sory because this is my fault, and i try to choose easy way.. but thats true guru.. we must try it first,research deeply. Ok guru thanks again
I wouldn't say that anyone is angry with you. This community is an excellent resource for help with your learning. When I say that, I mean we will always try to point you in the direction you should go to achieve what you want to achieve. Most folks around here will never do something for you that you have not honestly and earnestly tried to accomplish yourself.
It is also a very good idea to have some knowledge of PHP terms and language. This is because, though we try to keep things as simple as possible, even some of the simplest things can be confusing to someone that doesn't know we're talking about.
Keep plugging along. Try stuff. And when your programs die, try something else. And then, when things go haywire again, let us know so we can help you with it.
And thanks for contributing to this community. People needing help is what keeps this place helping people.