PHP script help

Discussion in 'Software' started by Bustergut, Jul 20, 2006.

  1. Bustergut

    Bustergut Private E-2

    I'm trying to run an open source program called taskdriver. I'm using Apache 1.3, Windows XP, PHP 4.x and Mysql 4.x. It all installed OK and said everything was created OK, but when I come to log in using the admin / admin username nothing happens. The tables have been created OK though and the login is there. I think it's something to do with the login script

    ob_start();
    $connection = @mysql_connect($hostname, $user, $pass) or die(mysql_error());
    $dbs = @mysql_select_db($database, $connection) or die(mysql_error());

    $sql = "SELECT * FROM $userstable WHERE username = '$_POST[username]' AND password = ('$_POST[password]')";
    $result = @mysql_query($sql,$connection) or die(mysql_error());


    $num = @mysql_num_rows($result);

    echo $num ;

    if ($num != 0) {
    $cookie_name = "auth";
    $cookie_value = "fook!$_POST[username]";
    $cookie_expire = time()+7200;
    $cookie_domain = $domain;

    setcookie($cookie_name, $cookie_value, $cookie_expire, "/", $cookie_domain, 0);
    header ("Location: http://" . $domain . $directory . "index.php");
    ob_end_flush();
    exit;
    }

    $num does =0
    I am running on localhost

    Anybody got any clues ? More info can be provided as long as it ain't too technical.
     
  2. Corporal Punishment

    Corporal Punishment Head of Software Shenanigans Staff Member

    what are the settings in your config.php?
     
  3. Bustergut

    Bustergut Private E-2

    Config settings below. I'm running on pc so localhost is the domain I suspect.

    /* Email address used with your admin account */
    $AdminEmail = "me@here";
    /* Database Hostname (usually localhost) */
    $hostname = "localhost";
    /* Username for database */
    $user = "root";
    /* Password for database */
    $pass = "mypassword";

    /* Database name */
    $database = "task";

    // DO NOT ALTER THE TABLE DATA UNLESS YOU KNOW WHAT YOUR DOING
    /* table name for the user table that will be inserted into the database, If your uncertain what this is leave it as it is */
    $userstable = "users";
    /* table name for the categories table that will be inserted into the database, If you are uncertain what this is leave it as it is */
    $cattable = "categories";
    /* table name for the dev_tasks table that will be inserted into the database, If you are uncertain what this is leave it as it is */
    $taskstable = "dev_tasks";
    /* table name for the history table that will be inserted into the database, If you are uncertain what this is leave it as it is */
    $historytable = "history";



    /* Do NOT enter www. or http:// */
    $domain = "localhost:8080";
    /* this is the directory account of the script ie.. /login/ be sure to add a slash at the beginning and end */
    $directory = "/taskdriver/";
     
  4. Bustergut

    Bustergut Private E-2

    I found the answer. It was to do with cookie settings and the setcookie command. I set the domain to blank because I don't have one - using localhost.

    Thus:-
    //setcookie($cookie_name, $cookie_value, $cookie_expire, "/", $cookie_domain, 0);

    changed to

    setcookie($cookie_name, $cookie_value, $cookie_expire, "/", false);
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds