Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4270726
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:20:43+00:00 2026-05-21T07:20:43+00:00

I got some help with an email form, and I feel that I am

  • 0

I got some help with an email form, and I feel that I am almost there as the script sends an email but need a few tweaks before I put the form up. Here is my code right now:

index.html:

<div id="main">
    <form method="post" action="mailer.php">
        <div id="text">
            Please enter your email address.
        </div>
        <input type="text" name="q" id="search" />
        <input type="submit" name="submit" id="submit" value="Go!" />
    </form>
</div>

mailer.php:

<?php

$email = addcslashes($_REQUEST['q']) ;
if ($email==FALSE){
    echo "You forgot to enter your email";
}
else

mail( "example@gmail.com", "E-Mail entered",
"E-Mail entered: $email");
header( "Location: http://www.example.com/thankyou.html" );
?>

A few issues I am running into:

The email being sent does not actually include the email entered, the email comes from Apache@ipaddress.ec2.internal and the Body is Email Entered:
which does not include the email string – is there something buggy with the code?

Also, my if statement doesn’t seem to work. Even if I leave the box black, it still assumes a valid email address was sent.

Finally, is there a parameter that sees if the address is in the correct format? ie: includes the @ the . and the domain?

Many thanks for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T07:20:44+00:00Added an answer on May 21, 2026 at 7:20 am

    First off, you can use filter_var($email, FILTER_VALIDATE_EMAIL) to test the submitted address. This function returns false if it’s not valid. Second, mail() requires a 4th parameter to assign a return address in your message header. Here’s an example:

    mail(
       'to@address.com',
       'Subject',
       'Message Body',
       'From: from@address.com'
       )
    

    Regarding your if/else statement, test $_POST['q'] == NULL first, then change $email = addcslashes($_REQUEST['q']); to $email = str_replace(array('\'', '"'), '', $_POST['q']); – no real reason to escape characters in this case. Just take em’ out.

    Edit: This is what your code should look like:

    $email = str_replace(array('\'', '"'), '', $_POST['q']);
    
    $isValid = filter_var($email, FILTER_VALIDATE_EMAIL);
    
    if ( $_POST['q'] == NULL ) {
    
        echo "You forgot to enter your email";
    
    } elseif ( $isValid == FALSE ) {
    
        echo "Please enter a valid email address";
    
    } else {
    
        mail(
            'example@gmail.com', // Your address that you want the message sent to
            'Subject',
            'Message Body',
            'From: ' . $email // The address collected
        );
    
        header( "Location: http://www.example.com/thankyou.html" );
    
    }
    

    Does that make a little more sense?

    Do note that because of modern spam filters, this method may not make it to every recipient. Creating useful email headers can be a bit of an art-form that takes some practice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i got some problem and need help .. my plan : 1. get ip
I got some code off the Internet and now I just need help to
I got some help a few weeks ago on some code for a drop
I asked a question yesterday on here and got some awsome help, but I
I got some help with this earlier today but I cannot figure out the
I need some help with an SQL stored procedure, I haven't got alot of
I need some help programatically setting the selected item in a combobox. I've got
Hi I posted this earlier and got some help but still no working solution.
I got some problem with texture transparency, I hope ya can help. Details: XNA
With some kindly help from StackOverflow, I've got Unity Framework to create my chained

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.