I need a simple way to compare info and return values.

I need a php page that access’s the smf_forum MySQL database and retrieve 3 bits of information from the smf_forummembers feild by using username as the key value and then get the user_group & user_password & if the username and password match then return this:
login=<true/false>
group=<0/1/2/etc>

Can anyone help?

You should ask at the SMF forums.

http://www.simplemachines.org/community/index.php?P=41910e5760b774377e22daa1e5e6ca37;

The community there is super helpful when it comes to SMF related items.

I just need to know how to connect to a MySQL Database with php to get & compare string I send via login.php?username=&password=

Can you fix this so it doesn’t return true when it’s false;

[code]<?php

// Grab User submitted information
$user = $_POST[“user”];
$pass = $_POST[“pass”];

// Connect to the database
$con = mysql_connect(“localhost”,“db_forum”,"");
// Make sure we connected succesfully
if(! $con)
{
die(‘Connection Failed’.mysql_error());
}

// Select the database to use
mysql_select_db(“db_forum”,$con);

$result = mysql_query(“SELECT member_name, passwd FROM smf_forummembers WHERE member_name = $user”);

$row = mysql_fetch_array($result);

if($row[“member_name”]==$user && $row[“passwd”]==$pass)
echo"true";
else
echo"false";
?>[/code]
example call
http://website.com/forum/login.php?user=<member_name>&pass=

Try Changing This
[php]if($row[“member_name”]==$user && $row[“passwd”]==$pass)[/php]

to:
[php]if (($row[“member_name”]==$user) && ($row[“passwd”]==$pass))[/php]

Doesn’t matter now. All these problems are now solved. Thank you for your help.

I re-wrote everything again:
[php]<?

/* SMF */
require “…/Settings.php”;

$user = $_REQUEST[‘user’];
$pass = $_REQUEST[‘pass’];

mysql_connect($db_server, $db_user, $db_passwd);
mysql_select_db($db_name);

    $result = mysql_query("SELECT * FROM `".$db_prefix."members` WHERE `member_name` = '$user'");
   
    if($result == false){
            die("User not found!");
    }

$row = mysql_fetch_row($result);

    /* Member ID */	   
    $memid = $row[0];
   
    /* Username */
    $username = $row[1];
   
    /* Post Count */
    $post = $row[3];
   
    /* Group */
    $group = $row[4];
                   
    /* Last online */            
    $last_login = $row[6];
   
    /* Real Name */
    $Real_name = $row[7];
   
    /* passwd_result */
    $passwd_result = $row[16];
                   
    $attach_result = $row[34];
            if($attach_result == "")
                    $attach = null;
            else
                    $attach = $attach_result;
    
    if($passwd_result == $pass)
			$passw = "True";
	else
			$passw = "False";

    $Array = array(
            'Username' => $username,
            'RealName' => $Real_name,
            'MemID' => $memid,
            'UserGroup' => $group,
            'PassResult' => $passw,
            'Avatar' => $attach,
            );

    $json = json_encode($Array);
   
    echo $json;           

/* SMF */
?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service