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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:53:52+00:00 2026-05-27T07:53:52+00:00

not sure what I am doing wrong. I set up a simple php mail

  • 0

not sure what I am doing wrong. I set up a simple php mail form, using javascript validation. Haven’t been doing this for too long, would appreciate some help. I am getting errors such as this “Notice: Undefined index: cr[first_name] in /home/content/17/8543117/”

This is the form processing script: 
$to = "alexmoverguz@gmail.com";
$subject = "You have a new lead!";
$first_name = $_POST['cr[first_name]'];
$last_name = $_POST['cr[last_name]'];
$phone = $_POST['cr[phonecr]'];
$phoneprefix = $_POST['cr[phonecr2]'];
$phonesuffix = $_POST['cr[phonecr3]'];
$email = $_POST['cr[email]'];
$zip = $_POST['cr[zip]'];
$message = '';
$headers = "From: $first_name \n\n $last_name \n\n $phone \n\n $phoneprefix \n\n      
$phonesuffix \n\n $email \n\n $zip";
$sent = mail($to,$subject,$headers);
if($sent)
{
$_SESSION['success'] = '<p class="error">Your inquiry has been sent!</p>';
header('Location: index.php?e=inquiry_sent'); 
exit();
}
?>

This is the form:

<?php
if (isset($_REQUEST['e']))
if ( $_REQUEST['e']=="inquiry_sent"){
echo "<p class=\"error\">Thanks! We will contact you shortly!</p>";
}else{

echo "<p class=\"error2\">Your inquiry failed, please try again</p>";
}
?>
<form name="cr" action="thankyou.php" method="post" onSubmit="return form_check();">
    <input type="hidden" name="creditoptin" value="yes" />
    <div id="cform">
        <div class="crp">
            <label for="first_name">First Name</label>
            <input id="first_name" type="text" name="cr[first_name]" 
value="" style="width:160px;" />   
        </div>
        <div class="crp">
            <label for="last_name">Last Name</label>
            <input id="last_name" type="text" name="cr[last_name]"   
value="" style="width:160px;" />
        </div>
        <div class="crp">
            <label for="phonecr">Phone</label>
            <input name="cr[phonecr]" style="width:34px;" id="phonecr"       
  maxlength="3" onkeyup="force_numeric(this);autotab(this,'phonecr2');" value="" /> -
            <input name="cr[phonecr2]" style="width:34px;"  
id="phonecr2" maxlength="3" onkeyup="force_numeric(this);autotab(this,'phonecr3');"   
value="" /> -
            <input name="cr[phonecr3]" style="width:44px;"   
id="phonecr3" maxlength="4" onkeyup="force_numeric(this);" value="" />
        </div>
        <div class="crp">
            <label for="email">Email Address</label>
            <input id="email" type="text" name="cr[email]" maxlength="60" value="" style="width:160px;" />
        </div>
        <div class="crp">
            <label for="zip">Zip Code</label>
            <input id="zip" name="cr[zip]" maxlength="5"  
onkeyup="force_numeric(this)" value="" />
        </div>
        <div id="submt">
            <input type="image" src="images/submit.png" value="Submit"  
onclick="if(typeof sub_pop == 'function')sub_pop();" />
</form>

Thanks guys!

  • 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-27T07:53:53+00:00Added an answer on May 27, 2026 at 7:53 am

    Instead of $first_name = $_POST['cr[first_name]'];, you should use $first_name = $_POST['first_name'];. Only the names of the input elements get translated into $_POST variables, without the name of the form.

    Also, you are not doing any input sanitatizing in your code, but just mailing on whatever the user entered in your form; this might be a security risk. You should check out the Web on topics like XSS and SQL injections and sanitize the user input before processing it further.

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

Sidebar

Related Questions

I know this probably really simple but Im not sure what im doing wrong...
I'm trying to free g_strdup but I'm not sure what I'm doing wrong. Using
I'm mot sure if I'm doing this wrong or not I don't know if
Not sure what I'm doing wrong with .live() $(function(){ var wrapper = $('#trailer_wrapper'); var
I am not sure what I am doing wrong, It would be great if
I am not sure what I could be doing wrong that causes info level
I'm not sure what I am doing wrong, but the text for my JPanels
Not sure if I am doing this correctly or not. Here is my .js
Im not sure if I'm doing this right. I have an action that I
Sorry if this has been answered somewhere; I'm not quite sure how to phrase

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.