Any ideas on what my PHP file should look like...

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

raemay
Posts: 19
Joined: Sat May 11, 2013 12:05 am

Re: Any ideas on what my PHP file should look like...

Post by raemay » Thu Jul 11, 2013 10:26 pm

but have also tried this:

on sendMail
if the hilite of button "IAgree" then
put empty into myFormData
put libUrlMultipartFormData(myFormData, \
"rcpnt" & ("~@~.com"), \
"subj","LoanApp", \
"cu",(the selectedText of button "CUlist"), \
"mn",(field "MembNmbr"), \
"ff",(field "FirstField"), \
"lf",(field "LastField"), \
"tf",(field "teleField"), \
"af",(field "AltField"), \
"ef",(field "EmailField"), \
"if",(field "IncomeField")) \
into myError
if myError is empty then
set the httpHeaders to line 1 of myFormData
post line 2 to -1 of theFormData to URL "~://~.~/downloads/App/App.php"
put the result into rslt
if rslt is empty then
beep
answer information "Submitted successfully"
else
beep
answer rslt
end if
else
beep
answer error "Can't submit data because of error:" && myError
end if
end if
end sendMail

<?php
$rcpnt="rachel@oaktreebiz.com";
$subj=$_POST["subj"];
$cu=$_POST["cu"];
$mn=$_POST["mn"];
$ff=$_POST["ff"];
$lf=$_POST["lf"];
$tf=$_POST["tf"];
$af=$_POST["af"];
$ef=$_POST["ef"];
$if=$_POST["if"];
$s=" "; //space
$msg=$cu.$s.$mn.$s.$ff.$s.$lf.$s.$tf.$s.$af.$s.$ef.$s.$if;

$header = "MIME-Version: 1.0\r\n" .
"Content-type: text/plain; charset=latin-1\r\n" .
"\r\n";

$rslt = mail($rcpnt,$subj,$msg,$header);
if (!$rslt)
echo 'An error occurred';
else echo 'Mail sent';
?>

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Any ideas on what my PHP file should look like...

Post by Mark » Sat Jul 13, 2013 6:48 pm

Hi Rae,

I have made a few small corrections to my original script. This is the new LiveCode script:

Code: Select all

on sendMail
   if the hilite of button "IAgree" then
      put empty into myFormData
      put libUrlMultipartFormData(myFormData, \
            "rcpnt", ("recipient@economy-x-talk.com"), \
            "subj","LoanApp", \
            "cu",(the selectedText of button "CUlist"), \
            "mn",(field "MembNmbr"), \
            "ff",(field "FirstField"), \
            "lf",(field "LastField"), \
            "tf",(field "teleField"), \
            "af",(field "AltField"), \
            "ef",(field "EmailField"), \
            "if",(field "IncomeField")) \
            into myError
      if myError is empty then
         set the httpHeaders to line 1 of myFormData
         post line 2 to -1 of myFormData to URL "http://economy-x-talk.com/rae/rae.php"
         put the result into rslt
         put the urlResponse
         if rslt is empty then
            beep
            // answer information "Submitted successfully"
         else
            beep
            // answer rslt
         end if
      else
         beep
         answer error "Can't submit data because of error:" && myError
      end if
   end if
end sendMail
This is the PHP script:

Code: Select all

<?php
$rcpnt = $_POST['rcpnt'];
$subj = $_POST['subj'];
$cu = $_POST['cu'];
$mn = $_POST['mn'];
$ff = $_POST['ff'];
$lf = $_POST['lf'];
$tf = $_POST['tf'];
$af = $_POST['af'];
$ef = $_POST['ef'];
$if = $_POST['if'];
$s = ' ';
//space
$msg = $cu . $s . $mn . $s . $ff . $s . $lf . $s . $tf . $s . $af . $s . $ef . $s . $if;
$header = "From: Your Name <mail@economy-x-talk.com>\r\n" . "MIME-Version: 1.0\r\n" . "Content-type: text/plain; charset=latin-1\r\n" . "\r\n";

$rslt = mail($rcpnt, $subj, $msg, $header);
if (!$rslt)
    echo "An error occurred in: $msg\r\n$rcpnt\r\n$subj";
else
    echo 'Mail sent';
?>
and this is the script without From header:

Code: Select all

<?php
$rcpnt = $_POST['rcpnt'];
$subj = $_POST['subj'];
$cu = $_POST['cu'];
$mn = $_POST['mn'];
$ff = $_POST['ff'];
$lf = $_POST['lf'];
$tf = $_POST['tf'];
$af = $_POST['af'];
$ef = $_POST['ef'];
$if = $_POST['if'];
$s = ' ';
//space
$msg = $cu . $s . $mn . $s . $ff . $s . $lf . $s . $tf . $s . $af . $s . $ef . $s . $if;
$header = "MIME-Version: 1.0\r\n" . "Content-type: text/plain; charset=latin-1\r\n" . "\r\n";

$rslt = mail($rcpnt, $subj, $msg, $header);
if (!$rslt)
    echo "An error occurred in: $msg\r\n$rcpnt\r\n$subj";
else
    echo 'Mail sent';
?>
All tested and approved ;-)

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

raemay
Posts: 19
Joined: Sat May 11, 2013 12:05 am

Re: Any ideas on what my PHP file should look like...

Post by raemay » Mon Jul 15, 2013 7:19 pm

Awesome! Works perfectly. Thank you so Much Mark. All this you did on a Saturday and everything. I am so thankful. I bet this will come in handy for many users.
Sincerely,
Rae

raemay
Posts: 19
Joined: Sat May 11, 2013 12:05 am

Re: Any ideas on what my PHP file should look like...

Post by raemay » Mon Jul 15, 2013 7:23 pm

Is there a way I can give you any "kudos" Mark? You have made made my week.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Any ideas on what my PHP file should look like...

Post by Mark » Wed Jul 17, 2013 12:25 am

Hi Rae,

I'm happy to help, it wasn't that difficult actually. Just... if you like my explanations, perhaps you'd like my book as well ;-)

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply