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!
I'm starting with AMFPHP... I have this code that I wanna turn into a class that I can use directly into AMFPHP... But I'm not sure how to proceed. I played around but I get errors of course. So I'll appreciate any help that shows me what the result should look like, with a little explanation if possible... so I can do it on my own. ^_^
<?php
//login.php
include "connect.php";
//This page gets called when a user attempts to login
//POST the information
$username = $_POST['username'];
$password = md5($_POST['password']);
$cookie = $_POST['cookie'];
//If the checkbox was checked set a cookie called "fd_mem_user" and set its value equal to the username
if($cookie != "")
{
setcookie("fd_mem_user",$username, time() + 31536000,"/");
}
else
{
//If its was previously set and then the user unchecks it, set the same cookie equal to nothing and the expiration time to one hour before the current time.
setcookie("fd_mem_user","", time() - 3600,"/");
}
$query = mysql_query("SELECT * FROM $tableName WHERE username = '$username' AND password = '$password'") or die(mysql_error());
$num = mysql_num_rows($query);
if($num < 1)
{
//no username/password combo was found
echo "result=fail";
}
else
{
//username/password combo found. Give the access. User info gets displayed
$row = mysql_fetch_array($query);
echo "result=success";
echo "&username=$row[username]";
echo "&email=$row[email]";
echo "&firstname=$row[firstname]";
echo "&lastname=$row[lastname]";
echo "&address1=$row[address1]";
echo "&address2=$row[address2]";
echo "&city=$row[city]";
echo "&state=$row[state]";
echo "&zip=$row[zip]";
echo "&phone=$row[phone]";
echo "&date_added=$row[date_added]";
}
?>
Waiting for your help, I made some changes... I managed to get a working service but I have a problem with echo. (see the comment in the appended code)