Jump to content

Login PHP, Quick Question?


Chris McGee

Recommended Posts

When I put my username and password in the fields and then submit I get the fallowing error...

 

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/purseati/public_html/Connections/users.php on line 58

 

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/purseati/public_html/Connections/users.php on line 63

 

Does anyone know what to do?

Link to comment
Share on other sites

<?php require_once('Connections/users.php'); ?>

<?php

$host="localhost";

$user="purseati_XJ5014";

$pass="mcgee87";

$db="purseati_userlogin";

 

$connection = mysql_connect($host,$user,$pass)or die ('Unable to connect');

mysql_select_db($db) or die ('Unable to select DB');?>

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

 

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 

  switch ($theType) {

    case "text":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;   

    case "long":

    case "int":

      $theValue = ($theValue != "") ? intval($theValue) : "NULL";

      break;

    case "double":

      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";

      break;

    case "date":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

    case "defined":

      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

      break;

  }

  return $theValue;

}

}

?>

<?php

// *** Validate request to login to this site.

if (!isset($_SESSION)) {

  session_start();

}

 

$loginFormAction = $_SERVER['PHP_SELF'];

if (isset($_GET['accesscheck'])) {

  $_SESSION['PrevUrl'] = $_GET['accesscheck'];

}

 

if (isset($_POST['usernameText'])) {

  $loginUsername=$_POST['usernameText'];

  $password=$_POST['passwordText'];

  $MM_fldUserAuthorization = "";

  $MM_redirectLoginSuccess = "contact.html";

  $MM_redirectLoginFailed = "home.html";

  $MM_redirecttoReferrer = false;

  mysql_select_db($database_users, $users);

 

  $LoginRS__query=sprintf("SELECT username, password FROM users WHERE username=%s AND password=%s",

    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

 

  $LoginRS = mysql_query($LoginRS__query, $users) or die(mysql_error());

  $loginFoundUser = mysql_num_rows($LoginRS);

  if ($loginFoundUser) {

    $loginStrGroup = "";

   

    //declare two session variables and assign them

    $_SESSION['MM_Username'] = $loginUsername;

    $_SESSION['MM_UserGroup'] = $loginStrGroup;      

 

    if (isset($_SESSION['PrevUrl']) && false) {

      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];

    }

    header("Location: " . $MM_redirectLoginSuccess );

  }

  else {

    header("Location: ". $MM_redirectLoginFailed );

  }

}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.