Jump to content

Please help with syntax


lingo5

Recommended Posts

Hi,

I have this "tell a friend" form:

 

<form name=refer action="processors/referer.php" method="POST"><td align="center" valign="middle"><table width="600" border="0" cellspacing="0" cellpadding="0"><tr>
  <td height="30" colspan="2"><strong>
Tus datos 
    <input name="id_propeidad" type="hidden" id="id_propeidad" value="<?php echo $row_destacadas_RS['id_propiedad']; ?>" />
    <input name="tipopropiedad" type="hidden" id="tipopropiedad" value="<?php echo $row_destacadas_RS['tipopropiedad']; ?>" />
  </strong>
    <input name="regimen" type="hidden" id="regimen" value="<?php echo $row_destacadas_RS['regimen']; ?>" />
    <input name="localidad" type="hidden" id="localidad" value="<?php echo $row_destacadas_RS['localidad']; ?>" /> <input name="isla" type="hidden" id="isla" value="<?php echo $row_destacadas_RS['isla']; ?>" /></td></tr> <tr><td height="30">
tu nombre:<input name="fromName" type="text" id="fromName"></td><td height="30">
tu email:<input name="fromEmail" type="text" id="fromEmail"></td></tr> <tr><td height="30" colspan="2"><strong>
Datos de tu amigo</strong></td></tr><tr><td height="30">
su nombre:<input name="toName" type="text" id="toName"></td><td height="30">
tu email:<input name="toEmail" type="text" id="toEmail"></td></tr><tr align="center"><td height="30" colspan="2">
<input type="submit" name="Submit" value="Refer"></td></tr> </table></td></form>

 

and this is the referer script that sends the email:

 

<?php
$fromName=$_REQUEST["fromName"];
$fromEmail=$_REQUEST["fromEmail"];
$toName=$_REQUEST["toName"];
$idPropiedad=$_REQUEST["id_propiedad"];
$toEmail=$_REQUEST["toEmail"];
if ($fromEmail) 
{$ref=(http:www/sitename/propiedad_detalle.php?id_propiedad=$idPropiedad);
if ($fromName=='')
$subject= "Your friend has referred you this link from www.sitename.com"; 
else$subject= "$fromName has referred you this link from www.sitename.com"; 
$message = "Hola $toName, tu amigo $fromName te recomienda que mires esta propiedad.\r\nPuedes verla aquí $ref ";
$from = "Desde: $fromEmail\r\n";
mail($toEmail, $subject, $message, $from);
header ("location:".$ref);
}?>

 

The email is sent ok except for this part:

 

if ($fromEmail) 
{
$ref=(http:www.sitename/propiedad_detalle.php?id_propiedad=$idPropiedad);

 

This needs to be a link back to the property record, but all I get on the email is http://www.sitename.com/propiedad_detalle.php?id_propiedad=$idPropiedad

 

Thanks

Link to comment
Share on other sites

Turn error reporting on when your developing. That piece of code will produce an error.

 

It should be...

 

$ref = "http:www/sitename/propiedad_detalle.php?id_propiedad=$idPropiedad";

 

And if you want it to be a link, you will need to wrap it in the html it needs to be a link.

 

$ref = "<a href='http:www/sitename/propiedad_detalle.php?id_propiedad=$idPropiedad'>link</a>";

 

You will also however, need to send the email as html. This is covered in the mail page of the manual.

Link to comment
Share on other sites

Thanks thorpe, I have set the script to send in html format like so:

 

<?php
$fromName=$_REQUEST["fromName"];
$fromEmail=$_REQUEST["fromEmail"];
$toName=$_REQUEST["toName"];
$toEmail=$_REQUEST["toEmail"];
if ($fromEmail)
{
$ref = "<a href='http://www.sitename.com/propiedad_detalle.php?id_propiedad=$idPropiedad'>link</a>";
if ($fromName=='')
$subject= "Your friend has referred you this link from www.sitename.com"; 
else
$subject= "$fromName has referred you this link from www.sitename.com"; 
$message = " Dear $toName,\r\nYour friend $fromName has referred this link to you.\r\nPlease visit this link by clicking $ref ";
$from = "From: $fromEmail\r\n";

//*** Uniq id Session ***//
$strSid = md5(uniqid(time()));
$strHeader = "";
$strHeader .= "$fromEmail\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n"; 
$strHeader .= "Cc: \r\n";
$strHeader .= "Bcc: salva@sitename.es,dora@sitename.es\r\n";

$strHeader .= "MIME-Version: 1.0\n";
$strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
$strHeader .= "This is a multi-part message in MIME format.\n";

$strHeader .= "--".$strSid."\n";
$strHeader .= 'Content-Type: text/html; charset=iso-8859-1'.$eol;
$strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
$strHeader .= $message."\n\n";


$flgSend = @mail($toEmail, $subject, $message, $from); // @ = No Show Error //

if($flgSend)
{
header("Location: ../index.php?formsentok=true"); 
}
//echo "Mail send completed.";
//}
else
{
header("Location: ../index.php?formfailed=true");  
}
?>

but get the following error

 

Parse error: syntax error, unexpected $end in /usr/home/sitename.com/web/test/processors/referer.php on line 45

 

Line 45 is the last line!!

Link to comment
Share on other sites

Thanks Thorpe,

this is my code modified to send email as html...i'm definately doing something wrong because the link still doesn't appear as a link on the email.

<?php
$fromName=$_REQUEST["fromName"];
$fromEmail=$_REQUEST["fromEmail"];
$idPropiedad=$_REQUEST["id_propiedad"];
$toName=$_REQUEST["toName"];
$toEmail=$_REQUEST["toEmail"];
if ($fromEmail)
{
$ref = "<a href='http://www.sitename.com/propiedad_detalle.php?id_propiedad=$idPropiedad'>here</a>";
if ($fromName=='')
$subject= "Your friend has referred you this link from www.sitename.com"; 
else
$subject= "$fromName has referred you this link from www.sitename.com"; 
$message = " Dear $toName,\r\nYour friend $fromName has referred this link to you.\r\nPlease visit this link by clicking $ref ";
$from = "From: $fromEmail\r\n";

//*** Uniq id Session ***//
$strSid = md5(uniqid(time()));
$strHeader = "";
$strHeader .= "$fromEmail\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n"; 
$strHeader .= "Cc: \r\n";
$strHeader .= "Bcc: \r\n";

$strHeader .= "MIME-Version: 1.0\n";
$strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
$strHeader .= "This is a multi-part message in MIME format.\n";

$strHeader .= "--".$strSid."\n";
$strHeader .= 'Content-Type: text/html; charset=iso-8859-1'.$eol;
$strHeader .= "Content-Transfer-Encoding: 7bit\n\n";

$flgSend = @mail($toEmail, $subject, $message, $from); // @ = No Show Error //

if($flgSend)
{
header("Location: ../index.php?formsentok=true"); 
}
//echo "Mail send completed.";
//}
else
{
header("Location: ../index.php?formfailed=true");  
}
}

?>

please help... :confused:

Link to comment
Share on other sites

You are not including you headers within the mail() function.

 

$strHeader is where you set your headers, but you don't do anything with them.

 

Try this:

 

$strHeader  = "From: Your Name <". $fromEmail .">\r\n"; // change Your Name to your name or website name
$strHeader .= "Reply-To: ". $fromEmail ."\r\n";
$strHeader .= "MIME-Version: 1.0\r\n";
$strHeader .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

$flgSend = @mail($toEmail, $subject, $message, $strHeader);

 

Edit: Also, please, for your own sake/sanity, start indenting your code.  And, unless you are sending attachments, you do not need to set boundaries.

Link to comment
Share on other sites

Thanks MrMarcus...works fine

;)

 

No problem.

 

Please remove any/all instances of @ from your code.  You are suppressing valuable errors messages that could help you troubleshoot issues with your application.  Removing the @ (from @mail()) and checking your error_log during development would have shown you that your mail() function was failing.

 

Errors should never be suppressed.  They are errors and should not be ignored.  Proper handling and logging by way of conditions will help you locate and resolve application errors, as well as save you time and headaches.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.