PDA

View Full Version : Submitting to PHP


David REMD
06-08-2007, 10:15 AM
I am attempting to submit form data from AMS 6.0 to a mail.php file published on my website; that will then send an email to me containing the form data. I have attached a sample project with my notes and supporting help documentation. Any help in getting this to work would be greatly appreciated!

Tek
06-08-2007, 11:18 AM
Can we see what your mail.php file looks like?

Edit: Never mind... didn't see the accomanying documentation.

Taking a look...

Tek
06-08-2007, 11:43 AM
Ok I made it work but I changed your project and your mail.php file.

First, in your mail.php file you had a syntax error (missing a quote after the 'cell_phone' field) and I put all of the fields into one string called 'body'.

First, change your mailer command in your mail.php to look like this:

mail ("$to","$subject","$body");


Next, add in this line before your HTTP.Submit action in your project:

body = "First Name: "..first_name.."\r\nLast Name: "..last_name.."\r\nHome Phone: "..home_phone.."\r\nWork Phone: "..work_phone.."\r\nCell Phone: "..cell_phone.."\r\nProperty Address: "..property_address.."\r\nComments: "..comments


Then change the HTTP.Submit line to look like this:

HTTP.Submit("http://www.realestatemediadesign.com/mail.php", {subject="Form Data Submission",body=body}, SUBMITWEB_POST, 20, 80, nil, nil);


That should do it.

David REMD
06-08-2007, 11:56 AM
Thanks Tek! I'll give it a try.

David REMD
06-08-2007, 05:13 PM
Tek,

I can not get it to work. I must be doing something wrong.

You mentioned you made a change to both the project and mail.php file. What changes did you make to the project? Would you please post the project and mail.php that you made changes to? Thank you.

Tek
06-08-2007, 10:17 PM
David,

The changes I made to the project are in the last two pieces of code I posted. It's taken from your submit button actions.

The changes to the mail.php file are noted in the first line.

David REMD
06-09-2007, 08:29 AM
Tek,

Is this the way you have it setup?

<?php

// specify recipient email address
$to="info@realestatemediadesign.com";

$host="relay-hosting.secureserver.net"

// send our email
mail ("$to","$subject","$body");
?>

-- clear error variable
error = 0;

-- Get values from input fields
first_name = Input.GetText("first_name");
last_name = Input.GetText("last_name");
home_phone = Input.GetText("home_phone");
work_phone = Input.GetText("work_phone");
cell_phone = Input.GetText("cell_phone");
property_address = Input.GetText("property_address");
comments = Input.GetText("comments");

-- check for empty fields and deliver errors if needed
if String.Length(first_name) < 1 then
Dialog.Message("Error", "Please enter your first name and re-submit. Thank you.");
error = 1;
end
if String.Length(last_name) < 1 then
Dialog.Message("Error", "Please enter your last name and re-submit. Thank you.");
error = 1;
end
if String.Length(home_phone) < 1 then
Dialog.Message("Error", "Please enter your home phone and re-submit. Thank you.");
error = 1;
end
if String.Length(work_phone) < 1 then
Dialog.Message("Error", "Please enter your work phone and re-submit. Thank you.");
error = 1;
end
if String.Length(cell_phone) < 1 then
Dialog.Message("Error", "Please enter your cell phone and re-submit. Thank you.");
error = 1;
end
if String.Length(property_address) < 1 then
Dialog.Message("Error", "Please enter the property address and re-submit. Thank you.");
error = 1;
end

if error~=1 then
-- if no errors exist, send the email now and give a confirmation dialog

body = "First Name: "..first_name.."\r\nLast Name: "..last_name.."\r\nHome Phone: "..home_phone.."\r\nWork Phone: "..work_phone.."\r\nCell Phone: "..cell_phone.."\r\nProperty Address: "..property_address.."\r\nComments: "..comments

HTTP.Submit("http://www.realestatemediadesign.com/mail.php", {subject="Form Data Submission",body=body}, SUBMITWEB_POST, 20, 80, nil, nil);

Dialog.Message("Success", "Success, your info has been submitted.");
end

These are the changes I made. Am I still doing something wrong? It's still not working.

David REMD
06-09-2007, 01:53 PM
Okay, I removed the relay-hosting.secureserver.net from the mail.php file, submitted the completed form, and received an email. However, the email "subject" and "Body" was blank...none of the form data came through. What am I doing wrong? PLease help.:huh

David REMD
06-10-2007, 10:39 AM
Tek, I can't get this to work on my end. Please post the mail.php code, and the code behind the "submit" button. I will test it on my end. If it works, then all AMS users will benefit. Thank you! :)

RizlaUK
06-10-2007, 11:12 AM
just a tought..........

i dont know much about php but i once had problems with a email script and it turned out to be my server had smtp disabled.....


like i say.....just a tought

Tek
06-11-2007, 08:54 AM
David,

The only thing I did differently was to remove the '$host' line by commenting it out and changing the '$to' string to my own email address.

RizlaUK is right about the SMTP in PHP. It may be disabled so you might want to check it out or maybe test it again on another server.

David REMD
06-11-2007, 09:17 AM
Thanks to everyone that helped in supporting me! Since I could not get it to go through my godaddy.com account, I setup a designated hosting account with http://web.tera-byte.com/. I tested the form and the email came through just fine. Thanks again!:yes

Tek
06-11-2007, 09:19 AM
Ahh good to hear. :yes

rexzooly
09-21-2007, 11:00 AM
If you want to still do this i have a php scrip and amz for you to look at but
any changers to the amz better or for worse i would ask you to resubmit to me and also would ask the same for the php script.