still not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Bucketheadfan
Forum Newbie
Posts: 4
Joined: Fri Dec 24, 2010 1:44 pm

still not working

Post by Bucketheadfan »

I am trying to get

<input type="radio" name="Veterinarian Contact" value="Yes" id="Vet_yes" /><label for="Vet_yes">Yes</label>
<input type="radio" name="Veterinarian Contact" value="No" id="Vet_no" /><label for="Vet_no">No</label>

code to show up in an email through php and all of the attempts I have tried have failed so can anyone help me on what I should do to make a simple two radio button array to show whether or not Yes or No was clicked and show just Yes or No in my email

any help is much appreciated I am terrible at php

:banghead:
Neilos
Forum Contributor
Posts: 179
Joined: Fri Nov 19, 2010 2:07 am

Re: still not working

Post by Neilos »

I assume the inputs are in a form yes? Have the form post the selection.

I'd not use spaces in the name as, I think that this would cause you problems, use name="Veterinarian_Contact"

Then in the php you have;

Code: Select all

$selection = $_POST['Veterinarian_Contact'];
Then in the email build a string by concatenating your text with the variable like so;

Code: Select all

$string = 'You selected ' . $selection . '.';
Does this help?
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: still not working

Post by Jonah Bron »

Show us your code so we can see what the problem is.
Bucketheadfan
Forum Newbie
Posts: 4
Joined: Fri Dec 24, 2010 1:44 pm

Re: still not working

Post by Bucketheadfan »

Here is my code and my php

Code: Select all

<?php
$name=$_POST['Name'];
$address=$_POST['Address'];
$city=$_POST['City'];
$email=$_POST['Email'];
$catscale=$_POST['Cat Scale'];
$anyWayNeeded=$_POST['Any Way Needed'];
$veterinarianContact=$_POST['Veterinarian_Contact'];
$string='You selected ' . $selection . '.';
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
   die('Invalid email address.');
}

$email_from=$email;
$email_subject="Foster Form Submission";
$email_body=$string;

$to="sweettooth_dukenukem@yahoo.com";
$headers = "From: $email_from \r\n";
$headers .="Reply-To: $Email \r\n";

mail($to,$email_subject,$email_body,$headers);

?>
Here is my Code:
[text]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Iroquois County Animal Rescue</title>
<link href="external1.css" rel="stylesheet" type="text/css" media="screen" />
<link href="externalprint1.css" rel="stylesheet" type="text/css" media="print" />
<script type="text/javascript" rel="stylesheet" src="fosterValidate.js"></script>
</head>
<body>

<div class="container"><a name="top"></a>
<div class="header"><a href="../index.html"><img src="../Images/catpic.png" alt="Insert Logo Here" style="background: #C6D580; display:block;" /></a>
<!-- end .header --></div>
<div class="sidebar1">
<ul class="nav">
<li><a href="../index.html">Index</a></li>
<li><a href="about.html">About</a></li>
<li><a href="adoption.html">Adoption</a></li>
<li><a href="forms.html">Forms</a></li>
</ul>
<!-- end .sidebar1 --></div>
<div class="content">
<h1>Foster Care</h1>
<h3><i>Welcome to the ICAR foster care program.</i></h3>
<p><i>Thank you so very much for your interest in volunteering your time to improve the lives of neglected and homeless pets until an appropriate permanent home is found. Contributing to the lives of these special pets is extremely rewarding.</i></p>

<form action="FormToEmail.php" name="fosterForms" method="post" enctype="multipart/form-data" onsubmit="">
<p><br/>Name: <input name="Name" type="text" id="name" size="30" /><br />
Address: <input name="Address" type="text" id="address" size="35" /><br />
City: <input name="City" type="text" id="city" size="15" /> State: <input name="state" type="text" id="state" size="2" /> Zip: <input name="Zip" type="text" id="zip" size="10" /><br />
Home Phone: <input name="Home Phone" type="text" id="homePhone" size="15" /> Cell Phone: <input name="Cell Phone" type="text" id="Cell Phone" size="15" /><br />
Work Phone: <input name="Work Phone" type="text" id="workPhone" size="15" /> Other Phone: <input name="Other Phone" type="text" id="Other Phone" size="15" /><br />
E-mail: <input name="Email" type="text" id="email" size="30" /><br />
<br/>
In case of emergency:<br />
Name: <input name="Emergency Name" type="text" id="Emergency Name" size="25" /> Phone: <input name="Emergency Phone" type="text" id="emergencyPhone" size="15" /><br />
Name: <input type="text" name="Emergency Name 2" size="25" /> Phone: <input name="Emergency Phone 2" type="text" id="emergencyPhone2" size="15" /><br />
<br />
Please check other areas in which you would like to help:<br />
<br />
<input type="checkbox" name="Clean Cages" size="25" />Cleaning Cages/Kennels <input type="checkbox" name="Walking Dogs" size="25" />Walking Dogs<br />
<input type="checkbox" name="Socialize Cats" size="25" />Socializing Cats <input type="checkbox" name="Fundraising" size="25" />Fundraising<br />
<input type="checkbox" name="Transporting" size="25" />
Transporting
<input type="checkbox" name="Any Way Needed" size="25" />
Any Way Needed

<input type="checkbox" name="Other" size="25" />Other<br /></p>
<p><strong>Please tell us about your current pets:</strong>
<ins><ul>
<li>Name</li>
<li>Species/Breed</li>
<li>Age</li>
<li>S/N</li>
</ul></ins>
</p>
<p><textarea name="Pets" rows="5" cols="30">Enter Information...</textarea>
<br /><br />
Rabies Vaccination Date:<input type="text" name="Rabies Vaccination" size="15" /><br />
Parvo Distemper Date:<input type="text" name="Parvo Distemper" size="15" /><br />
Kennel Cough Date:<input type="text" name="Kennel Cough" size="15" /><br />
Lepto Date:<input type="text" name="Lepto" size="15" /><br />
Heartworm Preventative Type:<input type="text" name="Heartworm Preventative Type" size="15" /><br />
Date:<input type="text" name="Heartworm Preventative" size="15" /><br />
Flea Preventative Type:<input type="text" name="Flea Preventative Type" size="15" />
<br />
Date:<input type="text" name="Flea Preventative" size="15" />
</p>
<p>May we contact your veterinarian for a reference?</p>
<p><input type="radio" name="Veterinarian_Contact" value="Yes" /><label for="Vet_yes">Yes</label>
<input type="radio" name="Veterinarian_Contact" value="No" /><label for="Vet_no">No</label>
<br /><br />Name: <input type="text" name="Veterinarian Name" size="30" /><br />
Address: <input type="text" name="Veterinarian Address" size="35" /><br />
Phone: <input name="Veterinarian Phone" type="text" id="Veterinarian Phone" /><br /></p>
<p>On a scale of 1(little) to (extensive), please rank your experience/knowlege:</p>
<p>Dogs: <input type="radio" name="Dog Scale" value="1" />1
<input type="radio" name="Dog Scale" value="2" />2
<input type="radio" name="Dog Scale" value="3" />3
<input type="radio" name="Dog Scale" value="4" />4
<input type="radio" name="Dog Scale" value="5" />5</p>
<p>
Cats: <input type="radio" name="Cat Scale" value="1" />1
<input type="radio" name="Cat Scale" value="2" />2
<input type="radio" name="Cat Scale" value="3" />3
<input type="radio" name="Cat Scale" value="4" />4
<input type="radio" name="Cat Scale" value="5" />5
</p>
<p>Please explain your house-training program:</p>
<p><textarea name="House Training" rows="5" cols="30">Enter House Training Information...</textarea></p>
<p>Have you had any formal training with animals or special skills?</p>
<p><input type="radio" name="Skills" value="Yes" />Yes
<input type="radio" name="Skills" value="No" />No</p>
<p>You must accept these Terms.</p>
<p><input type="button" value="Terms" name="terms" onclick="createWindow()" /></p>
<p>Registration with state sent in with payment on:<input name="State Registration" type="text" id="State Registration" size="15" /></p>
<p><input type="submit" value="Submit" />
<input type="reset" value = "Reset" /></p>
</form>
<p><a href="#top">Back To Top</a></p>


<!-- end .content --></div>
<div class="footer">
<p>ICARe &#169; 2010</p>
<!-- end .footer --></div>
<!-- end .container --></div>
</body>
</html>
[/text]
Neilos
Forum Contributor
Posts: 179
Joined: Fri Nov 19, 2010 2:07 am

Re: still not working

Post by Neilos »

You've only half copied the code I wrote, notice the difference;
Bucketheadfan wrote:

Code: Select all

$veterinarianContact=$_POST['Veterinarian_Contact'];
$string='You selected ' . $selection . '.';
and;
Neilos wrote:

Code: Select all

$selection = $_POST['Veterinarian_Contact'];
$string = 'You selected ' . $selection . '.';
You variable string will read "You selected .". Because you don't assign anything to the variable $selection.

Before trying to send it off in an email check that you get the string built propperly by echo'ing it to the browser, then try sending it in the email. So try;

Code: Select all

<?php

$veterinarianContact=$_POST['Veterinarian_Contact'];

$string='You selected ' . $veterinarianContact . '.';

echo $string;

?>
And then if it works try;

Code: Select all

<?php
$name=$_POST['Name'];
$address=$_POST['Address'];
$city=$_POST['City'];
$email=$_POST['Email'];
$catscale=$_POST['Cat Scale'];
$anyWayNeeded=$_POST['Any Way Needed'];
$veterinarianContact=$_POST['Veterinarian_Contact'];
$string='You selected ' . $veterinarianContact . '.';
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
   die('Invalid email address.');
}

$email_from=$email;
$email_subject="Foster Form Submission";
$email_body=$string;

$to="sweettooth_dukenukem@yahoo.com";
$headers = "From: $email_from \r\n";
$headers .="Reply-To: $Email \r\n";

mail($to,$email_subject,$email_body,$headers);

?>
I find it is always easier to break problems down into their component parts and get them working individually before trying to hammer it all together.
Post Reply