Home   News  Product reviews  Website reviews  Forums   Competitions  Subscribe 


Web Building >> Web design & build
 |  Print Topic
Jump to first unread post. Pages: 1 | 2 | >> (show all)
splash
regular


Reg'd: Sun
Posts: 43
Need help with forms on our website
      #337764 - Tue Mar 13 2007 01:26 PM

I have a problem, I am trying to get a form on our camera club website that would allow members to complete, then click on a "submit" button to send it on to me. I have tried several combinations but just can get it to work. I have a test form set that you to look at on the camera club front page. If you go to www.klcameraclub.co.uk then scroll down a little you will see a icon (camera/flash man). If you click on that you will see what I am trying to achieve. This is only a rough draft, and I have plans to make several changes before using it, I am just trying to get it to work first. I am trying to get the completed form to go to www.my-entry@klcameraclub.co.uk this is an email address members have been already using for several weeks.

We have members with PC's & Mac computers and it seems to work for them, some mambers do have a problem, those who don't use MS outlook seem to have the most problems. The ISP is 34SP, any suggestions will be much appreciated.


Post Extras: Print Post   Remind Me!   Notify Moderator  
ianm
regular


Reg'd: Fri
Posts: 348
Loc: Colchester
Re: Need help with forms on our website [Re: splash]
      #337811 - Tue Mar 13 2007 06:10 PM

Your form can not send a the information as there is no script set to handle the information, I am going to take a gamble here and presume you have php installed on your server, if so here's how to make it work.

----Find------
<form name="form1" method="post" action="" enctype="multipart/form-data">

------Replace with----------
<form name="form1" method="post" action="txtmailer.php" enctype="multipart/form-data">

Copy the code below paste it into notepad or whatever text editor you use and change the 1st few lines to use your details, then save it as txtmailer.php if you use notepad then when you save as put the name txtmailer.php between "" to stop it getting a .txt extension. once done upload the new txtmailer.php to the same place where all you other webpages are and then test your form.



<?

// Default settings. Change these!
$address = 'youremail@whatever.com'; // Default address you want mail sent to
$subj = 'site feedback'; // Default subject to give to emails
$returnto = 'homepage.html'; // Default page people should be redirected to after mailing


//////////////

// Override defaults
$address = ($_POST['sendto'])?$_POST['sendto']:$address;
$subj = ($_POST['subject'])?$_POST['subject']:$subj;
$returnto = ($_POST['returnto'])?$_POST['returnto']:$returnto;

// if email address isn't present or is invalid, use TO address as FROM address.
if (eregi('^.+@.+\.[a-z]{2,6}',$_POST['email'])) {
$email = $_POST['email'];
$message = "Auto Mail from ".$email."\n\n";
}
else {
$email = $address;
$message = "Auto Mail from Anonymous\n\n";
}
foreach ($_POST as $key => $val) {
if ($key != 'returnto' && $key != 'email' && $key != 'subject' && $key != 'sendto') {
$message .= $key.': '.$val."\n";
}
}
$message = stripslashes($message);
if (@mail($address, $subj, $message,"From: ".$email)) {
if ($returnto) {
header('Location: '.$returnto);
}
else {
?><html><body><center><font color="green"><b>email sent!</b></font><p><a href="JavaScript:history.back()">Back</a></center></body></html><?
}
}
else {
?><html><body><center><font color="red"><b>there was a problem sending the mail</b></font><p><a href="JavaScript:history.back()">Back</a></center></body></html><?
}

?>


Post Extras: Print Post   Remind Me!   Notify Moderator  
splash
regular


Reg'd: Sun
Posts: 43
Re: Need help with forms on our website [Re: ianm]
      #338144 - Thu Mar 15 2007 07:10 PM

Hi Ian, many thanks for your advise, sorry for the delay in responding, it's all a bit over my head and I have been talking to a friend who has some experence in building small websites. We have looked at it together and think we have done what you suggested. But still this are not working correctly. My friend said:-

That looks good to me. I confess I can't read perl script like I can html. I'd be inclined to leave the unwanted text. I don't think it'll do any harm, and I'm not quite sure how many of those forward slashes should be left or removed if you remove the text!

I have removed some of your instruction text, perhaps this is why it's not working. Is it possible I can in some way send you the txtmailer.php file so you can check it?

I uploaded it to the 34SP website and it's along side all my folders for all my websites. I have three seperate sites. Cameraclub, Photographic and a homewatch/residents association.

When I click on SEND I get the error message:-

The webpage cannot be found
HTTP 404
Most likely causes:
There might be a typing error in the address.
If you clicked on a link, it may be out of date.

What you can try:
Retype the address.

Go back to the previous page.

Go to www.jcbwebsites.co.uk and look for the information you want.

More information

This error (HTTP 404 Not Found) means that Internet Explorer was able to connect to the website, but the page you wanted was not found. It's possible that the webpage is temporarily unavailable. Alternatively, the website might have changed or removed the webpage.

For more information about HTTP errors, see Help.


Post Extras: Print Post   Remind Me!   Notify Moderator  
splash
regular


Reg'd: Sun
Posts: 43
Re: Need help with forms on our website [Re: splash]
      #338295 - Fri Mar 16 2007 05:43 PM

Hi Ian, I have just moved the txtmailer.php file into the folder for the cameraclub website, (I think I should have done this in the first place). I think we are getting some progress. You will see if you try the "test form" on my website, that now when you click on submit the the error message is as follows:-

Parse error: syntax error, unexpected T_STRING in /usr/local/psa/home/vhosts/jcbwebsites.co.uk/httpdocs/2/txtmailer.php on line 5

Does this point to the problem ?


Post Extras: Print Post   Remind Me!   Notify Moderator  
ianm
regular


Reg'd: Fri
Posts: 348
Loc: Colchester
Re: Need help with forms on our website [Re: splash]
      #338310 - Fri Mar 16 2007 06:43 PM

Hi,
When you were getting the 404 error that is in fact a good sign, this at least proves the form is working, what i think is happening is the information is being sent somewhere then once this is done the script forwards the user to another page, my guess is you have not updated this correctly and hence the user gets forwarded to a page that does not exist and so the 404 error.

Have a look at the top few lines and change info to what you require, so something like

// Default settings. Change these!
$address = 'my-entry@klcameraclub.co.uk '; // Default address you want mail sent to
$subj = 'site feedback'; // Default subject to give to emails
$returnto = 'http://www.klcameraclub.co.uk'; // Default page people should be redirected to after mailing

DONT remove any / slashed just change the info between the quotes '', The error on line5 sounds like you have moved the Quotes to me, just paste the above few lines in place of what you have right now and see how it goes, The return to line right now is set to your site homepage, however once working it would be a nice idea to creast a new page saying something like you information has been sent and then make it so that users get forwarded to this page so they no the info has been sent if you get my drift.

Good luck


Post Extras: Print Post   Remind Me!   Notify Moderator  
splash
regular


Reg'd: Sun
Posts: 43
Re: Need help with forms on our website [Re: ianm]
      #338325 - Fri Mar 16 2007 07:30 PM

I have added the following:-

// Default settings. Change these!
$address = 'my-entry@klcameraclub.co.uk'; // Default address you want mail sent to
$subj = 'These are my entries for the King's Lynn Camera Club's Competition (as listed below)'; // Default subject to give to emails
$returnto = 'http://www.klcameraclub.co.uk'; // Default page people should be redirected to after mailing

//////////////

// Override defaults


and now I get the error message:-

Parse error: syntax error, unexpected T_STRING in /usr/local/psa/home/vhosts/jcbwebsites.co.uk/httpdocs/2/txtmailer.php on line 4

Perhaps I have changed to much again.


Post Extras: Print Post   Remind Me!   Notify Moderator  
ianm
regular


Reg'd: Fri
Posts: 348
Loc: Colchester
Re: Need help with forms on our website [Re: splash]
      #338410 - Sat Mar 17 2007 07:43 AM

Sounds likw something wrong in the overide settings which I wont go into for now, try and re-copy the script changing the top 3 settings again. beolow is something that should work, in the subject field i also removed the () as this tells php to look for a function and may have caused problems.
Copt and paste the below and see how it goes.

<?

// Default settings. Change these!
$address = 'my-entry@klcameraclub.co.uk'; // Default address you want mail sent to
$subj = 'These are my entries for the Kings Lynn Camera Clubs Competition as listed below'; // Default subject to give to emails
$returnto = 'http://www.klcameraclub.co.uk'; // Default page people should be redirected to after mailing


//////////////

// Override defaults
$address = ($_POST['sendto'])?$_POST['sendto']:$address;
$subj = ($_POST['subject'])?$_POST['subject']:$subj;
$returnto = ($_POST['returnto'])?$_POST['returnto']:$returnto;

// if email address isn't present or is invalid, use TO address as FROM address.
if (eregi('^.+@.+\.[a-z]{2,6}',$_POST['email'])) {
$email = $_POST['email'];
$message = "Auto Mail from ".$email."\n\n";
}
else {
$email = $address;
$message = "Auto Mail from Anonymous\n\n";
}
foreach ($_POST as $key => $val) {
if ($key != 'returnto' && $key != 'email' && $key != 'subject' && $key != 'sendto') {
$message .= $key.': '.$val."\n";
}
}
$message = stripslashes($message);
if (@mail($address, $subj, $message,"From: ".$email)) {
if ($returnto) {
header('Location: '.$returnto);
}
else {
?><html><body><center><font color="green"><b>email sent!</b></font><p><a href="JavaScript:history.back()">Back</a></center></body></html><?
}
}
else {
?><html><body><center><font color="red"><b>there was a problem sending the mail</b></font><p><a href="JavaScript:history.back()">Back</a></center></body></html><?
}

?>

Edited by ianm (Sat Mar 17 2007 07:46 AM)


Post Extras: Print Post   Remind Me!   Notify Moderator  
splash
regular


Reg'd: Sun
Posts: 43
Re: Need help with forms on our website [Re: ianm]
      #338434 - Sat Mar 17 2007 10:32 AM

Hi Ian, I pasted your text, and tried it (only filling in one of my fields, I did not get this I tried again filling in all my fields and I have just received the following:- (no error messages now)

Auto Mail from Anonymous

Competition_Name: Test two 10.23 - 170307
Competition_date: m
textfield: 1
textfield2: 2
textfield3: o
textfield32: p
textfield33: q
textfield34: r
textfield342: s

As was typing this the first one arrived:-

Auto Mail from Anonymous

Competition_Name: test sat 10am 17.03.07
Competition_date:
textfield:
textfield2:
textfield3:
textfield32:
textfield33:
textfield34:
textfield342:

Strange, as you can see 23 min after I sent the first one.

I obviously need to change the form expecially "Auto Mail from Anonymous" - Is that simple? It looks as if we have nearly got thing sorted. I am very gratful.


Post Extras: Print Post   Remind Me!   Notify Moderator  
ianm
regular


Reg'd: Fri
Posts: 348
Loc: Colchester
Re: Need help with forms on our website [Re: splash]
      #338534 - Sat Mar 17 2007 09:05 PM

The reason you are getting the anonymous message is because you have no field called email, right now all you text fields are called things like textfield textfield2 etc, if you change the name of these in the html of you form to email then when someone enters that email address it will tell you who sent the email, otherwise you get that message, not sure how your biulding your fom but in the html but if you create a new feild with the name email you should get a better responce.
When I set up forms i normally use a bit of javascript to make sure the email feild cant be left blank.
However overall the form is now sending information, the reason the email took so long to arrive could be many reasons but it wont be the form script.

By the way while on the subject of email on a webpage or forums always try not to put your email address there as it can be harvested by spam bots, there are a number of ways round this but the easiest way is to convert your email address to something that cant easily be picked up by spam bots.
Have a look at this page http://alicorna.com/obfuscator.html which you simply input your email address and the resulting output you paste straight onto the html of your webpage and the browser will render it as a readable email address but in the html the robot will not find it so easy.

Cheers


Regards

Edited by ianm (Sat Mar 17 2007 09:12 PM)


Post Extras: Print Post   Remind Me!   Notify Moderator  
splash
regular


Reg'd: Sun
Posts: 43
Re: Need help with forms on our website [Re: ianm]
      #338553 - Sat Mar 17 2007 11:26 PM

Hi Ian, I have left the test Icon in the same place so you can view my form. I have made a few changes. When I complete all the fields on a form I get somthing like:-

Auto Mail from Anonymous

Competition_Name: Open Slide 2
Competition_date: 19th March 2007
Membership_No_: 220
Members_Name:: John Barrett
Print_1_Title: sunset
Print_2_Title: Raining
P2_Type: Monochrome Print
Slide_1_Title: Sunshine
S1_Type: Colour Slide
Slide_2_Title: Wet Day
S2_Type: Monochrome Slide
Panel_Title: Port of Lynn
Pan_Type: Monochrome Slide Panel

Not all the fields are shown on the above. I did select them all. Why is Print 1 type, missing ?

Also when I click on submit from my computer, it seems to open up the website for a second time. It would be best if it went back to the home page. As a point of interest I have also copied the form etc, to the "Members only" page of the website, this works the same, but when I click on submit it gives me a blank white page (I can howver still see the top frame and the navagation buttons of by website). I don't know if it will work for the members yet, I will ask one of them to try it tomorrow. Thanks for help.
John


Post Extras: Print Post   Remind Me!   Notify Moderator  
ianm
regular


Reg'd: Fri
Posts: 348
Loc: Colchester
Re: Need help with forms on our website [Re: splash]
      #338559 - Sat Mar 17 2007 11:59 PM

Had a quick look at your form on your site but i cant see a form field called print 1 type, any form fields will be passed by the script so try and delete and put the field back in to make sure there are no problems with the html.

As for the site opening up in a new window, this will be another one of the problems with frames, I have not used frames for at least 5 years, if possbile try and build a page for your form in a standard webpage rather than in frames format, there may well be a way of doing it by adding a target= "framename" or something in the redirect bit of the mailer script but without some googleing and playing around i cant answer that one. By the way if your using frames because it means adding items to the menu is a simpler job when you add a new page then have a look at using include files but thats another topic.

Cheers


Post Extras: Print Post   Remind Me!   Notify Moderator  
splash
regular


Reg'd: Sun
Posts: 43
Re: Need help with forms on our website [Re: ianm]
      #338579 - Sun Mar 18 2007 08:09 AM

Hi Ianm, Thanks for sending the test form. I also received one from one member who I asked to test it. Both received OK. The members one had all the fields showing, I don't quite understand it, but for now I will leave it as it is. Thanks for the other info, we do not currently have any images sent for competitions, but somthing to think about in the future. I am using Dreamweaver 4, for your information. I had a quick look at your website, It's a great site. I like your navagation buttons on your home page, it make mine look very poor. Yours are so much larger and clearer. The only thing I need to sort if the form I receive, does NOT show an email address from the sender! Any chance of sending me the HTML code I need to add to the form, so members have to send an email address as a default.
Regards John


Post Extras: Print Post   Remind Me!   Notify Moderator  
ianm
regular


Reg'd: Fri
Posts: 348
Loc: Colchester
Re: Need help with forms on our website [Re: splash]
      #338580 - Sun Mar 18 2007 08:29 AM

Give this a try

<input name="email" type="text" size="23" maxlength="50">

You can change the size to suite.

Regards


Post Extras: Print Post   Remind Me!   Notify Moderator  
splash
regular


Reg'd: Sun
Posts: 43
Re: Need help with forms on our website [Re: ianm]
      #338594 - Sun Mar 18 2007 10:32 AM

Hi Ian, I have added yor suggestion, and it seems to work. How can I make this a required field ?

Post Extras: Print Post   Remind Me!   Notify Moderator  
ianm
regular


Reg'd: Fri
Posts: 348
Loc: Colchester
Re: Need help with forms on our website [Re: splash]
      #338600 - Sun Mar 18 2007 11:21 AM

Between the head tags in your html add this

<script>

/*
Check required form elements script-
By JavaScript Kit (http://javascriptkit.com)
Over 200+ free scripts here!
*/

function checkrequired(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements
if (tempobj.name.substring(0,8)=="required"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("You need to fill in at least the email box. Please complete then submit again!")
return false
}
else
return true
}
</script>

Adjust the alert message above to what you require in the above code.

Somewhere just inside your <form> tag add this

onSubmit="return checkrequired(this)"

So it will look something like this

<form action="txtmailer.php" method="post" enctype="multipart/form-data" onSubmit="return checkrequired(this)">

Now all you need to do is add the word required in front of your field names without a space so it will look like this

<input name="requiredemail" type="text" size="23" maxlength="50">

All you need to do is add the word required in front of any form feilds you wish to be required

Cheers


Post Extras: Print Post   Remind Me!   Notify Moderator  
splash
regular


Reg'd: Sun
Posts: 43
Re: Need help with forms on our website [Re: ianm]
      #338630 - Sun Mar 18 2007 02:09 PM

Hi Ian, I think I have done something wrong, I thought I had followed your instructions, but obviously not. Can you have a look at my form. Also should I have made any alterations to the txtmailer.php ?
John


Post Extras: Print Post   Remind Me!   Notify Moderator  
ianm
regular


Reg'd: Fri
Posts: 348
Loc: Colchester
Re: Need help with forms on our website [Re: splash]
      #338668 - Sun Mar 18 2007 07:19 PM

Could not see anything wrong at a glance but the problem is something to do with the function in the head section, delete that bit and re-paste it again from below and this should sort it

Cheers

<script>

/*
Check required form elements script-
By JavaScript Kit (http://javascriptkit.com)
Over 200+ free scripts here!
*/

function checkrequired(which){
var pass=true
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elements
if (tempobj.name.substring(0,8)=="required"){
if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
pass=false
break
}
}
}
}
if (!pass){
alert("You need to fill in at least the email & message box. Please complete both, then submit again!")
return false
}
else
return true
}
</script>


Post Extras: Print Post   Remind Me!   Notify Moderator  
splash
regular


Reg'd: Sun
Posts: 43
Re: Need help with forms on our website [Re: ianm]
      #338675 - Sun Mar 18 2007 07:49 PM

Hi Ian, I have done as you said, I completed the form not adding an email address, clicked on submit and it went without any query. I arrived shortly afterwards - something is obviously not quite correct. It did not ask me to complete the email address field. Sorry for the trouble this is causing you.

Post Extras: Print Post   Remind Me!   Notify Moderator  
ianm
regular


Reg'd: Fri
Posts: 348
Loc: Colchester
Re: Need help with forms on our website [Re: splash]
      #338868 - Mon Mar 19 2007 11:36 PM

Guess something must be going a miss in the copy and paste, have emailed you a working copy of your form.

Cheers


Post Extras: Print Post   Remind Me!   Notify Moderator  
splash
regular


Reg'd: Sun
Posts: 43
Re: Need help with forms on our website [Re: ianm]
      #339189 - Thu Mar 22 2007 07:04 AM

Hi Ian,I have uploaded your file and sending the form without an email is NOT now possible so that fine. Thanks - You will see my form has several fields, why do the none of the selection fields ("type of entry" fields) when completed come through when the fields are completed and form sent? If I highlight each one before sending them, thay do it's a bit strange.
John
PS I did reply to you emeil, thank you


Post Extras: Print Post   Remind Me!   Notify Moderator  
ianm
regular


Reg'd: Fri
Posts: 348
Loc: Colchester
Re: Need help with forms on our website [Re: splash]
      #339320 - Thu Mar 22 2007 11:53 PM

John
Sorry for the late reply have been a bit busy, I am not sure why the felds dont arrive unless highlighted, in fact I have never heard of this before and it should make no differance to the browser if the feilds are highlighted or not, if anyone else no differant I would like to know why.
The next step I would take is presume there is something not quite right with the html of the form, give it a check at http://validator.w3.org/ and see what errors you get.You can run just the form feilds though the manual input, if this comes up clean then I am at a loss.

Cheers


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1 | 2 | >> (show all)

Rate this topic

Jump to


Extra information
0 registered and 2 anonymous users are browsing this forum.

Moderator:  putasolutions, Joe_London, greysts, bricat, Nanook, Hello_There, John_McKenna, Mouse, TheFatControlleR 


Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      Mark-up is enabled

Rating:
Topic views: 0

Contact Us | Privacy statement Main website