Get ready for BLACK FRIDAY shopping starting in

Forums

PHP

This topic is locked

Several Q's all in one...

Posted 13 May 2003 07:23:10
1
has voted
13 May 2003 07:23:10 Rob Toth posted:
Several questions tied into one.

First, here's what I would like to achieve.

On several pages I have an e-mail address submit form. So it's a very basic form with just one text field: the e-mail. When a user enters their e-mail and clicks Submit, I would like
- the page reloaded (or a new page loaded)
- an e-mail sent to an address specified in a PHP file
- a reply-to address properly setup so that the receiving autoresponder can reply


With that in mind... here is the PHP I use...
====================================================
<?php
$message = "Sender E-Mail:\t$theiremail\n IP:\t$REMOTE_ADDR\n\n";
$to = " ";
$subject = "FORM DATA.";
mail($to, $subject, $message);
?>
====================================================

Should that do the trick? Should I use a CGI instead of this PHP?
QUESTION: How could I modify this PHP file to have the Reply-To setup in a way that the autoresponder can recognize it (and therefore reply)?

also here is the Javascipt that I use for my redirect...

This is of course in the head...
====================================================
<!-- begin code for redirect after SUBMIT -->
<script language="JavaScript" type="text/JavaScript">
<!--
function goToURL() { //v3.0
var i, args=goToURL.arguments; document.returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'";
}
//-->
</script>
<!-- end code for redirect after SUBMIT -->
====================================================

and this is in the body...

====================================================
<form method="post" action="php/email.php">
<input type="text" name="theiremail">
<input type="image" src="images/submit.gif" name="submit" value="Send" onClick="goToURL('parent','index.htm');return document.returnValue">
</form>
====================================================
QUESTION: Does this follow correctly? I get an error saying Object Expected. I'm trying to use a picture of a submit
button instead of using a <input type="submit"> but shouldn't this still work? And for the goToURL part... that index.htm file is in the same folder as the current page... that's how it should be right? Or after envoking the php folder to get the php file... am I all of a sudden in the PHP folder therefore my goToURL link should be more like "../index.htm"?


I would really appreciate a hand on this.

Replies

Replied 20 May 2003 03:53:51
20 May 2003 03:53:51 k k replied:
for the mail function, you can add a fourth parameter. this is an additional parameter that contains info for "from" and "reply" info. so an example would be:
$extra = "From: \r\nReply-To: ";
Note that in the above i added \r\n. you separate headers with a combination of line feed and new line.

so then:
mail($to, $subject, $message,$extra);


for the second problem, i use an easier javascript function:

<pre id=code><font face=courier size=2 id=code>
&lt;script language="JavaScript" type="text/JavaScript"&gt;
function goToURL() {
myForm.submit();
}
&lt;/script&gt;
</font id=code></pre id=code>

in your form tag, ,just give the form a name. the above javascript is gonna submit 'myForm' so name it the same name.
<pre id=code><font face=courier size=2 id=code>
&lt;form name="myForm" method="post" action="php/email.php" </font id=code></pre id=code>
and in the onClick function it should simply as follows:
onClick="goToURL()"

Edited by - ospinto on 20 May 2003 03:54:26

Edited by - ospinto on 20 May 2003 03:55:08

Reply to this topic