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

  • Home
  • SEARCH
  • 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 8265045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:39:37+00:00 2026-06-08T04:39:37+00:00

Considering that my experience with PHP is limited, I used a contact form generator

  • 0

Considering that my experience with PHP is limited, I used a contact form generator that works almost as I want it. The form, and all of its variables function properly, however upon receiving the email, it adds my own domain as the senders email. I want to have the person who completed the contact form’s email as the sender, so that I can easily reply to the message (rather than copy and pasting the email address from inside the message).

Here is part of the code:

<?php

$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

session_start();
if( ($_SESSION['security_code']==$_POST['security_code']) && (!empty($_POST['security_code'])) ) { 
// Checkbox handling
$field_4_opts = $_POST['field_4'][0].",". $_POST['field_4'][1].",". $_POST['field_4'][2];

// Checkbox handling
$field_5_opts = $_POST['field_5'][0].",". $_POST['field_5'][1].",". $_POST['field_5'][2].",". $_POST['field_5'][3];

mail("mail@mail.com","phpFormGenerator - Form submission","Form data:

Your Name:: " . $_POST['field_1'] . " 
Country:: " . $_POST['field_2'] . " 
Your Email:: " . $_POST['field_3'] . " 
Your areas of interest:: $field_4_opts
What type of articles are you interested in writing?:: $field_5_opts
Any other types of articles that interest you?:: " . $_POST['field_6'] . " 
Approximately how often will you contribute?: " . $_POST['field_7'] . " 
Your blog/website:: " . $_POST['field_8'] . " 
What would make you a good contributor?: " . $_POST['field_9'] . " 


 powered by phpFormGenerator.
");

include("confirm.html");
}
else {
echo "Invalid Captcha String.";
}

?>

install.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>testing2 - created by phpFormGenerator</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><link href="style.css" rel="stylesheet" type="text/css">
    <!-- calendar stuff -->
          <link rel="stylesheet" type="text/css" href="calendar/calendar-blue2.css" />
          <script type="text/javascript" src="calendar/calendar.js"></script>
          <script type="text/javascript" src="calendar/calendar-en.js"></script>
          <script type="text/javascript" src="calendar/calendar-setup.js"></script>
    <!-- END calendar stuff -->

    <!-- expand/collapse function -->
    <SCRIPT type=text/javascript>
    <!--
    function collapseElem(obj)
    {
        var el = document.getElementById(obj);
        el.style.display = 'none';
    }


    function expandElem(obj)
    {
        var el = document.getElementById(obj);
        el.style.display = '';
    }


    //-->
    </SCRIPT>
    <!-- expand/collapse function -->


    <!-- expand/collapse function -->
        <SCRIPT type=text/javascript>
        <!--

        // collapse all elements, except the first one
        function collapseAll()
        {
            var numFormPages = 1;

            for(i=2; i <= numFormPages; i++)
            {
                currPageId = ('mainForm_' + i);
                collapseElem(currPageId);
            }
        }


        //-->
        </SCRIPT>
    <!-- expand/collapse function -->


     <!-- validate -->
    <SCRIPT type=text/javascript>
    <!--
        function validateField(fieldId, fieldBoxId, fieldType, required)
        {
            fieldBox = document.getElementById(fieldBoxId);
            fieldObj = document.getElementById(fieldId);

            if(fieldType == 'text'  ||  fieldType == 'textarea'  ||  fieldType == 'password'  ||  fieldType == 'file'  ||  fieldType == 'phone'  || fieldType == 'website')
            {   
                if(required == 1 && fieldObj.value == '')
                {
                    fieldObj.setAttribute("class","mainFormError");
                    fieldObj.setAttribute("className","mainFormError");
                    fieldObj.focus();
                    return false;                   
                }

            }


            else if(fieldType == 'menu'  || fieldType == 'country'  || fieldType == 'state')
            {   
                if(required == 1 && fieldObj.selectedIndex == 0)
                {               
                    fieldObj.setAttribute("class","mainFormError");
                    fieldObj.setAttribute("className","mainFormError");
                    fieldObj.focus();
                    return false;                   
                }

            }


            else if(fieldType == 'email')
            {   
                if((required == 1 && fieldObj.value=='')  ||  (fieldObj.value!=''  && !validate_email(fieldObj.value)))
                {               
                    fieldObj.setAttribute("class","mainFormError");
                    fieldObj.setAttribute("className","mainFormError");
                    fieldObj.focus();
                    return false;                   
                }

            }



        }

        function validate_email(emailStr)
        {       
            apos=emailStr.indexOf("@");
            dotpos=emailStr.lastIndexOf(".");

            if (apos<1||dotpos-apos<2) 
            {
                return false;
            }
            else
            {
                return true;
            }
        }


        function validateDate(fieldId, fieldBoxId, fieldType, required,  minDateStr, maxDateStr)
        {
            retValue = true;

            fieldBox = document.getElementById(fieldBoxId);
            fieldObj = document.getElementById(fieldId);    
            dateStr = fieldObj.value;


            if(required == 0  && dateStr == '')
            {
                return true;
            }


            if(dateStr.charAt(2) != '/'  || dateStr.charAt(5) != '/' || dateStr.length != 10)
            {
                retValue = false;
            }   

            else    // format's okay; check max, min
            {
                currDays = parseInt(dateStr.substr(0,2),10) + parseInt(dateStr.substr(3,2),10)*30  + parseInt(dateStr.substr(6,4),10)*365;
                //alert(currDays);

                if(maxDateStr != '')
                {
                    maxDays = parseInt(maxDateStr.substr(0,2),10) + parseInt(maxDateStr.substr(3,2),10)*30  + parseInt(maxDateStr.substr(6,4),10)*365;
                    //alert(maxDays);
                    if(currDays > maxDays)
                        retValue = false;
                }

                if(minDateStr != '')
                {
                    minDays = parseInt(minDateStr.substr(0,2),10) + parseInt(minDateStr.substr(3,2),10)*30  + parseInt(minDateStr.substr(6,4),10)*365;
                    //alert(minDays);
                    if(currDays < minDays)
                        retValue = false;
                }
            }

            if(retValue == false)
            {
                fieldObj.setAttribute("class","mainFormError");
                fieldObj.setAttribute("className","mainFormError");
                fieldObj.focus();
                return false;
            }
        }
    //-->
    </SCRIPT>
    <!-- end validate -->




</head>

<body onLoad="collapseAll()">

<div id="mainForm">




    <div id="formHeader">
            <h2 class="formInfo">testing2</h2>
            <p class="formInfo"></p>
    </div>


    <BR/><div id="footer"><p class="footer"><a class=footer href=http://phpformgen.sourceforge.net>Generated by phpFormGenerator</a></p></div>

</body>
</html>

Can you kindly find what I will need to change?

  • 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-06-08T04:39:40+00:00Added an answer on June 8, 2026 at 4:39 am

    Add the relevant headers before calling the mail function in PHP.

        $headers = 'From: user@example.com' . "\r\n" .
        'Reply-To: user@example.com' . "\r\n";
    
    mail($to, $subject, $message, $headers);
    

    In your case:

    <?php
    
    $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
    
    session_start();
    if( ($_SESSION['security_code']==$_POST['security_code']) && (!empty($_POST['security_code'])) ) { 
    // Checkbox handling
    $field_4_opts = $_POST['field_4'][0].",". $_POST['field_4'][1].",". $_POST['field_4'][2];
    
    // Checkbox handling
    $field_5_opts = $_POST['field_5'][0].",". $_POST['field_5'][1].",". $_POST['field_5'][2].",". $_POST['field_5'][3];
    
    $message = "Form data:
            Your Name:: " . $_POST['field_1'] . " 
            Country:: " . $_POST['field_2'] . " 
            Your Email:: " . $_POST['field_3'] . " 
            Your areas of interest:: $field_4_opts
            What type of articles are you interested in writing?:: $field_5_opts
            Any other types of articles that interest you?:: " . $_POST['field_6'] . " 
            Approximately how often will you contribute?: " . $_POST['field_7'] . " 
            Your blog/website:: " . $_POST['field_8'] . " 
            What would make you a good contributor?: " . $_POST['field_9'] . " 
    
    
             powered by phpFormGenerator.
            ";
    
         $headers = 'From: '.$_POST['field_3']. "\r\n" .
                'Reply-To: '.$_POST['field_3'] . "\r\n" .
                'X-Mailer: PHP/' . phpversion();
    
          mail("mail@mail.com","phpFormGenerator - Form submission", $message, $headers);
    
    include("confirm.html");
    }
    else {
    echo "Invalid Captcha String.";
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Considering that I have a Schema named SBST I want to find all empty
I would like to know , considering that Clojure uses 32-bit hash for its
Considering that simple java code which would not work: public class Bar extends AbstractBar{
Considering that the two machine's time settings are not synced, is it still possible
considering that metric is delay in distance vector routing algorithm, is it possible that
I'm trying to create programmability a home shortcut for any installed application. Considering that
I'm considering a project that involves the browser user being able to screen capture
I have a question considering a program that stimulates a stack (not using any
I'm working on a project that is considering using Cassandra as a database. We
In considering languages to use in creating a web-application that interfaces with a database

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.