We help IT Professionals succeed at work.
Get Started

How to avoid some values to be sent to email (Simple PHP Contact Form)

egolddude
egolddude asked
on
231 Views
Last Modified: 2006-12-06
I know simple PHP Contact Form (or submitted forms to be sent to email).
Goes like this (in 3 steps) : form.htm .. > .. submit.php .. > .. submitted.htm

** ON  form.htm **
<form method="post" action"submit.php">
Name: <input type="text" name="name"><br>
Address: <input type="text" name="address"><br>
City: <input type="text" name="city"><br>
State: <input type="text" name="state"><br>
ZipCode: <input type="text" name="zip">
</form>

** ON  submit.php **
<?
$name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$msg = "Details Submitted:\n
Name: $name\n
Address: $address\n
City: $city\n
State: $state\n
ZipCode: $zip\n";
mail("myemail@yahoo.com", "Simple Form Submitted", $msg);
header("Location: submitted.htm");
?>

** ON  submitted.htm **
Just a THANK YOU page.


WHAT I WANT ...
---------------------
I dont want to put a JavaScript Form Validation (yes, even a blank form can be submitted) BUT I want the form ONLY submits the field(s) that a client filled. Can someone helps in modifying the PHP Codes ?

So, if a client fill all fields, I should receive reports like this on my email:
-------------------------------------------
Details Submitted:
Name: John Doe
Address: Route 66
City: Los Angeles
State: California
ZipCode: 90028
-------------------------------------------

And, if a client only fill 1 field then I should ONLY receive reports like this on my email (which cannot be done with the PHP Codes as above):
-------------------------------------------
Details Submitted:
Name: Britney Spears
-------------------------------------------

Any answers OR suggestions are gladly welcomed ... Thanks.
Comment
Watch Question
Top Expert 2006
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE