Jump to content

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'])

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.