Jump to content

[SOLVED] dreamweaver - form submission


Recommended Posts

I am writing my login page in dreamweaver. I need the login page to send users to different pages based on their user type. I tried to use the standard server behavior for login but it sends all to one successful login page. If I try to insert code when using a server behavior - it doesn't like it (I'm assuming you can't).  I just decided to write the code myself so that I could use a switch statement to determine which successful login page to send them to. I'm not new to programming but new to php and dreamweaver. I copied some of the parts of code from dreamweaver (specifically the form action using $_SERVER['PHP_SELF']) and this code:

$loginFormAction = $_SERVER['PHP_SELF'];

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

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

 

I do not exactly understand the above code.  When I run my program, key in data and hit submit it is looking for this in a search box:  http://localhost/$_server['php_self']

So, obviously I don't understand the php_self part.  My code follows. My form was created just for testing which is why the names and descriptions are nutty.  Thank you so much for you help!  Pamela

(Here is the code)

 

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

<?php

if (!function_exists("GetSQLValueString")) {

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

{

  if (PHP_VERSION < 6) {

    $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;

}

}

//This program validates request to login to site

if (!isset($_SESSION)){

session_start();

 

}

$loginFormAction = $_SERVER['PHP_SELF'];

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

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

      }

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

$loginUsername = $_POST['formemail'];

$password = $_POST['formpassword'];

$MM_redirectLoginFailed = "loginfail.php";

mysql_select_db ($database_Carrollton, $Carrollton);

$Login_query = "SELECT mem_email, mem_password, mem_type FROM members WHERE mem_email = ? and mem_password = ?";

$LoginRS = mysqli_prepare($carrollton, $Login_query);

mysqli_stmt_bind_parm($LoginRS, 'ss', $loginUsername, $password);

mysqli_stmt_execute($LoginRS);

$loginFoundUser = mysql_num_rows($LoginRS);

if ($loginFoundUser) {

$loginUserName = mysql_result($LoginRS,0,'mem_id');

$loginStrGroup = mysql_result($loginRS,0,'mem_type');

 

// declare two session variables and assign them

    $_SESSION['MM_Username']=$loginUsername;

$_SESSION['MM_UserGroup']=$loginStrGroup;

 

$id = $loginStrGroup;

switch ($id) {

case "M";

$MM_redirectLoginSuccess = "admin_my_account.php";

    break;

case "D";

$MM_redirectLoginSuccess = "admin_dealer.php";

    break;

case "1";

$MM_redirectLoginSuccess = "admin_admin.php";

    break;

case "2";

$MM_redirectLoginSuccess = "admin_moderate.php";

    break;

default:

$MM_redirectLoginSuccess = "admin_my_account.php";

    break;  }

  header("Location:".MM_redirectLoginSuccess);

    }

else {

  header("Location:".$MM_redirectLoginFailed);

}

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

 

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>

<body>

<form id="form1" name="form1" method="post" action="$_SERVER['PHP_SELF']">

  <label>formemail

    <input type="text" name="formemail" id="formemail" />

  </label>

  <label>formpassword

    <input type="text" name="formpassword" id="formpassword" />

  </label>

  <label>formbutton

    <input type="submit" name="formbutton" id="formbutton" value="Submit" />

  </label>

</form>

</body>

</html>

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.