opus pro and opus creator flash, multimedia and e-learning software and authoring tools

Digital Workshop - Flash SCORM Multimedia and E-Learning Authoring Tools for Business and Education
Opus Pro - Multimedia and E-Learning Authoring Software for Business and Education

part 3: creating a log-in

An Example Script to Create a Log-in

The following PHP script should give you some idea as to how to create a log-in interface in Opus:

<?php

$user = $HTTP_POST_VARS['user'];
$pass = $HTTP_POST_VARS['pass'];

$DBhost = "localhost";
$DBuser = "username";
$DBpass = "password";
$DBName = "mydb";

$connect = mysql_connect($DBhost,$DBuser,$DBpass);
$db = mysql_select_db($DBName,$connect);

$query = "SELECT * FROM tablename WHERE username='$user'";
$result = mysql_query($query, $connect);

$resultRow=mysql_fetch_array($result);
$storedpassword=$resultRow[userpassword];
$storeduser = $resultRow[username];

if ($password==$storedpassword) {
  echo "&success=1";
} else {
  echo "&success=0";
}

?>

If the username and password are correct, a name-value pair of "success" and "1" is transmitted via the echo function.

If the username and password do not match, the name "success" and value "0" are transmitted.

You would therefore need to use the 'Destination' tab of the existing Post Web Data action to retrieve this name-value pair and store it to a variable. You can then use an If statement to trigger different actions depending on the value of the target variable, such as showing an 'Invalid Login' message or displaying the next page if the login was successful.