SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Mar 2004
    Location
    Maine
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Submitting Forms Via Email!

    I am trying to set up a mailing list on my website. What i want on my site is just a form box and a submit button to have people add their email addresses. I want the email addresses they put in the box to be emailed to the address of my choice. I have it set up but everytime u put something in the box and hit submit a box will pop open saying: This form is being submitted using email. Submitting this form will reveal your email address and blahdy blahdy blah.
    How can i just have them click the submit button, have their email go to the one i specify without having that box pop up?

    Heres the basic HTML:
    </form>
    <input name="textfield" type="text" value="enter email address"> <INPUT TYPE=SUBMIT STYLE="background:#000000; color:silver; font-family:impact;
    name="Submit" value="Submit">
    </form>

    This is just the look of it no actions have been set. Lets say the email address i want it to go to is email@email.com and the website is www.website.com.

    Does anyone know What i need to do to get this to work? More specifically the html for the info i posted. Thanx for any help that you can give...

  2. #2
    Is Still Alive silver trophybronze trophy RetroNetro's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    6,883
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hello

    You need some sort of server side script, like cgi or php.

    I am sure there are more languages that can be used but those are the 2 I know of.

    You then just point the form action to the path of the php file or your cgi-bin.

    I am no php or cgi expert, so I am not gonna be a big help, but I have steered you in the right direction at least.

    Hope you get it straightened out.

    later
    Johnny

  3. #3
    SitePoint Member
    Join Date
    Mar 2004
    Location
    Maine
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, thanx for the input, anyone know how u go about this using cgi or php?

  4. #4
    Non-Member Egor's Avatar
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    7,305
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Hi, if your server supports PHP you can use this processor:

    first copy this into a text file and save as mailer.php
    Code:
    <?php
    
    $MailToAddress = "email@email.com"; // your email address
    $redirectURL = "redirect page url here"; // the URL of the thank you page.
    
    # optional settings
    $MailSubject = "[Message from the Products order form]"; // the subject of the message you will receive
    $MailToCC = ""; // CC (carbon copy) also send the email to this address (leave empty if you don't use it)
    # in the $MailToCC field you can have more then one e-mail address like "d@web4future.com, b@web4future.com, c@web4future.com"
    
    # If you are asking for an email address in your form, you can name that input field "email".
    # If you do this, the message will apear to come from that email address and you can simply click the reply button to answer it.
    # You can use this scirpt to submit your forms or to receive orders by email.
    # You need to send the form as POST!
    
    # If you have a multiple selection box or multiple checkboxes, you MUST name the multiple list box or checkbox as "name[]" instead of just "name" 
    # you must also add "multiple" at the end of the tag like this: <select name="myselect[]" multiple> 
    # and the same way with checkboxes
    
    # This script was made by George A. & Calin S. from Web4Future.com
    # There are no copyrights in the e-mails sent and we do not ask for anything in return.
    
    # DO NOT EDIT BELOW THIS LINE ============================================================
    # ver. 1.2
    $Message = "";
        if (!is_array($HTTP_POST_VARS))
        return;
    reset($HTTP_POST_VARS);
    	while(list($key, $val) = each($HTTP_POST_VARS)) {
    		$GLOBALS[$key] = $val;
    		if (is_array($val)) { 
    			$Message .= "<b>$key:</b> ";
    			foreach ($val as $vala) { 
    				$vala =stripslashes($vala);
    				$Message .= "$vala, ";
    			} 
    			$Message .= "<br>";
    		} 	
    		else {
    			$val = stripslashes($val);
    			if (($key == "Submit") || ($key == "submit")) { } 	
    			else { 	if ($val == "") { $Message .= "$key: - <br>"; }
    					else { $Message .= "<b>$key:</b> $val<br>"; }
    			}
    		}
    	} // end while
    $Message = "<font face=verdana size=2>".$Message;
    mail( $MailToAddress, $MailSubject, $Message, "Content-Type: text/html; charset=ISO-8859-1\r\nFrom: ".$email."\r\nBCc: ".$MailToCC);
    header("Location: ".$redirectURL);
    ?>
    and then point your form action to mailer.php and youre set

  5. #5
    SitePoint Member
    Join Date
    Mar 2004
    Location
    Maine
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Not Working

    I can't seem to make this work. i copy and pasted it and did exactly what u said. Heres what i have and someone tell me what i'm doing wrong. In My html file i have this for my form:

    <FORM METHOD="POST" ACTION="http://www.hostultra.com/~sickhate/mailer.php">
    <input name="textfield" type="text" value="enter email address"> <INPUT TYPE=SUBMIT STYLE="background:#000000; color:silver; font-family:impact;
    name="Submit" value="Submit"> </FORM>

    The Mailer Php File Looks Like This:

    Code:


    <?php

    $MailToAddress = "poorlittleboy@hotmail.com"; // your email address
    $redirectURL = "http://www.sickandtwistedhate.8m.com/sounds.html"; // the URL of the thank you page.

    # optional settings
    $MailSubject = "[Mailing List]"; // the subject of the message you will receive
    $MailToCC = "poorlittleboy@hotmail.com"; // CC (carbon copy) also send the email to this address (leave empty if you don't use it)
    # in the $MailToCC field you can have more then one e-mail address like "d@web4future.com, b@web4future.com, c@web4future.com"

    # If you are asking for an email address in your form, you can name that input field "email".
    # If you do this, the message will apear to come from that email address and you can simply click the reply button to answer it.
    # You can use this scirpt to submit your forms or to receive orders by email.
    # You need to send the form as POST!

    # If you have a multiple selection box or multiple checkboxes, you MUST name the multiple list box or checkbox as "name[]" instead of just "name"
    # you must also add "multiple" at the end of the tag like this: <select name="myselect[]" multiple>
    # and the same way with checkboxes

    # This script was made by George A. & Calin S. from Web4Future.com
    # There are no copyrights in the e-mails sent and we do not ask for anything in return.

    # DO NOT EDIT BELOW THIS LINE ============================================================
    # ver. 1.2
    $Message = "";
    if (!is_array($HTTP_POST_VARS))
    return;
    reset($HTTP_POST_VARS);
    while(list($key, $val) = each($HTTP_POST_VARS)) {
    $GLOBALS[$key] = $val;
    if (is_array($val)) {
    $Message .= "<b>$key/b> ";
    foreach ($val as $vala) {
    $vala =stripslashes($vala);
    $Message .= "$vala, ";
    }
    $Message .= "<br>";
    }
    else {
    $val = stripslashes($val);
    if (($key == "Submit") || ($key == "submit")) { }
    else { if ($val == "") { $Message .= "$key: - <br>"; }
    else { $Message .= "<b>$key/b> $val<br>"; }
    }
    }
    } // end while
    $Message = "<font face=verdana size=2>".$Message;
    mail( $MailToAddress, $MailSubject, $Message, "Content-Type: text/html; charset=ISO-8859-1\r\nFrom: ".$email."\r\nBCc: ".$MailToCC);
    header("Location: ".$redirectURL);
    ?>

    The server I'm using it on supports PHP. When i submit the form the email address i put in the field disapears and the page reloads.. but nothing is sent to the email i specify. Also when i click on my mailer.php file by itself i get this message:
    Code:
    Warning: Cannot modify header information - headers already sent by (output started at /data/hosted/sickhate/mailer.php:4) in /data/hosted/sickhate/mailer.php on line 52

    Can anyone help with this? Thanx

  6. #6
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,269
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    PHP's not my thing but the above code worked straight away on my hosts server submitting the form to my email address and redirecting the page as expected.

    I should check that PHP is working and enabled on your hosts server or try a simple php file to see if it's working.

    Paul

  7. #7
    Non-Member Egor's Avatar
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    7,305
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Yeah you can just check the processor script like that because it has nothing to output as is. The script looks fine, maybe you could try giving the inputs different names rather then textfield but I dont see how that can be the problem.
    Also I hope you didnt use "Code:" at the top of your php file


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •