Jump to content

Where do I add $connection?


marcus

Recommended Posts

[code]

<?php

  include("./inc/ryu786.php");

  $connection = mysql_connect($host, $user, $password);
  [quote]$db = mysql_select_db($database, $connection);[/quote]
  $sql = "SELECT id FROM user
          WHERE user='$_POST[login]'
          AND pass='$_POST[pass]'";

  $result = mysql_query($sql);
  $num = mysql_num_rows($result);
  if ($num > 0) {                                // ### USER AND PASSWORD ARE CORRECT
    $id = mysql_fetch_assoc($result);

    $ip = $REMOTE_ADDR;
    $sql = "INSERT INTO logip (userid, ip) VALUES ('$id[id]', '$ip')";
    $result = mysql_query($sql);

    setcookie("auth", "yes");
    setcookie("id", $id['id']);

    header("Location: main.php");

  }else{                                          // ### USER OR PASSWORD IS INCORRECT
    header("Location: failed.php");
  }

?>

[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.