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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:56:35+00:00 2026-06-18T01:56:35+00:00

I have an ajax post coming to my PHP file for sending an email.

  • 0

I have an ajax post coming to my PHP file for sending an email.
The issue is, my html contact form is always changing, one user might use 10 text-inputs, another user might use 5, etc.

The data is coming to the PHP file like this :

txt1=John&txt2=aol@aol.com&txt3=5550123944&dropDown1=Sales&question=How+are+you

The PHP file is like this :

<?php
$emailSubject = 'Customer Has a Question!';
$webMaster = 'giberisk@yahoo.com';

$name = $_POST ['name'];
$email = $_POST['email'];
$phone = $_POST ['phone'];
$question = $_POST ['question'];


$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Phone: $phone <br>
Question: $question <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
$theResults = <<<EOD
EOD;
echo "$theResults";
?> 

What do I have to do, so that the PHP file finds out how many arguments were passed, and to name the variables after the name of those arguments ?

I hope I was clear enough,

Thanks in advance

  • 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-18T01:56:36+00:00Added an answer on June 18, 2026 at 1:56 am

    you could do foreach, like

    $count = count($_POST); //shows number of variables POST'ed
    foreach($_POST as $key => $val ) {
       echo $key . "==>" .$val;   
       //or assign values to key variables
       ${$key} = $value; //${$key} will be variable holding $value as value
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a form validation using ajax post method. But i got the
I have a form which POST's its data via AJAX: $.ajax({ type: POST, url:
I have this jQuery script var dataString = class_id=+class_id; $.ajax({ type: POST, url: page.php,
I have this ajax code: return $.ajax({ type: POST, url: somefile.php, cache:false, data: {
I have a contact edit form. The entire form is requested through ajax (loaded
I have a AJAX post method that gets xml data from server. But when
I have a jQuery AJAX post request that is unexpectedly triggering the error callback
I have a script that submits data via an ajax POST. It is called
I'm having problems with understanding how jQuery create headers for ajax post. I have
I want to have a set of checkboxes that use AJAX to post to

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.