[php] Need help with Php Mailing script

Initiate Mage
Joined
Nov 11, 2006
Messages
0
Reaction score
0
Hi im at work and i need some help we were useing a windows based server and now that we have switched over to a linux server .asp dose not work so i started setting one up in php but its not working. Im getting the error

Parse error: parse error, unexpected T_VARIABLE in /home/www/gangways.biz/cgi-bin/jmail.php on line 109

line 109 is
PHP:
$body = "First Name: "$_POST["$firstname"];

the php script is calling information from a previous page (the page is html)

PHP:
<?
$to = "[email protected]";
$subject = "Inquiry From Gangways.biz";
$body = "First Name: "$_POST["$firstname"];
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
 } else {
  echo("<p>Message delivery failed...</p>");
 }
?>

This is the little script i made

below is the whole page

Thanks for your time

Tom McClellan

PHP:
<head>
<meta name="description" content="" />
<meta name="keywords" content="docks, ramps, gangways, brow" /> 
<meta name="copyright" content="Superior Welding" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Superior Docks - Inquiry Confirmation</title>
<!-- InstanceEndEditable -->
<link href="../css/v1.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {color: #000000}
.style2 {font-size: 14px}
.style4 {
 color: #000000;
 font-size: 14;
 font-weight: bold;
}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>
<body onload="MM_preloadImages('../img/buttons/home_two.gif','../img/buttons/drawings_two.gif','../img/buttons/pricelist_two.gif','../img/buttons/gallery_two.gif','../img/buttons/specifications_two.gif','../img/buttons/inquiry_two.gif')">
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr class="topbarbg">
    <td width="800" height="30" align="right"><span class="smallwhitetext" style="padding:12px;"><a href="../index.htm" >Home</a> |<a href="../inquiry.htm"> Contact Us</a></span></td>
  </tr>
  <tr>
    <td align="center" valign="middle"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodycolor">
      <tr>
        <td width="200" align="center" valign="middle"><h1><!-- InstanceBeginEditable name="PageTitle" -->Inquiry Form <!-- InstanceEndEditable --></h1></td>
        <td width="600" height="50" align="left" valign="bottom"><img src="../img/logo.gif" alt="company logo" width="311" height="41" /></td>
      </tr>
      <tr>
        <td width="200" align="left" valign="top"><table width="38%" border="0" cellspacing="0" cellpadding="0">
          <tr bgcolor="#FFFFFF">
            <td align="left" valign="top" class="bodycolor"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="center"><a href="../index.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','../img/buttons/home_two.gif',1)"><img src="../img/buttons/home-one.gif" alt="Home" name="home" width="160" height="29" border="0" id="home" /></a><a href="index.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image6','','../img/buttons/home_two.gif',1)"></a></td>
              </tr>
              <tr>
                <td align="center"><a href="../drawings.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Drawings','','../img/buttons/drawings_two.gif',1)"><img src="../img/buttons/drawings-one.gif" alt="Drawings" name="Drawings" width="160" height="29" border="0" id="Drawings" /></a></td>
              </tr>
              <tr>
                <td align="center"><a href="../price.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Pricelist','','../img/buttons/pricelist_two.gif',1)"><img src="../img/buttons/pricelist-one.gif" alt="PriceList" name="Pricelist" width="160" height="29" border="0" id="Pricelist" /></a></td>
              </tr>
              <tr>
                <td align="center"><a href="../gallery.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Gallery','','../img/buttons/gallery_two.gif',1)"><img src="../img/buttons/gallery-one.gif" alt="gallery" name="Gallery" width="160" height="29" border="0" id="Gallery" /></a></td>
              </tr>
              <tr>
                <td align="center"><a href="../specs.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('specs','','../img/buttons/specifications_two.gif',1)"><img src="../img/buttons/specifications-one.gif" alt="Specifications" name="specs" width="160" height="29" border="0" id="specs" /></a></td>
              </tr>
              <tr>
                <td align="center"><a href="../inquiry.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Inquiry','','../img/buttons/inquiry_two.gif',1)"><img src="../img/buttons/inquiry-one.gif" alt="Inquiry" name="Inquiry" width="160" height="29" border="0" id="Inquiry" /></a></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td><p class="smallwhitetext style1 style2"><span class="smallgraytext">420 Christian Ridge Rd. <br />
                      Ellsworth, ME 04605 <br />
                      Ph: 207-664-2121 <br />
                      Fax: 207-664-2533</span></p>
                    </td>
                </tr>
                <tr>
                  <td align="center"><span class="style1"><strong><img src="../img/email.gif" alt="email image" /></strong></span></td>
                </tr>
              </table>
              </td>
          </tr>
        </table></td>
        <td width="600" align="left" valign="top"><!-- InstanceBeginEditable name="ContentArea" -->
<?
$to = "[email protected]";
$subject = "Inquiry From Gangways.biz";
$body = "First Name: "$_POST["$firstname"];
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
 } else {
  echo("<p>Message delivery failed...</p>");
 }
?>
   <p>Thank you for contacting superior Docks. </p>
          <p>Your message has been sent. </p>
          <p>A representative will be in touch soon. </p>
          <!-- InstanceEndEditable --></td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td height="30" align="right" valign="middle" class="smalltext bodycolor"></td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>
 
Re: Need help with Php Mailing script

You should place a dot if you want to concenate strings.

$body = "First Name: ".$_POST["$firstname"];

Also use <?php instead of <? ;)
 
<? doesn't work on all servers, while <?php does. Also the code after <? has some different interpretations. Its just best to be sure and use the <?php tag.
 
Back