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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:46:08+00:00 2026-06-13T13:46:08+00:00

I am having trouble figuring our exactly why my php code won’t pick up

  • 0

I am having trouble figuring our exactly why my php code won’t pick up the first name from my form, I hope you guys can help.

Everything else is emailed through fine, just the first name field which is element_1_1.

Here is the PHP:

$<?php
$errors = ''; 
$myemail = 'example@example.co.uk';
if( empty($_POST['element_1_1'])  ||
empty($_POST['element_1_2'])  ||
empty($_POST['element_3']) ||
empty($_POST['element_2'])  ||
empty($_POST['element_5'])  ||
empty($_POST['element_4']))

$name = $_POST['element_1_1'];
$lastname = $_POST['element_1_2'];
$email_address = $_POST['element_3']; 
$number = $_POST['element_2'];
$area = $_POST['element_5'];
$discount = $_POST['element_4'];

if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", 
$email_address))
{
    $errors .= "\n Error: Invalid email address \n";
}

if( empty($errors))
{
$to = $myemail; 
$email_subject = "";
$email_body = "".

"\n First Name:   $name \n  \n Second Name:   $lastname \n  \n Email:   $email_address \n  \n Phone Number:   $number \n \n Area(s):   $area \n \n Discount:   $discount \n".


$headers = "From: example@example.co.uk\n"; 
$headers .= "Reply-To: $email_address";

mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: http://www.example.co.uk');
} 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
<title>Contact form handler</title>
</head>

<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
echo "";
echo " \n <a href='http://www.example.com'>Go     Back</a> \n";
?>


</body>
</html>

And here is the form:

<div id="bmvform-form_container">
    <form id="form_507993" class="appnitro"  method="post" action="formsend.php">
                <div class="form_description">
        <h2>Want To Receive Our Properties?</h2>
        <p><em>At Pure Acquisitions, we respect your privacy. Any details provided will NOT be sent to any third party without your consent.</em></p>
    </div>                      
        <ul >

    <li id="li_1" >
    <label class="description" for="element_1">Name </label>
    <span>
        <input id="element_1_1" name="element_1_1" class="element text" maxlength="255" size="14" value=""/>
        <label>First</label>
    </span>
    <span>
        <input id="element_1_2" name="element_1_2" class="element text" maxlength="255" size="14" value=""/>
        <label>Last</label>
    </span><p class="guidelines" id="guide_1"><small>We don't want to be rude!</small></p> 
    </li>       <li id="li_3" >
    <label class="description" for="element_3">Email Address </label>
    <div>
        <input id="element_3" name="element_3" class="element text medium" type="text" maxlength="255" value=""/> 
    </div><p class="guidelines" id="guide_3"><small>To send you important stuff!</small></p> 
    </li>       <li id="li_2" >
    <label class="description" for="element_2">Phone Number </label>
    <div>
        <input id="element_2" name="element_2" class="element text medium" type="text" maxlength="255" value=""/> 
    </div><p class="guidelines" id="guide_2"><small>We need to let you know about our properties!</small></p> 
    </li>       <li id="li_5" >
    <label class="description" for="element_5">Locations You Are Interested In </label>
    <span>
        <input id="element_5_1" name="element_5" class="element radio" type="radio" value="All" />
        <label class="choice" for="element_5_1">All</label>
        <input id="element_5_2" name="element_5" class="element radio" type="radio" value="London" />
        <label class="choice" for="element_5_2">London</label>
        <input id="element_5_3" name="element_5" class="element radio" type="radio" value="South of England" />
        <label class="choice" for="element_5_3">South of England</label>
        <input id="element_5_4" name="element_5" class="element radio" type="radio" value="West Midlands" />
        <label class="choice" for="element_5_4">West Midlands</label>
        <input id="element_5_5" name="element_5" class="element radio" type="radio" value="East Midlands" />
        <label class="choice" for="element_5_5">East Midlands</label>
        <input id="element_5_6" name="element_5" class="element radio" type="radio" value="North West" />
        <label class="choice" for="element_5_6">North West</label>
        <input id="element_5_7" name="element_5" class="element radio" type="radio" value="North East" />
        <label class="choice" for="element_5_7">North East</label>
        <input id="element_5_8" name="element_5" class="element radio" type="radio" value="Yorkshire & Humber" />
        <label class="choice" for="element_5_8">Yorkshire & Humber</label>
        <input id="element_5_9" name="element_5" class="element radio" type="radio" value="Wales" />
        <label class="choice" for="element_5_9">Wales</label>
        <input id="element_5_10" name="element_5" class="element radio" type="radio" value="Scotland" />
        <label class="choice" for="element_5_10">Scotland</label>

    </span><p class="guidelines" id="guide_5"><small>Let us know where in the country you are looking for property.</small></p> 
    </li>       <li id="li_4" >
    <label class="description" for="element_4">Ideal Discount From Market Value </label>
    <div>
        <input id="element_4" name="element_4" class="element text medium" type="text" maxlength="255" value=""/> 
    </div><p class="guidelines" id="guide_4"><small>How much discount (in percent) are you looking for?</small></p> 
    </li>

                <li class="buttons">
            <input type="hidden" name="form_id" value="507993" />

            <input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
    </li>
        </ul>
    </form> 
</div>
  • 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-13T13:46:09+00:00Added an answer on June 13, 2026 at 1:46 pm
    if( empty($_POST['element_1_1'])  ||
    empty($_POST['element_1_2'])  ||
    empty($_POST['element_3']) ||
    empty($_POST['element_2'])  ||
    empty($_POST['element_5'])  ||
    empty($_POST['element_4']))
    
    $name = $_POST['element_1_1'];
    $lastname = $_POST['element_1_2'];
    $email_address = $_POST['element_3']; 
    $number = $_POST['element_2'];
    $area = $_POST['element_5'];
    $discount = $_POST['element_4'];
    

    You’re missing the curley brackets here? I would assume this or something similar with curley brackets, depending on what you’d like to do.

    if( empty($_POST['element_1_1'])  ||
    empty($_POST['element_1_2'])  ||
    empty($_POST['element_3']) ||
    empty($_POST['element_2'])  ||
    empty($_POST['element_5'])  ||
    empty($_POST['element_4']))
    {
    $name = $_POST['element_1_1'];
    $lastname = $_POST['element_1_2'];
    $email_address = $_POST['element_3']; 
    $number = $_POST['element_2'];
    $area = $_POST['element_5'];
    $discount = $_POST['element_4'];
    }
    

    What are you trying to do with the if-statement anyway? You’re checking if one of them is empty and then set them all? Or you should check if one of them is empty and then send a message back to user that one of the fields needs to be filled? Then you should change it a bit to something like this:

    if( empty($_POST['element_1_1'])  ||
        empty($_POST['element_1_2'])  ||
        empty($_POST['element_3']) ||
        empty($_POST['element_2'])  ||
        empty($_POST['element_5'])  ||
        empty($_POST['element_4']))
        {
        do something;    }
    else {
    $name = $_POST['element_1_1'];
        $lastname = $_POST['element_1_2'];
        $email_address = $_POST['element_3']; 
        $number = $_POST['element_2'];
        $area = $_POST['element_5'];
        $discount = $_POST['element_4'];
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble figuring out what my Flex Project is expecting from my PHP
I am having trouble figuring our how I can get results only when products.published,
My company is having trouble figuring out the best way to manage our builds,
I'm having trouble figuring out why border-radius is gone from my #screen element when
I'm having a little trouble figuring out exactly how const applies in a specific
I'm having trouble figuring out how to access a cookie from a compiled object.
I'm having trouble figuring out how to call a method from a parent module
We are looking at adopting Git for our SCM but having trouble figuring out
I am having trouble figuring out extracting the real and imaginary parts from AForgenet
im having trouble figuring out how to bind mouseout() to my entire nav bar

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.