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
you could do foreach, like