Quote from
luishp on March 23, 2020, 4:29 pm
Where do we find the Server script "myscript.php" and how to use it with the "Form" object to get the information of the person.
Hi @rocote, that script should be coded by you, depending on what information and how you want to store or send the information, the script could be quite different. This is a sample code for sending the form data through email:
<?php
//Header required when app and php are of different origins
header("Access-Control-Allow-Origin: *");
$message="";
if($_SERVER["REQUEST_METHOD"] === "POST") {
foreach ($_POST as $key => $value){
$message .= "".htmlspecialchars($key).": ".htmlspecialchars($value)."\r\n";
}
$to = "somebody@example.com";
$subject = "My subject";
$headers = "From: webmaster@example.com" . "\r\n" . "CC: somebodyelse@example.com";
mail($to,$subject,$message,$headers);
}else{
$result = "INVALID DATA";
echo $result;
}
echo "EMAIL SUCCESSFULLY SEND";
?>
Just change $to, $subject and $headers variables and save it into a text file with name "myscript.php". Then upload it to your web server. Also use something like this on your form action property:
https://yourdomain.com/yourfolder/senddata.php
Regards.
Where do we find the Server script "myscript.php" and how to use it with the "Form" object to get the information of the person.
Hi @rocote, that script should be coded by you, depending on what information and how you want to store or send the information, the script could be quite different. This is a sample code for sending the form data through email:
<?php
//Header required when app and php are of different origins
header("Access-Control-Allow-Origin: *");
$message="";
if($_SERVER["REQUEST_METHOD"] === "POST") {
foreach ($_POST as $key => $value){
$message .= "".htmlspecialchars($key).": ".htmlspecialchars($value)."\r\n";
}
$to = "somebody@example.com";
$subject = "My subject";
$headers = "From: webmaster@example.com" . "\r\n" . "CC: somebodyelse@example.com";
mail($to,$subject,$message,$headers);
}else{
$result = "INVALID DATA";
echo $result;
}
echo "EMAIL SUCCESSFULLY SEND";
?>
Just change $to, $subject and $headers variables and save it into a text file with name "myscript.php". Then upload it to your web server. Also use something like this on your form action property:
https://yourdomain.com/yourfolder/senddata.php
Regards.
Vadim has reacted to this post.