Jump to content

[SOLVED] Invalid Mailing Code


everlifefree

Recommended Posts

Hi I am new here so I hope this is where and how I post this...

 

On my site I have a this code that is supposed to mail a link but it sends something weird that doesn't work... Please Help!

 

Here's The PHP CODE:

if (isset($_POST["Submit"], $_POST["topic"], $_POST["body"]) and $_POST["topic"] != "" and $_POST["body"] != "") {

 

if (isset($_POST["opponent"]) and $_POST["opponent"] != "") {

 

$opponent = myF(myQ("SELECT `id` FROM `[x]users` WHERE LCASE(`username`) = '".strtolower($_POST["opponent"])."'"));

if ($opponent["id"] > 0) {

 

myQ("

INSERT INTO `[x]debates`

(`user`,`opponent`,`date`,`duration`,`topic`,`body`,`votes`)

VALUES (

'".me("id")."',

'{$opponent["id"]}',

'".time()."',

'{$_POST["duration"]}',

'{$_POST["topic"]}',

'{$_POST["body"]}',

'".pk(array(me("id"),$opponent["id"]))."'

)

");

 

$mail_replace = array(

"{me}" => me("username"),

"{url}" => "http://".$_SERVER['HTTP_HOST'].str_replace("/index.php", NULL, $_SERVER['PHP_SELF'])."?L=debates.request&id=".mysql_insert_id()

);

 

Here's The mails tpl:

 

<obj mail_subject>Debate request with {me}!</obj mail_subject>

<obj mail_body>{me} requested a Debate with you. Please click the following link to accept or deny this request. <a href="{url}">My Debates</a></obj mail_body>

 

 

Here's The mail sent now:

 

Dan requested a Debate with you. Please click the following link to accept or deny this request. (link here that will take you to 404 error) My Debates

 

Here's The mail I want sent:

Dan requested a Debate with you. Please click the following link to accept or deny this request. My Debates (the words My Debates the link taking you to "main url"?L=debates.request&id="debate id that php script requested to mail")

 

Link to comment
https://forums.phpfreaks.com/topic/84586-solved-invalid-mailing-code/
Share on other sites

I believe the problem lies in the below php code if that will help anyone know what to fix...

 

Problem PHP:

 

            $mail_replace = array(

              "{me}" => me("username"),

              "{url}" => "http://".$_SERVER['HTTP_HOST'].str_replace("/index.php", NULL, $_SERVER['PHP_SELF'])."?L=debates.request&id=".mysql_insert_id()

            );

 

"{url}" => "http://".$_SERVER['HTTP_HOST'].str_replace("/index.php", NULL, $_SERVER['PHP_SELF'])."?L=debates.request&id=".mysql_insert_id()

 

change to:

"{url}" => "http://".$_SERVER['HTTP_HOST'].str_replace("/index.php", "?L=debates.request&id=".mysql_insert_id(),$_SERVER['PHP_SELF'])

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.