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 4016008
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:41:16+00:00 2026-05-20T09:41:16+00:00

I am using an html sign up form for a website I’m building. The

  • 0

I am using an html sign up form for a website I’m building. The form accepts first name, last name, email address, birthdate (month,day,year), and sex. It calls a php file to process the results and email them to me like this:

<form  method="post" action="sendMail.php" >

the php file looks like:

<?php
$firstName = $_REQUEST['FirstName'] ;
$lastName = $_REQUEST['LastName'] ;
$email = $_REQUEST['EmailAddress'] ;
$birthdate = $_REQUEST['month'] ;
$sex = $_REQUEST['sex'] ;

$message .=  "First Name: \t";
$message  = $firstName;
$message .= "\n";
$message .=  "Last Name: \t";
$message .= $lastName;
$message .= "\n";
$message .=  "Email: \t";
$message .= $email;
$message .= "\n";
$message .=  "Birthdate: \t";
$message .= $birthdate;
$message .= "\n";
$message .=  "Sex: \t";
$message .= $sex;

mail( "ty@ollielifestyle.com", "Sign-Up Form Results", $message, "From: $email" );
/*?>  header( "Location: http://www.example.com/thankyou.html" );
<?php */
?>

The script works fine to process and email the results, but I do not know how to make the ‘php mail() function’ return to the exact same calling page. I know that typically people like to show a thank you page but I do not want to lead the visitor to just a thank you page. Is there a way to alter the ‘php mail() function’ to redirect to the same exact page that called it, or to call it without leaving the page in the first place? Thanks for any hints in advance!

Update I have included the php into the same page with the sign up form. It isn’t returning any errors but I do not seem to be getting any emails delivered to the gmail account I set up for it. I did not know if it would work better to place the form in the html file as I normally would (outside of the php function) or inside an else statement so I tried it both ways with neither giving an email. Was there a logical error in the code below ?

Version 1:

$message .=  "First Name: \t";
$message  = $firstName;
$message .= "\n";
$message .=  "Last Name: \t";
$message .= $lastName;
$message .= "\n";
$message .=  "Email: \t";
$message .= $email;
$message .= "\n";
$message .=  "Birthdate: \t";
$message .= $birthdate;
$message .= "\n";
$message .=  "Sex: \t";
$message .= $sex;

mail( "ymaxwell86@gmail.com", "Sign-Up Form Results", $message, "From: $email" );  
echo "Thank you for using our mail form";
}
?>       

First Name:*       
   

Last Name:*        

Email Address:* 

Birthday:    

Month
January
February
March
April
May
June
July
August
September
October
November
December

Day

Year

function changeDate(i){
var e = document.getElementById(‘day’);
while(e.length>0)
e.remove(e.length-1);
var j=-1;
if(i==”na”)
k=0;
else if(i==2)
k=28;
else if(i==4||i==6||i==9||i==11)
k=30;
else
k=31;
while(j++1909){
var s = document.createElement(‘option’);
var e = document.getElementById(‘year’);
s.text=y;
s.value=y;
try{
e.add(s,null);}
catch(ex){
e.add(s);}}

Gender:              
Male
Female

*required fields

                   
          

         

Version 2:

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  $firstName = $_REQUEST['FirstName'] ;
  $lastName = $_REQUEST['LastName'] ;
  $email = $_REQUEST['EmailAddress'] ;
  $birthdate = $_REQUEST['month'] ;
  $sex = $_REQUEST['sex'] ;

  $message .=  "First Name: \t";
  $message  = $firstName;
  $message .= "\n";
  $message .=  "Last Name: \t";
  $message .= $lastName;
  $message .= "\n";
  $message .=  "Email: \t";
  $message .= $email;
  $message .= "\n";
  $message .=  "Birthdate: \t";
  $message .= $birthdate;
  $message .= "\n";
  $message .=  "Sex: \t";
  $message .= $sex;

  mail( "ymaxwell86@gmail.com", "Sign-Up Form Results", $message, "From: $email" );  
  echo "Thank you for using our mail form";
  }
else
//if "email" is not filled out, display the form
  {
  echo "<form action=''  method='post'>
       <p>First Name:* &nbsp; &nbsp; &nbsp;&nbsp;
         <input name='FirstName' type='text' id='FirstName' size='25' />&nbsp; &nbsp;<br />

         Last Name:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <input name='LastName' type='text' id='LastName' size='25'/><br />
         <br />
         Email Address:*&nbsp;
         <input name='EmailAddress' type='text' id='EmailAddress' size='25' onblur='valid_email=validateEmail(email_field,mandatory,messages);' />
         <br />
         <br />
         Birthday: &nbsp;&nbsp;&nbsp;
         <select name='month' onChange='changeDate(this.options[selectedIndex].value);'>
           <option value='na'>Month</option>
           <option value='1'>January</option>
           <option value='2'>February</option>
           <option value='3'>March</option>
           <option value='4'>April</option>
           <option value='5'>May</option>
           <option value='6'>June</option>
           <option value='7'>July</option>
           <option value='8'>August</option>
           <option value='9'>September</option>
           <option value='10'>October</option>
           <option value='11'>November</option>
           <option value='12'>December</option>
         </select>
         <select name='day' id='day'>
           <option value='na'>Day</option>
         </select>
         <select name='year' id='year'>
           <option value='na'>Year</option>
         </select>
         <script language='JavaScript' type='text/javascript'>
function changeDate(i){
var e = document.getElementById('day');
while(e.length>0)
e.remove(e.length-1);
var j=-1;
if(i=='na')
k=0;
else if(i==2)
k=28;
else if(i==4||i==6||i==9||i==11)
k=30;
else
k=31;
while(j++<k){
var s=document.createElement('option');
var e=document.getElementById('day');    
if(j==0){
s.text='Day';
s.value='na';    
try{
e.add(s,null);}
catch(ex){
e.add(s);}}
else{
s.text=j;
s.value=j;
try{
e.add(s,null);}
catch(ex){
e.add(s);}}}}
y = 2010;
while (y-->1909){
var s = document.createElement('option');
var e = document.getElementById('year');
s.text=y;
s.value=y;
try{
e.add(s,null);}
catch(ex){
e.add(s);}}
</script>
         <br />
       </p>
       <p>Gender:  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
         <input type='radio' name='sex' value='male' /> Male
         <input type='radio' name='sex' value='female' /> Female
         <br />
       <div id='mailListNote'>
         *required fields
       </div>
         <br />
  <br />

         &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <input type='submit' name='submit' value='Submit' onclick='valid_email =validateEmail(email_field,mandatory,messages); '/>
         &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
         <INPUT TYPE=RESET  onClick='return confirm('Are you sure you want to reset the form?')'>
       </p>
     </form>";
  }
?>
  • 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-20T09:41:17+00:00Added an answer on May 20, 2026 at 9:41 am

    You have basically two options:

    • Simply change the url in header("location:…"); to return to the original page.
    • Or use Ajax to submit the form in the background. There are plenty helpful plugins based on JQuery. Google is your friend.

    It is definitely a good idea to provide some feedback to the user after submitting your form. So, the thank you page might just be the most user-friendly solution. And even the technically easiest solution for you.

    Hope this helps!

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

Sidebar

Related Questions

I am using HTML agility DLL for getting images and title of external website
In the following example I get title from this form using html id=title .
I'm struggling with encodings and lxml. I'm reading in some html from a website
I am making a game using html canvas. Here is my progress: http://db.tt/ei3LlR (use
I have made an application in javascript using HTML fields in asp.net, as asp
Simply said: How do I receive data from a PHP echo to display using
i am using a twitter script to post messages to the twitter wall from
I'm using Devise 1.3.4 for authentication for the backend in my app. For a
I have created a web system using Java Servlets and now want to make
I asked this question earlier today. After trying out suggestions from a few members,

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.