Frances;
Hi. I trust you are doing file. I have seen some of your screenshots and always learn something from you.
By RadPHP I think you mean Embarcadero's PHP? I have never used RadPHP, I don't know what the difference is to plain vanilla PHP (which is what I have). I write php using the same editor (uestudio) that I use for my win32 fwh apps.
PHP with ADS works perfectly. I suggest you start by opening the help file and search for PHP. Open the 2nd entry: "A Sample PHP Web Site". You will see screenshots + PHP code. Use the forward and back buttons to see each .php file. it shows how to connect, insert, update, select data and show it on a web page. Simple PHP, but the code will show you everything you need.
It is unlikely that PHP will come setup with the Advantage language extension, but the help file also shows you that. I'm using Linux (Fedora 14) with Apache server to host the page. The actual ADS server is Windows Server and physically over 3 thousand miles away. The web server serves php pages while the data is fetched from the ADS server. A have a second setup where the web server is right next to the ADS server, both running Linux. And a third setup I also have is one where the Web server and the ADS server are both running on the same linux server.
It doesn't have to be PHP, it could also be Java, Perl, asp.net. Advantage has a client for each just like for PHP.
Here is the code I use to connect:
- Code: Select all Expand view RUN
//----------------------------------------------------------------------------------------------------------------------
function DDconnect( $db, &$rConn )
{
$user = $_SESSION[ 'userid' ];
$pass = $_SESSION[ 'password' ];
$rConn = ads_connect( $db, $user, $pass );
return is_resource( $rConn );
}
The login.php code is here. It is mostly PHP, HTML and some CSS:
- Code: Select all Expand view RUN
<?php
session_start();
include "classes.php" ;
include "include/corefuncs.php";
if ( $_POST && isset( $login ) && ( strlen( $_POST[ "custid" ] ) < 3 || strlen( $_POST[ "password" ] ) < 6 ) )
die( "bad user name or password" );
if ( $_POST && array_key_exists('custid', $_POST) &&
array_key_exists( 'password', $_POST ) &&
array_key_exists( 'submit', $_POST ) &&
!empty( $_POST[ 'custid' ] ) &&
!empty( $_POST[ 'password' ] ) ) $login = 1;
if ( isset( $login ) ) {
nukeMagicQuotes();
$user = $_POST[ "custid" ] ;
$pass = $_POST[ "password" ] ;
$_SESSION[ 'userid' ] = $user;
$_SESSION[ 'password' ] = $pass;
if ( !DDconnect( _DATA_DICT, $rConn ) )
die( "<br> Error connecting to Database.<br>" ) ;
$curruser = new user;
if( !$curruser->load( $rConn, $user ) ) die( "<br> No access has been set for referring physician." ) ;
//log successfull login attempt into database
//table log keeps track of each successfull login for analisys and statistics.
$rStmt = ads_prepare( $rConn, "INSERT INTO log ( [UserId], [login_date], [ip] ) VALUES( ?, now(), ? )" );
$aParms = array( 1 => $user, 2 => $_SERVER[ 'REMOTE_HOST' ].$_SERVER[ 'REMOTE_ADDR' ] );
$rResult = ads_execute( $rStmt, $aParms );
ads_close( $rConn );
$curruser->password = $pass;
$_SESSION[ 'user' ] = $curruser;
$_SESSION[ 'userid' ] = $curruser->userid;
$_SESSION[ 'password' ] = $pass;
$_SESSION[ 'username' ] = $curruser->GetName();
header( 'location: ./main.php' );
exit;
}
?>
<style type="text/css">
input.required {background-color:darkred; color:white }
body {
padding: 0;
margin: 90px 10% 0 230px;
background: #fff url(background.png) top left no-repeat;
color: #fff;
text-align: center;
line-height: 100%;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif
}
label {
font-size: 10px;
width: 3em;
float: left;
text-align: right;
margin: 0.05em 0em;
clear: both; }
input {
float: left;
margin: .1em .1em;
height: 20px;
width: 110px; }
#subbutton {
font-size: 11px;
float: none;
width: auto;
margin-bottom: 1em;
margin-left: 0em;
height: 25px;
line-height: 100%;
clear:both; }
#nav {
position: absolute;
top: 280px;
left: 2px;
width: 123px;
}
#header {
position: absolute;
top: 10px;
left: 660px;
}
#footer {
position: absolute;
bottom:10px;
color: #aaa ;
left: 1px;
width: 150px;
font-size: 75%;
clear: both;
}
#textarea {
font-size: 90%;
position:absolute;
top: 40px;
margin: 60px 5% 0 1px;
min-width: 425px;
max-width: 625px;
}
br {
clear: both;
}
</style>
<html>
<form ACTION=""
name="loginform"
method="post" >
<div id="nav">
<strong>User Login</strong><br>
<br>
<p><label for="id"> Username: </label></p>
<input type="text" name="custid"/>
<p><label for ="pass"> Password: </label></p>
<input type="password" name="password"/>
<br>
<br>
<input type="submit" name="submit" value=" Login " id="subbutton" />
</div>
</form>
</html>
<?php
// include('include/header.php');
// include('include/footer.php');
// echo '<div id="TextAreaHome"> ';
echo '<div id="wrapper">';
include( 'include/home.txt' );
echo '</div>';
echo '</div>';
?>
It will probably be easier to start by looking at the sample PHP web site from the help file. Then it is only a matter of learning PHP. Any PHP sample using mySQL will work the same, you only need to change the database functions to the respective ads_xxx function like you see on my code ads_execute(), ads_connect()... I wrote my only 2 web portals with PHP over 5 years ago. Haven't done many changes on them. The few times I have gone back to change something, it takes me a while to remember how to write PHP.
I hope that helps,
Reinaldo.