Help with form email submission and forwarding, por favor?

bangs head on desk :’(

Hi! I’m trying to put a PHP script together to accomplish a few things. I’ve tried googling and get pieces all over and can’t get them to work together.

I need it to take data from a form, simple, just an email address.
I need to verify the format as valid.
I need to parse the email name from the domain (see below).
I need to send myself an email containing that users email, and a subject.
I need to send a verification email to the user that their interest is appreciated.
and last, I need to send them to another page, using the parsed email (example: https://www.bananasoup.com/letter/?email=emailname%40emaildomain )

I’ve messed with this for hours, getting sources for one, maybe a couple features in one, but can’t make them work together. Some are showing me parts that can be put in the html. Some have to be put in the cgi bin.

Ok, going to take some Advil now and watch some TV before my head explodes. :stuck_out_tongue:

Any help appreciated! ;D

You have the steps broken down.

What code do you have for the individual parts?

Hey astonecipher,

These are the two pieces I have, I just put these together to show you, but I’ve tried the php in any number of ways. With the right field names, of course.

Thanks!

[php]

Get email

Email Address *

Email Form

==================
Email script

<?php $email_to = "[email protected]"; $email_subject = "Your email subject line"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.

"; echo $error."

"; echo "Please go back and fix these errors.

"; die(); } ======================================== This parses it, but what do I do with it to make it work in the URL? ======================================== { $email_from = $_POST['email']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.
'; } $email_message .= "Email: ".clean_string($email_from)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); =============================================== Or I could forward it from here? =============================================== { Header("Location: https://www.bananasoup.com/letter/?email=emailname%40emaildomain"); } [/php] Part 2 [php] <?php $email = $_POST['email']; { Header("Location: https://www.bananasoup.com/letter/?email=emailname%40emaildomain"); } ?>

[/php]


examples (1).txt (1.81 KB)

examples (2).txt (139 Bytes)

Following the IPO, Input - Processing - Output, standard:

You have the input from the form.
I don’t really see the processing or validation.

So,

  1. Input => via Form

  2. Processing
    [php]
    if ( isset( $_POST[‘email’] ) ) {
    if ( filter_var( $_POST[‘email’] , FILTER_VALIDATE_EMAIL)){
    echo $email.’ is valid
    ’;

     // splits the email into parts ( [name][domain] )
     $emailParts = explode( "@", $email );
    
     //send emails out
    
     // do other stuff
    

    }else{
    echo $email.’ is invalid
    ’;
    // return error message or similar
    }
    }
    [/php]

  3. Output

I was looking at this piece of code for validation and separation. Yours looks easier. :stuck_out_tongue:

$error_message = “”;

 $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';

if(!preg_match($email_exp,$email_from)) {

 $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
Sponsor our Newsletter | Privacy Policy | Terms of Service