Link to home
Start Free TrialLog in
Avatar of JudithARyan
JudithARyanFlag for United States of America

asked on

Mail via php

I'm trying to pass parameters between two php pages and then send email.  I get a parse error on the $subject line on the 2nd page and I'm not sure the parameters from the 1st page are being picked up.  What's my problem????

Here's my code:

From Page1.php:
<a href="Page2.php?ID=$ServiceRequest[ID]&Neighbor=$ServiceRequest[Neighbor]&Date=$ServiceRequest[SvcDate]">I'll Do This!</a>


To  Page2.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thank You for Volunteering!</title>
</head>
<body>

<?php
$ID=$HTTP_GET_VARS['ID'];
$Neighbor=$HTTP_GET_VARS['Neighbor'];
$Date=$HTTP_GET_VARS['Date'];

$to = "reqdesk@vvcaregivers.org";
$subject = "I'll do " . $ID . " for " . $Neighbor;       
$message = "volunteer for service";
mail(&to,$subject,$message);
echo "Mail Sent";  
</body>
</html>
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zappafan2k2
zappafan2k2

This line
<a href="Page2.php?ID=$ServiceRequest[ID]&Neighbor=$ServiceRequest[Neighbor]&Date=$ServiceRequest[SvcDate]">I'll Do This!</a>

Open in new window

looks funky.  Are the three variables buried in the query string?  If so, it should be
<a href="Page2.php?ID=<?php echo $ServiceRequest['ID']; ?>&Neighbor=<?php echo $ServiceRequest['Neighbor']; ?>&Date=<?php echo $ServiceRequest['SvcDate']; ?>">I'll Do This!</a>

Open in new window

Whenever you want to use PHP code, it has to be between <?php  ?>

In the code for page 2, this line
mail(&to,$subject,$message);

Open in new window

should be
mail($to,$subject,$message);

Open in new window


Avatar of JudithARyan

ASKER

Thanks for your help, I'll try both suggestions and let you know how I did.

Judith
DaveBaldwin, since the first section of your demo isn't in a <html  .... </html>  page, am I supposed to insert the first section in one of my own pages?  Sorry for my ignorance, I'm really new to php.

Thanks for your help.  Judith
No, that is a complete page on it's own.  The PHP runs on the server and the HTML including any generated by PHP gets sent to the browser.  My demo has a form on it that posts the info back to itself on the server where it gets processed and the results sent to your browser.
Thanks so much for your help.  Sorry for the delay