PDA

View Full Version : Forms Tutorial Part 1 Q & A



ilanit
07-26-2006, 02:47 AM
To the Administrator.
I read all theInstructions above and I have two questions.
1. when I write in the filed Action: contact php and all the Instructions after, this is actually php script for from?
2.If I have form with 60 fields,I do exactly the same thing or maybe this code fit only to small form with few fields.
Thanks.
Ilanit

Andy128
07-26-2006, 03:13 AM
Not an administrator, but I'll give this one a wack....

1. Yes- contact.php is php script that will collect the data from the form and send it to your e-mail.

2. Yes- this script is designed to collect all fields and send that data to your e-mail.

Andy

ilanit
07-26-2006, 06:08 AM
To Andy.
Thank you very much for your answer.
Ilanit

fabbers
08-02-2006, 07:50 AM
Thank you both for the replies! I have only 2 more questions...
In the script can I change the english field: $name, $address etc. for $naam, $adres? This is Dutch and since the website is initially in dutch that would suit the buttons better. the other thing is if I name the formfield button something different than submit does it work as well or do I need to change that as well?

thanks again for all the patience.....
Fabbers

navaldesign
08-02-2006, 07:57 AM
The above described script can be modified to implement a simple autoresponder, that will send your visitor a copy of the email that you will be receiving: this is done by adding some lines of code. See how this modified script could be:



<?PHP
$email = $HTTP_POST_VARS[email];
$mailto = "order@example.com";
$mailsubj = "Enter Your Subject Here";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form :\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
if ($key!="submit")
{
$mailbody .= "$key : $val\n";
}
}
mail($mailto, $mailsubj, $mailbody, $mailhead);


// Autoresponder
$mailto = $email;
$mailsubj = "Copy of the info you Sumbitted";
$mailhead = "From: your company name or domain name or your email or whatever you want\n";
reset ($HTTP_POST_VARS);
$mailbody = "Thankyou for your Submission. This is the info you have submitted:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
if ($key!="submit")
{
$mailbody .= "$key : $val\n";
}
}
mailbody . = "This is an automatically created message. If an answer is required, we will be back to you ASAP.\n";
mail($mailto, $mailsubj, $mailbody, $mailhead);
?>

As usual, change the part in blue with your own values.

Please note that the autoresponder will only work if the visitor's email field is named "email"

navaldesign
08-02-2006, 08:19 AM
Thank you both for the replies! I have only 2 more questions...
In the script can I change the english field: $name, $address etc. for $naam, $adres? This is Dutch and since the website is initially in dutch that would suit the buttons better. the other thing is if I name the formfield button something different than submit does it work as well or do I need to change that as well?

thanks again for all the patience.....
Fabbers

Yes you can. the only field you need to leave as it is, is the email field. Please also make sure to name your Submit button "submit", all lowercase letters. The value, which is what will appear on the button, can be anything

fabbers
08-02-2006, 08:42 AM
Thanks a million Navaldesign!
I am going to try all over again!
Could you please be so kind to help me on these last topics? I would be really greatful!
1.What would be the scriptline for a telephonenumber field?
2.If you past the html block into your page and paste the script into that would webvisitors see that html block or can you arrange it to the back so it is out of view?

Thank you again for all the trouble of helping me out!

Fabbers

navaldesign
08-02-2006, 08:55 AM
1. This script is a generic one, based on a loop. It does not look for the filed titles, nor the values. So you can simply add a Field for the telephone number in your form, and the script will automatically include in the email, both the field title (that could be named, f.e. "Telephone_Number" and the value filled in by the visitor. The same goes FOR ANY OTHER FIELD you may wish to add in your form. You can have AS MANY FIELDS AS YOU WANT.
2. No, visitors cannot see the HTML block. They can only see what the effect of the code pasted is (if any). In this case, being it a php script with no html visual part or echo / print commands, the script will produce absolutely none visual effect.

However, pasting the script in a HTML block (or box) has excactly the same result as pasting it directly in the page HTML (in the inside body Tag, as suggested in the tutorial) but it also adds some useless HTML Tags

Nite Producer
08-02-2006, 05:54 PM
AHHHHHHHHHHH,

What I can say guys,tank you thank you thank you, I'vewaitig for ths for so long, tat's really helping people who are nw in coding and scripts, I've tryed it and it works 1000000000000 per cent.

Thank yo again.

Before I leave I have a question to Navaldesign

1 - The script you added for the autoresponder should I past it in he inside body tag with the first one?
2 - ist does matter how many space I leave between the first script and the second?

Thanks

navaldesign
08-02-2006, 06:08 PM
1 - The script you added for the autoresponder should I past it in he inside body tag with the first one?

You should better delete completely the one you have, and paste the new one, putting your own details in it, then pasting it in the Inside Body Tag of your action page HTML.

2 - ist does matter how many space I leave between the first script and the second?
Doesn't matter. The server simply ignores blank lines.


Thanks

Hope this helps

Nite Producer
08-02-2006, 06:10 PM
Thanks Navaldesign,

You guys are the best.

Nite Producer
08-02-2006, 06:16 PM
But still another question:

in my form there is two e-mail field, one is for personal e-mail and the second is for the company e-mail, so is the script detect e-mails directly and send it to them or I have to change something in the script to read the different field names, cause I named them differently than just e-mail.

Thanks

navaldesign
08-02-2006, 06:18 PM
The main one, which will also be used for the autoresponder to send the mail to, must be called "email". This will also result in the "From" field of the email that you will receive. You can name the second email field whatever you want: "Second_email", "Home_email" etc.

Nite Producer
08-02-2006, 06:23 PM
Thank you so much navaldesign

navaldesign
08-02-2006, 06:26 PM
You are very welcome

rayvern
08-11-2006, 06:48 PM
I really do appreciate the help. I have followed the instructions to a tee and still when I click on the submit button it goes to a page cannot be displayed. I did have my personal email entered in and it would go to my email page but didn't send it. I also wonder how long it takes for everything to publish because when I make changes they sometimes don't change but later I see some changes but not all. Sorry I am such a novice but I am proud of the way the site is developing. Did't know I could do this. Is there anyway for you to look at my site and tell me where I am failing to understand. I have a page called contact us and have navigation buttons. When I click on home it will sometime go to the home page and sometmes it won't. My site link is http://www.banklinkusa.net and I would be glad to give my login info for the help.Thank you

navaldesign
08-11-2006, 07:18 PM
Your links back to home work ok both from the form and the thankyou page. However, you have put the php script in the form page, whilst it is not needed there. Being it php, i can-t see if you have also put it in the acrion.php page, as you should have. Use my form (http://www.navaldesign.info/feedback13.html)to send me your loggin info so i can have a look.

terrys
08-17-2006, 03:47 AM
Iíve been working on this problem for about 12 hours and canít get it solved. My submit button does nothingÖ
The site is http://www.digitalcraftsmanweb.com
I have a form at http://www.digitalcraftsmanweb.com/digital/cost_request.html (http://www.digitalcraftsmanweb.com/digital/cost_request.html) . In the Form Properties box:
Form Name: Request Form
Action: process123.php
Method: Post
Encoding type: multipart/form-data
Then I developed my "go to" page with downloads for my clients. The page is saved as Download. The Page Properties box has
Title: process123
File ext: php
In the html for this page, I put the following Inside the Body Tag:
<?php
$name=$HTTP_POST_VARS[Practice];
$mailto="terry@digitalcraftsmanweb.com";
$mailsubj="Request for a Cost Analysis";
$mailhead="From: $name";
reset($HTTP_POST_VARS);
$mailbody="Values submitted from web site form:\n";
while (list($key,$val)=each($HTTP_POST_VARS))
{
if($key!="submit")
{
$mailbody.="$key:$val\n";
}
}
mail($mailto,$mailsubj,$mailbody,$mailhead);
?>
The only change between this script and the one shown in the forum after the first tutorial is $name=$HTTP_POST_VARS[Practice]; instead of $email=$HTTP_POST_VARS[email];
Practice is thetag for the field indicating who is requesting the analysis.
Looking at the files through BlueVoda FTP, I have a cost_request.html and a download.php. Can anyone tell me what Iíve done wrong?

Andy128
08-17-2006, 04:07 AM
It appears that you have placed elements out side the form itself. Click on the form to get form properties and change the background color to grey for the moment. You will see that the submit button as well as other elements are not on the form itself. This you must change first. Delete the elements not on the form and then extend the form down. Now put the elements back on the form. When all done- change the background color back to white. Save and publish.


As to the "go to" page. Please explain this.

In order for your form to be processed- it needs a php page called process123.php with the necessary php script to grab all the data and send it to you via e-mail and then re-direct the user to another page.

Perhaps take a look at one of my php mailto tutorials here:
http://netisopen.com/computer/web/webpagestuff.html

Maybe that will make things a little clearer.

Andy

terrys
08-17-2006, 05:01 AM
Thanks, Andy!
It's late and I've got a full day teaching tomorrow, but I'llgive this a try as soon as I get home. ... By the by, I did follow the PHP Mailto Form instructions, but then reverted to the simpler script under Important Notes following Tutorial 1. I'll do a comparison of the 2 procedures after I fix the "not on the form" problems and then repost.

Terry

navaldesign
08-17-2006, 06:55 AM
Yes, but your main problems are script independent.
Problem #1: As Andy said, some of the form elements are outside the form area, so they are ignored. Most important, the Submit button is ouside the form area.
Problem #2. You have set the form action in "process123.php" so when you submit, the server will look for the "process123.php" file to process your form info. But there is no such page because you have saved it as "download" and ofcourse it has been published as "download.php". The name "process123" in the Title of Page Properties is just the page Title, for SE and for appearing in IE's address bar, but it is not what your form is looking for. Please open the "download" page in BV, save it as "process123" and publish it. OR, change the form action in "download.php"

There are some differences between Andy's script and the simple one posted in the above tutorial. Andy's script has some security features in it, and it also performs a field validation. But, as all similar scripts, Andy's script will perform these actions if the fields are named properly, if the fields are named differently, or if you have more fields to validate, or if you need a different type of validation, the script has to be customized accordingly

terrys
08-18-2006, 01:37 AM
I really appreciate the help...
I re-created the cost-request.html so all elements lie within the form grid. On the cost-request properties, the action is error.php. Then I created an error page and gave it the extension php, pasted the script into the custom HTML box, saved & published.

The submit button now calls the error page. But when I leave the Practice Name blank, the error page says "go back and fill it in". When I do that, it then tells me to fill in the address...which is already complete. So there must be a problem in the error-checking script, although I cannot find it.
??

Also, once all the data has been checked and the info is sent to me via email, how do I automatically call up the download.html page for the client? (site = http://www.digitalcraftsmanweb.com)

Andy128
08-18-2006, 02:56 AM
if you can- copy the php script that you used and paste it in this tread and we will compare the script to the form. More than likely- if it is asking you to fill in a field that is already filled in- there are spelling differences between the field name and the script.

Andy

terrys
08-18-2006, 03:14 AM
Here is the script I copied onto the error.php page:

<?php
$numberclaims=$HTTP_POST_VARS['claims'];
$name=$HTTP_POST_VARS['practice'];
$address=$HTTP_POST_VARS['address'];
$phone=$HTTP_POST_VARS['telehone'];
$contact=$HTTP_POST_VARS['contact'];
if(strlen($numberclaims)==0)
{
echo "Please use the Back button to return to the form and enter how many claims your office files each month. Thank you.";
exit;
}
if(strlen($numberclaims)>=8)
{
echo "There appear to be too many characters in the Number of Claims per Month. Please use the Back button to return to the form and shorten the entry. Thank you.";
exit;
}
if(strlen($name)==0)
{
echo "Please use the Back button to return to the form and enter the name of your practice. Thank you.";
exit;
}
if(strlen($name)>=100)
{
echo "There appear to be too many characters in the Name field. Please use the Back button to return to the form and shorten the entry. Thank you.";
exit;
}

if(strlen($address)==0)
{
echo "Please use the Back button to return to the form and enter the address of your practice. Thank you.";
exit;
}
if(strlen($address)>=175)
{
echo "You have placed too many characters in the Address field. Please use the Back button to return to the form and shorten the entry. Thank you.";
exit;
}

if(strlen($phone)==0)
{
echo "Please use the Back button to return to the form and enter a telephone number where we can contact you. Thanks!";
exit;
}
if(strlen($phone)>=20)
{
echo "There appear to be too many characters in the Telephone field. Please use the Back button to return to the form and shorten the entry. Thank you.";
exit;
}

if(strlen($contact)==0)
{
echo "Please use the Back button to return to the form and enter a primary contact whom we should call. Thank you.";
exit;
}

if(strlen($contact)>=75)
{
echo "There appear to be too many characters in the Contact field. Please use the Back button to return to the form and shorten the entry. Thank you.";
exit;
}


$name=$HTTP_POST_VARS[practice];
$mailto="terry@digitalcraftsmanweb.com";
$mailsubj="Request for a Cost Analysis";
$mailhead="From: $name";

reset($HTTP_POST_VARS);
$mailbody="Values submitted from web site form:\n";
while (list($key,$val)=each($HTTP_POST_VARS))
{
if($key!="submit")
{

$mailbody.="$key:$val\n";
}
}
mail($mailto,$mailsubj,$mailbody,$mailhead);
?>

Again, the site address is www.digitalcraftsmanweb.com (http://www.digitalcraftsmanweb.com)

terrys
08-18-2006, 03:16 AM
Don't know where the box came from when I pasted
if(strlen($numberclaims)>=8

Terry

terrys
08-18-2006, 03:45 AM
I can't find a problem with the address script, but there is a mispelling of 'telephone' in the $phone=$HTTP_POST_VARS['telehone'];

I'll correct that once we determine what the basic problem is. Would like to insert at the same time whatever code is needed for the final redirect to the download.html page.

Terry

Andy128
08-18-2006, 04:20 AM
I don't understand the re-direct to download.html?

What is download.html? I don't see that page on your site.

Give me a URL where you are needing the customer to go after they submit the form and a message is posted - Thank you - your info has been submitted and we will get back to you soon.

Andy

terrys
08-18-2006, 04:36 AM
Andy -
The sole purpose of this site is to collect data from medical practitioners so I can prepare a cost analysis showing the benefit of electronic claims billing. As an enticement for them to provide me with the data, I am offering 5 free gifts.

The download page (www.digitalcraftsmanweb.com/digital/download.html (http://www.digitalcraftsmanweb.com/digital/download.html)) cannot be accessed until the data I need is harvested from the form. When the practitioner completes the form and clicks "Submit", I want them to be taken to the download page where they can download the free gifts.

Does that help?
Terry