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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:59:22+00:00 2026-06-01T17:59:22+00:00

im currnetly making a website and im stuck i have a form <form name=inputForm

  • 0

im currnetly making a website and im stuck i have a form

    <form name="inputForm" onSubmit="return validateForm();" action="#">
<fieldset>
    <p>
      <label>First Name:</label>
      <input type="text" name="first_name"/><br />
      <label>Surname:</label>
      <input type="text" name="surname"/><br />
      <label>Address number:</label>
      <input type="text" name="address_number"/><br />
      <label>Address name:</label>
      <input type="text" name="address_name"/><br />
      <label>Suburb:</label>
      <input type="text" name="suburb"/><br />
      <label>Postcode:</label>
      <input type="text" name="postcode"/><br />      
      <label>State:</label>
      <select name="state">
            <option value="nsw">NSW
            <option value="qld">QLD
            <option value="act">ACT
            <option value="vic">VIC
            <option value="sa">SA
            <option value="tas">TAS
            <option value="nt">NT
            <option value="wa">WA
          </SELECT><br />
      <label>Email:</label>
      <input type="text" name="email"/><br />
      <label>Phone Number:</label>
      <input type="text" name="phone"/><br />
      <input type="submit" name="submit" value="Send form" />
      <input type="reset" name="reset" value="reset" />
      </p>
</fieldset>
</form>

which is then validated by javascript

function validateForm()
{
    var form = document.forms['inputForm'];
    var formats = 
        {
            first_name: /^[a-zA-Z]+[\-'\s]?[a-zA-Z]+$/,                             /*works for a-Z allows - and '*/
            surname: /^[a-zA-Z]+[\-'\s]?[a-zA-z]+$/,                                /*works for a-Z allows - and '*/
            postcode: /^\d{4}$/,                                                    /*4digit post code australia wide*/
            email: /^\w+([\.-]w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/,                   /*allows all word characters and normal email formats*/
            address_number: /^\d[0-9]$/,                                                    /*allows any number of digits*/
            address_name: /^\w?\s?[a-zA-Z]+(,?\s([a-zA-Z])*)*$/,            /*allows numbers space capital letters and other word characters*/
            suburb: /^\w?\s?[a-zA-Z]+(,?\s([a-zA-Z])*)*$/,          /*allows numbers space capital letters and other word characters*/
            phone: /^\d{8}$/,                                                       /*8 number phone number*/
        };
        var elCount = form.elements.length;
        for(var i = 0; i<elCount; i++)
        {
            var field = form.elements[i];
            if(field.type == 'text')
            {
                if(!formats[field.name].test(field.value))
                {
                    alert('invalid '+ field.name.replace('_',' ')+'.');             /*alerts the name of the area not filled right in a pop up box*/
                    field.focus();
                    return false;
                }
            }
        }
        alert('All fields correct, the form will now submit.')
}

then i need php to gather that information and send it to my email address (this is where im stuck)

<?php
if( isset( $_POST['submit'] ) || isset( $_POST['submit_x']))
{
    $to = "myemail@myemail.com";
      $subject = 'subject';
      $message = 'testing the php mail() function';
      $headers = "from: email\r\n";


        $body=" 
        Name: $name\n
        Email: $email\n
";
echo "the information has been sent we will be in contact with you shortly";
mail($to, $subject, $message, $headers);    
}
else
{
    echo "The informations has not been sent";
}
?>

now i’ve been scratching my head over this for a couple days looked it up cant find anything im still learning about php and javascript

the javascript and HTML work fine its just the mail function please 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-06-01T17:59:24+00:00Added an answer on June 1, 2026 at 5:59 pm

    first, add method=”post” to your form, so it looks like this:

    Next

     $headers = "from: email\r\n";
    

    to

     $headers = "from: {$_POST['email']}\r\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website that I'm making that needs a background resizer. Currently, I
I have a website made to provide free web-based tools for making indie games.
So I have my first ever Ruby website up and running and would like
I have a questing about XSLT. I am making a website on Sitecore CMS,
I have a question about tables in MySQL. I'm currently making a website where
I'm using webfonts for the first time on a website I'm currently making and
I am currently building an making my new website. It uses one page and
I currently making an Excel VB application. However, I am stuck at the moment.
I am currently making a website ( http://tannernelson.me/ehs ) It's hosted on Godaddy, and
Here is my situation: Im currently making a website where it has to be

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.