PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WEBDEV 2024 → WB19  PHPDisplay
WB19 PHPDisplay
Iniciado por jbistuer, 23,jul. 2015 13:52 - 15 respuestas
Miembro registrado
19 mensajes
Publicado el 23,julio 2015 - 13:52
Hi,
I my PHP project I'm using the instruction PHPDisplay in order to execute a PHP script for send emails with PHPMailer.
My problem is that PHPDisplay(script.php) does not work.
Can anybody tell me in which folder I must save my script?
Now it is stored in the root folder and in each of the languages folders.

Thanks in advance
Jordi
Publicado el 23,julio 2015 - 14:13
Hi Jordi,

try phpdisplay(URLofYourSite/script.php)

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Already there: WXShowroom.com, WXReplication (open source)
Coming soon: WXEDM (open source)
More information on http://www.fabriceharari.com


On 7/23/2015 5:52 AM, jbistuer wrote:
Hi,
I my PHP project I'm using the instruction PHPDisplay in order to
execute a PHP script for send emails with PHPMailer.
My problem is that PHPDisplay(script.php) does not work.
Can anybody tell me in which folder I must save my script?
Now it is stored in the root folder and in each of the languages folders.

Thanks in advance
Jordi
Miembro registrado
19 mensajes
Publicado el 28,julio 2015 - 19:44
Hi Fabrice,
unfortunately it doesn't work.
As a trace, I've put the command

echo "hola";

in the script in order to trace it and it not appears, so I guess that PHPDispay() can not find the script.
I do not know where I must put the script.
I've tested PHPDisplay("myscript.php") , PHPDisplay("/myscript.php") and PHPDisplay("URL/myscript.php").
In all cases, it does not work.

Regards
Miembro registrado
19 mensajes
Publicado el 03,agosto 2015 - 12:53
Hi Fabrice,

is it possible that the correct syntax is

PHPDisplay(script.php) instead of PHPDisplay("script.php") ?

Thanks.
Jordi
Publicado el 03,agosto 2015 - 14:29
Hi Jordi

no, the help is quite clear:
http://help.windev.com/…

Just do this:
- put the php page somewhere below your site root level

- then find in your browser how to run it (what URL to use). It should
be something along the line of http://yoursite.com/yourpage.php, or
http://yoursite.com/yourproject_web/yourpage.php or ...

- Once you have a valid URL, just copy and paste it in your code

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Already there: WXShowroom.com, WXReplication (open source)
Coming soon: WXEDM (open source)
More information on http://www.fabriceharari.com


On 8/3/2015 4:53 AM, jbistuer wrote:
Hi Fabrice,

is it possible that the correct syntax is

PHPDisplay(script.php) instead of PHPDisplay("script.php") ?

Thanks.
Jordi
Miembro registrado
19 mensajes
Publicado el 03,agosto 2015 - 17:18
Hi Fabrice,
I have the script in the root level and in each language folder.
It does not work :(
Publicado el 03,agosto 2015 - 18:34
That's -NOT- what I'm saying...

WHat is the URL that make it works in your BROWSER (not in webdev). If
it doesn't work at all from the browser, then there is a problem with
the script. If it DOES work, what IS THE URL you use to run it from the
browser ?

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Already there: WXShowroom.com, WXReplication (open source)
Coming soon: WXEDM (open source)
More information on http://www.fabriceharari.com


On 8/3/2015 9:18 AM, jbistuer wrote:
Hi Fabrice,
I have the script in the root level and in each language folder.
It does not work :(
Miembro registrado
19 mensajes
Publicado el 04,agosto 2015 - 00:03
My URL is cae171.com or www.cae171.com how you perfer it.
Publicado el 04,agosto 2015 - 11:58
I'm talking about the FULL qualified URL for your php script...

By example, the URL you are looking for is something like:
http://fabriceharari.com/UK/Page_Article.awp…


Not only www.fabriceharari.com

So find the URL that you should use to reach your php script, then use it

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Already there: WXShowroom.com, WXReplication (open source)
Coming soon: WXEDM (open source)
More information on http://www.fabriceharari.com

On 8/3/2015 4:03 PM, jbistuer wrote:
> My URL is cae171.com or www.cae171.com how you perfer it.
Miembro registrado
19 mensajes
Publicado el 04,agosto 2015 - 18:21
Ok, I gonna try it.

Thanks Fabrice.
Regards
Miembro registrado
19 mensajes
Publicado el 04,agosto 2015 - 20:45
Hi Fabrice,
I did what you said me but it does not work.
You can see attached images showing how I execute PHPDisplay() and the content of the folder in the server.
Thanks again.







Publicado el 05,agosto 2015 - 16:25
Hi

1. what is in wCadena?

2. and what does "it does not work" mean? What is the effect in your
browser?

3. Where is that code? Browser? Server? in a button? What is the target?

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Already there: WXShowroom.com, WXReplication (open source)
Coming soon: WXEDM (open source)
More information on http://www.fabriceharari.com



On 8/4/2015 12:45 PM, jbistuer wrote:
Hi Fabrice,
I did what you said me but it does not work.
You can see attached images showing how I execute PHPDisplay() and the
content of the folder in the server.
Thanks again.









Miembro registrado
19 mensajes
Publicado el 05,agosto 2015 - 18:33
Hi Fabrice,
First of all, a lot of thanks again for your help.

I tell you, with images, the sequence I execute.

1. from a button in a cellule (attached code cellule) I call the procedure Mail_convidats (attached code Mail_convidats).

----------------------------- code cellule -------------------------------------

// Se valida email de reenvio
SI Length(NoSpace(Cellule_Mail.SAI_Mail_Reenvi)) >= 0 ALORS
w_OK_mail=Faux
w_OK_mail=ComprovarEmail(Cellule_Mail.SAI_Mail_Reenvi)
SI w_OK_mail=Faux ALORS
wVariable=Cellule_Mail.SAI_Mail_Reenvi..Libellé
Erreur(wVariable," "+"El mail ha d'estar informat i amb format correcte.")
RETURN
FIN
FIN

reloj_arena..Visible=False

HLitRecherche(USER,USR_IDUSER,Cellule_Mail.Cellule_USR_IDUSER)
SI HTrouve()=Vrai ALORS
w_Parm_Pro = EnDecryp("D",USER.USR_PSW)
reloj_arena..Visible=Vrai
Mail_convidats(Cellule_Mail.Cellule_USR_IDUSER,w_Parm_Pro,wContracte,Cellule_Mail.SAI_Mail_Reenvi)
FIN
reloj_arena..Visible=Faux
// reloj_arena..Etat=Inactif

SBC_SLR001..Visible=Vrai
Cellule_Mail..Visible=Faux

--------------------------- Mail_convidats --------------------------------

PROCEDURE Mail_convidats(wUsuari,wPsw,wContrac,wTarget)

wRetorn is boolean
wAssumpte is a string
WCos is a string
wCos1 is a string
wCadena is a string
wMeupsw is a string
wDirectori is string

wMeupsw = EnDecryp("D",PARAM.EMP_PSW)

// ----------------- munta el cos del mail -----------------------
HReadSeek(CONTRACTES,CON_IDCONTRACTE,wContrac)
HReadSeek(SUBCON,USR_IDUSER,wUsuari)

wAssumpte = "Accés a l'aplicació CAE"
wCos1 = PARAM.EMP_POB + " , " + DateVersChaîne(DateSys(),"JJ-MM-AAAA") + CR + CR + ...
"Benvolguts senyors," + CR + CR + ...
"Com a empresa participant al contracte esmentat a continuació: " + CR + CR +
" Obra : " + CONTRACTES.CON_DESCRIPCIO + CR + ...
" Població : " + CONTRACTES.CON_POBOBR + CR + CR + "i per tal de que puguin accedir a cumplimentar la informació relativa a la seva empresa," + CR + ...
"els hi subministrem la informació adient." + CR + CR + ...

" URL : " + PARAM.EMP_URL + CR + ...
" Usuari : " + wUsuari + CR + ...
" Contrasenya : " + wPsw + CR + CR + ...

"Atentament," + CR + PARAM.EMP_NOM

wCadena = "mailsender=" + PARAM.EMP_CORREU + ...
"&nomsender=" + PARAM.EMP_NOM + ...
"&Psw=" + wMeupsw + ...
"&Server=" + PARAM.EMP_SMTP + ...
"&Port=" + PARAM.EMP_PORT + ...
"&Desti=" + SUBCON.SBC_NOMCOM + ...
"&Recip=" + wTarget + ...
"&Subject=" + wAssumpte + ...
"&Msg=" + wCos1
// comprova existencia script
wDirectori = fCurrentDir()
PHPDisplay("http://www.cae171.com/L45/enviar-mailer.php",wCadena)

// EnviarCorreu(PARAM.EMP_CORREU,wMeupsw,PARAM.EMP_SMTP,PARAM.EMP_PORT, + ...
// SUBCON.SBC_NOMCOM,wTarget,wAssumpte,WCos1)

RETOUR

2. In Mail_convidats procedure I set all the variables I need and call via PHPDisplay() the script enviar-mailer.php (see below)

----------------------------------------- enviar-mailer.php ----------------------------

<?php

$mailsender = $_GET['mailsender']; // mail empresa CAE
$nomsender = $_GET['nomsender']; // Nom empresa CAE
$Psw = $_GET['Psw']; // Psw
$Server = $_GET['Server']; //servidor
$Port = $_GET['Port']; // Port
$nomrecip = $_GET['nomrecip']; // Nom desti a qui s'envia el mail
$mailrecip = $_GET['mailrecip']; // @ del destinatari
$subject = $_GET['Subject']; // Assumpte
$msg = $_GET['Msg']; // Cos del missatge

echo $Server;

// require("includes/class.phpmailer.php");

require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->From = $mailsender;
$mail->FromName = nomsender;
$mail->AddAddress($mailrecip); // Direccion de correo del cliente

// Aqui­ van los datos que apareceran en el correo que reciba

$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->Body = $msg;

// Datos del servidor SMTP

$mail->IsSMTP();
$mail->SMTPSecure = "tls";
$mail->Host = $Server; // Servidor de Salida.
$mail->Port = $Port;
$mail->SMTPAuth = true;
$mail->Username = $mailsender; // Correo Electronico
$mail->Password = $Psw; // Contrasena

if ($mail->Send()){
echo "<script>alert('Correu enviat correctament');location.href ='javascript:history.back()';</script>";
}
else {

echo $mail->ErrorInfo;
echo "<script>alert('Error al enviar el formulari');location.href ='javascript:history.back()';</script>";
}

?>

The echo "Hola"; doen not appears, so I guess tha the script in not execeuted. Any email is sent.

------------------------------------ conclusion --------------------------

All I need is to send a mail via SMTP.
Another trial I did is with the code

PROCEDURE EnviarCorreu(wNomUser,wPswUser,wServerSMTP,wPort,wDesti,wRecip,wSubject,wMissatge)

//EmailStartSMTPSession(wNomUser, wPswUser,wServerSMTP,wPort,False,emailOptionSécuriséTLS)
//EmailStartSession(gSessionSMTP)

EmailReset()

// Sender of the message
Email.Expéditeur = wNomUser

Email.NbDestinataire = 1
Email.Destinataire[1] = wRecip
Email.Cc = PARAM.EMP_CC // eliminar quan funcioni

// Subject and content of the message
Email.Subject = wSubject
Email.Message = wMissatge

//mail("aaa@bbb.es","Asunto","Este es el cuerpo del asunto")

IF EmailEnvoieMessage() = False THEN
Error(ErrorInfo())
END

// Close the SMTP session
//EmailCloseSession(wNomUser)
//fDelete("EmailContent.txt")

but I get an error in EmailEnvoieMessage() sentence because a parameter is expected but I do not which parameter is. The help from Pcsoft for this sentence does not include any parameter.

From your experience, which is the best way in order to send an email from my application?

Method 1 with PHPDisplay() or method 2 with EmailEnvoieMessage() ?

Again, thanks for your help.
Publicado el 06,agosto 2015 - 12:08
Hi

I'm happy to help, but you need at this point to learn how to help your
yourself. So, in order to do that:

1. ANSWER MY QUESTIONS, one by one. I have a good reason for asking
them, believe me
2. Do your testing in a simplified environment. In this case, create a
text button, and write ONE line in it: your phpdisplay with a fixed
parameter string for test. When THAT will work, you will be able to use
it for your real code.

As for the best way to proceed: do not work in php mode at all. It's
full of limitations and constraints. As you are in php mode, you are now
experiencing the pain and suffering of anybody who uses it.
I don't. Ever!

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Already there: WXShowroom.com, WXReplication (open source)
Coming soon: WXEDM (open source)
More information on http://www.fabriceharari.com

On 8/5/2015 10:33 AM, jbistuer wrote:
Hi Fabrice,
First of all, a lot of thanks again for your help.

I tell you, with images, the sequence I execute.

1. from a button in a cellule (attached code cellule) I call the
procedure Mail_convidats (attached code Mail_convidats).

----------------------------- code cellule
-------------------------------------

// Se valida email de reenvio
SI Length(NoSpace(Cellule_Mail.SAI_Mail_Reenvi)) >= 0 ALORS
w_OK_mail=Faux
w_OK_mail=ComprovarEmail(Cellule_Mail.SAI_Mail_Reenvi)
SI w_OK_mail=Faux ALORS
wVariable=Cellule_Mail.SAI_Mail_Reenvi..Libellé
Erreur(wVariable," "+"El mail ha d'estar informat i amb
format correcte.")
RETURN
FIN
FIN

reloj_arena..Visible=False

HLitRecherche(USER,USR_IDUSER,Cellule_Mail.Cellule_USR_IDUSER)
SI HTrouve()=Vrai ALORS
w_Parm_Pro = EnDecryp("D",USER.USR_PSW)
reloj_arena..Visible=Vrai
Mail_convidats(Cellule_Mail.Cellule_USR_IDUSER,w_Parm_Pro,wContracte,Cellule_Mail.SAI_Mail_Reenvi)
FIN
reloj_arena..Visible=Faux
// reloj_arena..Etat=Inactif

SBC_SLR001..Visible=Vrai
Cellule_Mail..Visible=Faux

--------------------------- Mail_convidats --------------------------------

PROCEDURE Mail_convidats(wUsuari,wPsw,wContrac,wTarget)

wRetorn is boolean
wAssumpte is a string
WCos is a string wCos1 is a string wCadena is a string
wMeupsw is a string
wDirectori is string
wMeupsw = EnDecryp("D",PARAM.EMP_PSW)

// ----------------- munta el cos del mail -----------------------
HReadSeek(CONTRACTES,CON_IDCONTRACTE,wContrac)
HReadSeek(SUBCON,USR_IDUSER,wUsuari)

wAssumpte = "Accés a l'aplicació CAE"
wCos1 = PARAM.EMP_POB + " , " +
DateVersChaîne(DateSys(),"JJ-MM-AAAA") + CR + CR + ...
"Benvolguts senyors," + CR + CR + ...
"Com a empresa participant al contracte esmentat a continuació:
" + CR + CR + " Obra : " +
CONTRACTES.CON_DESCRIPCIO + CR + ...
" Població : " + CONTRACTES.CON_POBOBR + CR +
CR + "i per tal de que puguin accedir a cumplimentar la informació
relativa a la seva empresa," + CR + ...
"els hi subministrem la informació adient." + CR + CR + ...

" URL : " + PARAM.EMP_URL + CR + ...
" Usuari : " + wUsuari + CR + ...
" Contrasenya : " + wPsw + CR + CR + ...

"Atentament," + CR + PARAM.EMP_NOM

wCadena = "mailsender=" + PARAM.EMP_CORREU + ...
"&nomsender=" + PARAM.EMP_NOM + ...
"&Psw=" + wMeupsw + ...
"&Server=" + PARAM.EMP_SMTP + ...
"&Port=" + PARAM.EMP_PORT + ...
"&Desti=" + SUBCON.SBC_NOMCOM + ...
"&Recip=" + wTarget + ...
"&Subject=" + wAssumpte + ...
"&Msg=" + wCos1
// comprova existencia script
wDirectori = fCurrentDir()
PHPDisplay("http://www.cae171.com/L45/enviar-mailer.php",wCadena)

//
EnviarCorreu(PARAM.EMP_CORREU,wMeupsw,PARAM.EMP_SMTP,PARAM.EMP_PORT, + ...
// SUBCON.SBC_NOMCOM,wTarget,wAssumpte,WCos1)

RETOUR

2. In Mail_convidats procedure I set all the variables I need and call
via PHPDisplay() the script enviar-mailer.php (see below)

----------------------------------------- enviar-mailer.php
----------------------------

<?php

$mailsender = $_GET['mailsender']; // mail empresa CAE
$nomsender = $_GET['nomsender']; // Nom empresa CAE
$Psw = $_GET['Psw']; // Psw
$Server = $_GET['Server']; //servidor
$Port = $_GET['Port']; // Port
$nomrecip = $_GET['nomrecip']; // Nom desti a qui
s'envia el mail
$mailrecip = $_GET['mailrecip']; // @ del destinatari
$subject = $_GET['Subject']; // Assumpte
$msg = $_GET['Msg']; // Cos del missatge

echo $Server;

// require("includes/class.phpmailer.php");

require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->From = $mailsender;
$mail->FromName = nomsender;
$mail->AddAddress($mailrecip); // Direccion de correo del cliente

// Aqui­ van los datos que apareceran en el correo que reciba

$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->Body = $msg;

// Datos del servidor SMTP

$mail->IsSMTP();
$mail->SMTPSecure = "tls";
$mail->Host = $Server; // Servidor de Salida.
$mail->Port = $Port;
$mail->SMTPAuth = true;
$mail->Username = $mailsender; // Correo Electronico
$mail->Password = $Psw; // Contrasena

if ($mail->Send()){
echo "<script>alert('Correu enviat correctament');location.href
='javascript:history.back()';</script>";
}
else {

echo $mail->ErrorInfo;
echo "<script>alert('Error al enviar el formulari');location.href
='javascript:history.back()';</script>";
}

?>

The echo "Hola"; doen not appears, so I guess tha the script in not
execeuted. Any email is sent.

------------------------------------ conclusion --------------------------

All I need is to send a mail via SMTP.
Another trial I did is with the code

PROCEDURE
EnviarCorreu(wNomUser,wPswUser,wServerSMTP,wPort,wDesti,wRecip,wSubject,wMissatge)


//EmailStartSMTPSession(wNomUser,
wPswUser,wServerSMTP,wPort,False,emailOptionSécuriséTLS)
//EmailStartSession(gSessionSMTP)

EmailReset()

// Sender of the message
Email.Expéditeur = wNomUser
Email.NbDestinataire = 1
Email.Destinataire[1] = wRecip Email.Cc = PARAM.EMP_CC //
eliminar quan funcioni
// Subject and content of the message
Email.Subject = wSubject
Email.Message = wMissatge

//mail("aaa@bbb.es","Asunto","Este es el cuerpo del asunto")
IF EmailEnvoieMessage() = False THEN
Error(ErrorInfo())
END

// Close the SMTP session
//EmailCloseSession(wNomUser)
//fDelete("EmailContent.txt")

but I get an error in EmailEnvoieMessage() sentence because a parameter
is expected but I do not which parameter is. The help from Pcsoft for
this sentence does not include any parameter.
From your experience, which is the best way in order to send an email
from my application?

Method 1 with PHPDisplay() or method 2 with EmailEnvoieMessage() ?

Again, thanks for your help.
Publicado el 15,marzo 2016 - 17:18
Hi Fabrice.
According to your instructions, I managed to run a PHP script from WB.
Now I only need one thing that I can not.
If I pass parameters with a fixed value, the PHP script works well. I do this via $_GET['parameter'] in the PHP script.
However the value of the parameter that must happen is a field of my page WB. In this case, els PHP script does not receive the value sent.
Please, can you help me how to do that?
Thank you very much again

Attach the instruction I run

PHPDisplay("../Llistats/Informe_1.php","nomobra=Nomobra&nivell0=Nivell0&contracte=Contracte")

In this case, I must pass the variables Nomobra, Nivell0 and Contracte.
Publicado el 16,marzo 2016 - 14:14
Hi Jordi,

Attach the instruction I run

PHPDisplay("../Llistats/Informe_1.php","nomobra=Nomobra&nivell0=Nivell0&contracte=Contracte")


In this case, I must pass the variables Nomobra, Nivell0 and Contracte.

Try with

PHPDisplay("../Llistats/Informe_1.php","nomobra="+Nomobra+"&nivell0="+Nivell0+"&contracte="+Contracte)


-BUT- if you don't know how to build a string like this one, I stronly
suggest that you START by studiying in DETAILS the tutorial

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com