Forum Moderators: coopster & phranque

Message Too Old, No Replies

Replying to Form Enquiries - sender's email shows as my site

Problem with forms

         

feemgh

12:44 pm on Jun 23, 2003 (gmt 0)

10+ Year Member



I have build a form that works! Good start, the problem is that when someone completes the form and sends it to me the sender's email address is info@myurl.co.uk rather than their email address i.e. joebloggs@xxx.co.uk.

It means that I cannot reply directly without cutting and pasting the email address from the form....

How can I change this?

It may be something to do with this..

<input type="hidden" name="from" value="www.myurl.co.uk">

I am using html, asp and cgi.

Any help would be greatly appreciated.

Cheers

F

korkus2000

12:46 pm on Jun 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What are you using to process the form?

BlobFisk

12:48 pm on Jun 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It looks like you need to populate the sender field in your server side mail creation code with the email address that the user specifies.

For example, in ASP using CDONTS:


set mailobj = server.CreateObject("CDONTS.Newmail")
mailobj.From = FromEmailAddress

Where the variable FromEmailAddress is got from the form.

HTH

aus_dave

12:53 pm on Jun 23, 2003 (gmt 0)

10+ Year Member



You didn't mention if you are using a free script or if you coded it yourself.

I use a free PHP script for email forms. If the form has a field for the person's name and email address, the email I would receive has 'Joe Bloggs <joe@bloggs.com>' in the From field.

I'm no code wizard but your form script needs to be able to reference the form fields (variables) that your user inputs into each text box, which are then passed through to the form processing script.

It is worth spending some time finding a secure script as they are commonly exploited by hackers :).

feemgh

1:14 pm on Jun 23, 2003 (gmt 0)

10+ Year Member



Thanks for all your help...still not too sure though!

The code for the form is very basic - html really as host provides the cgi-bin/sendform.pl instructions.

This is the bones of the code that I have used:-

<form method="post" action="http://www.host.co.uk/cgi-bin/sendform.pl">
<input type="hidden" name="to" value="info@myurl.com">
<input type="hidden" name="from" value="www.myurl.com">
<input type="hidden" name="subject" value="Enquiry">
<input type="hidden" name="successpage" value="http://www.myurl.com/thankyou.htm">

So, not too sure what I can do - host advised that I need extra coding but not very helpful when you don't know much about coding!

Again any help with very basic instructions would be great.

many thanks again

feemgh

jaski

1:48 pm on Jun 23, 2003 (gmt 0)

10+ Year Member



Its a perl script. You will need to make a modification in that.

1) Figure out where the "from" field is getting its value.

You said you get emails with from = info@myurl.co.uk
so you have to see where is value "info@myurl.co.uk" getting set.

2) If you are able to figure out that .. you need to make an appropriate change there ..

that change will be some thing like

$from = $from_value_entered_by_joe_user; //value entered in form

<edit typo>

feemgh

2:46 pm on Jun 23, 2003 (gmt 0)

10+ Year Member



Thanks Jaski

Does that mean that I should change this line of code...

<input type="hidden" name="from" value="www.myurl.com">

The problem is that the host provides the scripts - so does this limit the possibilities to alter the code?

Sorry to be so niaive .... just fumbling about in the dark here....I know nothing about perl....

Cheers

feemgh

killroy

12:15 am on Jun 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



try removing the hidden from field and rename the field where the user enters his email to "from" that should do the trick as far as I can tell from the bits you posted.

try posting the whole form code

SN

feemgh

8:35 am on Jun 24, 2003 (gmt 0)

10+ Year Member



Thanks Killroy but that doesn't seem to have worked either...

Here is all the code for my form...

If you can help I would be very grateful...thanks in anticipation...

feemgh
------------------------------------------------------------

<form name="enquiries" method="post" action="http://www.host.co.uk/cgi-bin/sendform.pl" onSubmit="MM_validateForm('forename','','R','surname','','R','email','','R','telephone','','R','referrer','','R');return document.MM_returnValue">

<input type="hidden" name="to" value="info@myurl.co.uk">
<input type="hidden" name="from" value="www.myurl.co.uk">
<input type="hidden" name="subject" value="Enquiry">
<input type="hidden" name="successpage" value="http://www.myurl.co.uk/thankyou.html">
<center>

<b>E-mail:</b>
<input type="text" name="from" size="35" maxlength="50">

[edited by: jatar_k at 3:39 pm (utc) on June 24, 2003]
[edit reason] removed all unnecessary code [/edit]

jaski

8:52 am on Jun 24, 2003 (gmt 0)

10+ Year Member



Hi feemgh
This is the place where user is entering email id

<input type="text" name="from" size="35" maxlength="50">

So this should be setting up a variable "$from" when the form is submitted to this script.

You need to use it where email is being sent in your script.

PS: If it still causes a problem then

>><input type="hidden" name="from" value="www.myurl.co.uk">

This looks like an extra line which should not be there .. two form fields having same name "from" is not a good idea .. though I guess it should not be causing problem in this case because it appears first .. but try deleting this line any way.

killroy

9:16 am on Jun 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well , as I said, remove the hidden from line, as it seems to supply the from email address already. then it should take teh from info from your visible fom field and use that.

From your post I tried it in my own scripts, and it worked like a charm. (I didn'T even know about this, as it'S basically faking the FROM info) Forward, replies and all work fine now.

PS also try to cut down on those font tags. and next time you post a form in a forum, please take the time and remove the formatting codes, thanks.

SN

feemgh

9:40 am on Jun 24, 2003 (gmt 0)

10+ Year Member



Killroy, when I removed the "hidden" and "value" from this line

<input type="hidden" name="from" value="www.myurl.co.uk">

and swapped the email in this line to "from"

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

a box was added to the top of the form that I did not want....

Is that happening on your screen?

It also did not work i.e. I am still waiting for the form to arrive 1 hour later!

thanks

feemgh

PS Sorry about the length of the code - I did spend ages trying to make it look neater but never thought to take out <font> tags etc ...wil next time...!

feemgh

9:53 am on Jun 24, 2003 (gmt 0)

10+ Year Member



Hi all and thanks for your help...

Jaski....a bit of your solution and a bit of Killroy's solutions have worked.

I have removed this line...

<input type="hidden" name="from" value="www.myurl.co.uk">

and swapped "from" for email in this section....i.e.

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

And it seems to work.....

FANTASTIC

Many thanks all for your patience and persistence.

feemgh

ShawnR

10:29 am on Jun 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It looks like a lot of guess work has been going on here... We are guessing what the perl cgi script which handles the form is doing... If it is similar to Matt Wright's FormMail or a clone thereof (probably one of the most popular in use by many ISPs), then the problem is that the line:

<input type="text" name="from" size="35" maxlength="50">

should be:

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

The hidden vs not hidden is a red herring. Whether a field is hidden or not makes no difference to how it is processed by the form cgi.

To test it, cut down the form to the bare minimum as follows:

<form action="http://http://www.host.co.uk/cgi-bin/sendform.pl" method=post>
<input type="hidden" name="to" value="info@myurl.com">
<input type="hidden" name="from" value="A potential customer">
<input name="email">
<input type="hidden" name="subject" value="Testing my email form">
<input type="hidden" name="successpage" value="http://www.myurl.com/thankyou.htm">
<input type=submit>
</form>

But really, the best way to debug this would be to look at the perl script and see what field it wants for the reply-to address, rather than try to guess. Can you download it from your ISP?

Shawn

[added: Whoops... I walked away from my screen for 45 minutes... I see you have solved it, so my post is a bit reduntant. Well done for solving it anyway. You can leave the hidden 'from' line in. It will probably then show you that the 'sender' is your website. i.e. the text name of the sender, not the sender's email address.]

feemgh

11:17 am on Jun 24, 2003 (gmt 0)

10+ Year Member



Thanks ShawnR

I have had a look at the new host providers form_to_email scripts and these are some of the relevant variables:-

from: When the email is received by the intended recipient, the mail is given as being from this address. Without this line, the script defaults to "sendform@ednet.co.uk".

mandatory: This is a list of fields that the user MUSTfill in for the form submission to work. This list should be comma separated only. Without this line, the script has no mandatory fields.

email_as_from: If this is set to "yes" in the form, you can create a form field named emailfield of the form and use the content of that field as the fromaddress in the email sent out. This only works if the form has an emailfield.

I think I should maybe use the last option to do things properly? The problem is that we have switched providers so that is why matters are complicated plus I don't know much about the coding....

If I add

<input type="hidden" name="email_as_from" value="yes">

and then add

<input type="text" name="emailfield" size="35" maxlength="50">

Is this what I should be doing so that it works properly?

Help please!

Thanks

feemgh

ShawnR

12:00 pm on Jun 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmm... the instructions on your ISP's are not that clear. Your interpretation looks correct to me, but didn't you say you had it solved?

You use the 'mandatory' field like this:

<input type="hidden" name="mandatory" value="surname,telephone">
<input type="hidden" name="errorpage" value="url of your error page">

Then the 'surname' and 'telephone' fields will be mandatory, and if the user does not fill them in, the error page will be shown instead of the thankyou.htm page.

Shawn

feemgh

12:51 pm on Jun 24, 2003 (gmt 0)

10+ Year Member



Hi Shawn

Well it has been resolved but it is not in keeping with what the ISP details say....

I am not sure if I have interpreted it correctly....not sure if what I posted in last section will work. I don't see how the second bit of code (emailfield) ties in with the first bit of code (email)?

Sorry for being so dim....

Cheers

feemgh

ShawnR

1:11 pm on Jun 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi feemgh

So it seems that the actual operations don't match with what your ISP's instructions say. It is possible they changed the cgi script they are using, but neglected to change the instructions. If it works don't worry about it. Or if you wish, just ask them.

Shawn

feemgh

2:07 pm on Jun 24, 2003 (gmt 0)

10+ Year Member



Thanks ShawnR....if you think it is ok, then I'm happy...

Cheers

feemgh

ShawnR

2:27 pm on Jun 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm flattered ;) But don't take my word for it; If you have a concern you should get to the point where you satisfy yourself, whether that be by asking more questions, doing a perl tutorial or whatever.

Sometimes I might post with a tone that portrays more confidence than I should. Other times I post with a humble tone even though I am confident I am correct, just to see what other people think. Just depends on what I am trying to achieve, and my mood. I am sure others are the same. So always be critical ;)

Shawn

feemgh

2:58 pm on Jun 24, 2003 (gmt 0)

10+ Year Member



Thanks ShawnR...........I will try a tutorial, I see there is one listed in my host's help (what a joke!) section..

Many thanks again

feemgh

ShawnR

3:10 pm on Jun 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Also see the forum library (near the top left corner of this page)

Also see learn.perl.org (Has many on-line intro books)

Shawn

feemgh

3:17 pm on Jun 24, 2003 (gmt 0)

10+ Year Member



Great thanks ShawnR...I think the one related to this site will probably be better.

Cheers

feemgh