Cómo se hace para pasar una variable al programa.prg desde el index.html
- Code: Select all Expand view RUN
<a href="programa.prg">Pasa variable</a>
Gracias por la ayuda
<a href="programa.prg">Pasa variable</a>
function main
local cTest := "my Test"
TEMPLATE PARAMS cTest
<!DOCTYPE html>
<html>
<head>
<style>
body {background-color: powderblue;}
h1 {color: blue;}
p {color: red;}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<a href="programa.prg">Pasa variable <?prg return cTest ?></a>
</body>
</html>
ENDTEXT
return
//----------------------------------------------------------------------------//
This is a heading
This is a paragraph.
Pasa variable My test
cTest="L"
<a href="program.prg">Muestra libres <?prg return cTest ?></a>
cTest="O"
<a href="program.prg">Muestra ocupadas <?prg return cTest ?></a>
In Program.prg
USE ( PATH_DATA+'base.dbf' ) SHARED NEW VIA 'DBFCDX'
INDEX ON field->nombre TAG "nombre" FOR field->tipo=cTest MEMORY
function main
local cTest := "my Test"
TEMPLATE PARAMS cTest
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<a href="postpairs.prg?test=<?prg return cTest ?>">Pasa variable <?prg return cTest ?></a>
</body>
</html>
ENDTEXT
return
//----------------------------------------------------------------------------//
function Main()
? "--------------------------------------"
? "AP_FileName() --> cFileName returns the filename.prg provided to Apache by the client"
? ValToChar(AP_FileName())
? "AP_GetPairs() --> Hash returns a hash with all GET pairs, key and value "
? ValToChar(AP_GetPairs())
? "AP_Args() --> cArgs returns the args provided to Apache by the client if any "
? ValToChar( AP_Args() )
? "--------------------------------------"
function main
local cTest := "my Test"
local cTest2 := "my Test lorem ipsum"
? "--------------------------------------"
? "AP_FileName() --> cFileName returns the filename.prg provided to Apache by the client"
? ValToChar(AP_FileName())
? "AP_GetPairs() --> Hash returns a hash with all GET pairs, key and value "
? ValToChar(AP_GetPairs())
? "AP_Args() --> cArgs returns the args provided to Apache by the client if any "
? ValToChar( AP_Args() )
? "--------------------------------------"
TEMPLATE PARAMS cTest, cTest2
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<a href="program.prg?test=<?prg return cTest ?>">Pasa variable <?prg return cTest ?></a>
<br>
<a href="program.prg?test=<?prg return cTest2 ?>">Pasa variable <?prg return cTest2 ?></a>
</body>
</html>
ENDTEXT
return
//----------------------------------------------------------------------------//
function main
local cTest := "my Test"
local cTest2 := "my Test lorem ipsum"
? "<HR>"
? "AP_Body()"
? AP_Body()
? "<HR>"
? "AP_Method()"
? AP_Method()
? "<HR>"
? "AP_UserIP() --> cUserIP returns the IP, as string, of the client"
? AP_UserIP()
? "<HR>"
? "AP_HeadersIn() //--> Hash returns a hash with all headers pairs, key and value"
? AP_HeadersIn()
? "<HR>"
? "AP_FileName() --> cFileName returns the filename.prg provided to Apache by the client"
? ValToChar(AP_FileName())
? "<HR>"
? "AP_GetPairs() --> Hash returns a hash with all GET pairs, key and value "
? ValToChar(AP_GetPairs())
? "<HR>"
? "AP_Args() --> cArgs returns the args provided to Apache by the client if any "
? ValToChar( AP_Args() )
? "<HR>"
? "AP_PostPairs() --> Hash returns a hash with all POST pairs, key and value"
? ( AP_PostPairs() )
? "<HR>"
//AP_RPuts( uValue ) Sends a value, converted into a string, to the client. Returns nil
AP_RPuts( "<H1>AP_RPUts test</H1><br>" )
? "<HR>"
TEMPLATE PARAMS cTest, cTest2
<!DOCTYPE html>
<html>
<head>
<head>
<meta charset="utf-8">
<title>Meine Testseite</title>
</head>
</head>
<body>
<h1>Test POST and GET</h1>
<p>This is a test for POST and GET method</p>
<h3>GET method test</h3>
<a href="program1.prg?test=<?prg return cTest ?>">Pasa variable - <?prg return cTest ?></a>
<br>
<a href="program1.prg?test=<?prg return cTest2 ?>">Pasa variable - <?prg return cTest2 ?></a>
<br>
<h3>POST method test - FORM</h3>
<form action="program1.prg" method="post">
User name:
<br>
<input type="text" name="username">
<br>
Password:
<br>
<input type="password" name="passw">
<br><br>
<input type="submit" value="Send data">
</form>
</body>
</html>
ENDTEXT
return
//----------------------------------------------------------------------------//
# --------------------------------------------------------------------------
# CONFIGURACION RUTAS PROGRAMA (Relative to DOCUMENT_ROOT)
# --------------------------------------------------------------------------
SetEnv APP_TITLE "MyApp v1.0a"
# --------------------------------------------------------------------------
# Impedir que lean los ficheros del directorio
# --------------------------------------------------------------------------
Options All -Indexes
# --------------------------------------------------------------------------
# Pagina por defectos
# --------------------------------------------------------------------------
DirectoryIndex index.prg main.prg
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.prg/$1 [L]
</IfModule>
Users browsing this forum: No registered users and 17 guests