Submit URL Link give /

Discussion in 'PHP' started by MesCasinos, Jun 22, 2010.

  1. #1
    Hi guys!! Ok, im currently making my own newsletter, all is working fine but just one thing is goin' bad! :p

    Ok, first of all, i explain you the problem, after i post the codes. The problem is simple, i've a textarea in index.php named message, and a button submit..

    I submit in HTML so if i put <b>test</b>, its gona send to the email test. BUT, if i try to put a link, exemple <a href="http://www.domain.com/mylink.php">this is my text</a>, then the received email will show the text (this is my text) but he will link to /

    Same thing as if my link was <a href="/">this is my text</a>. I tried to add enctype, plain, html .. nothing change..

    I tried to include text from my language file, with links, and the link works. But if i put a link directly to the textarea, href will be /.

    You will better understand watching the code.

    Dont worry about the first textarea called message, this is a wymeditor im planing to use. But as i saw the href sended in the mails was /, i deceide to test the mail with both, a normal textarea ands this one to see if the same shit happen, but its the same for both, as you see in the second code
    
    ..code before
    <form id="myform1" name="myform1" method="post" action="sendmail.php?sub_lang=<?php echo $_GET['sub_lang']; ?>">
    <input type="hidden" name="action">
    <input type="hidden" name="nom" value="MonsterBonuses.com"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td>Titre: 
              <input name="titre" type="text" id="titre" size="50" /></td>
          </tr>
          <tr>
            <td>Message:</td>
          </tr>
          <tr>
            <td align="left">
              <textarea name="message" id="message" rows="15" class="wymeditor"></textarea>
              <label for="textarea"></label>
              <textarea name="message2" id="message2" cols="45" rows="5"></textarea>
              <input type="submit" name="button" id="button" value="Envoyé" class="wymupdate" />
            </td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
        </table></form>
    code after..
    
    HTML:
    this is my sendmail.php code
    
    <?PHP
    include ("../password_protect.php");
    
    /* Connection DATABASE */
    include("../../include/****/****.php");
    
    mysql_select_db("****", $con);
    
    $result = mysql_query("SELECT * FROM newsletters WHERE sub_lang='". $_GET['sub_lang'] ."' ORDER BY nom ASC");
    
    //inclue le header et footer dans la bonne langue
    if ($_GET['sub_lang'] == "fr"){
    	include("../../include/lang/fr.php");
    }else{
    	include("../../include/lang/en.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>Administration Newsletter [<?php echo $titre_lang; ?>]</title>
    </head>
    <body>
    <?PHP
    while($row = mysql_fetch_array($result)){
    
    //passe les variable à functions_mail.php en globals sinon marche pas
    
    //envoie du mail de première inscription
    
    //titre du mail 
    $sujet = ''.$_POST[titre].''; 
    $email = $row['email'];
    $email_md5 = $row['email_md5'];
    
    // 1 exemple de contenu du mail
    // le premier = doit pas avoir de . devant!!
    $contenu = ''.$ajax_newsletter_header.'';
    $contenu .= ''.$_POST[message].'';
    $contenu .= ''.$_POST[message2].'';
    $contenu .= '<hr>'.$ajax_newsletter_footer1.' <a href="http://www.monsterbonuses.com/newsletter/unsubscribe.php?u='.$email_md5.'">'.$ajax_newsletter_footer2.'</a>';
    
    // envoi du mail HTML 
    $from = "From: MonsterBonuses.com <noreply@monsterbonuses.com>\nMime-Version:"; 
    $from .= " 1.0\nContent-Type: text/html; charset=utf-8\n"; 
    
    // envoie du mail 
    if (mail($email,$sujet,$contenu,$from)){ 	
    echo "Envoyé avec succès à ".$row['email']."<br>";
    }else{
    	echo "erreur lors de l'envoie à ".$row['email']."";
    }
    }
    ?>
    </body>
    </html>
    
    PHP:

    This is sending a link correct:
    $contenu .= '<hr>'.$ajax_newsletter_footer1.' <a href="http://www.monsterbonuses.com/newsletter/unsubscribe.php?u='.$email_md5.'">'.$ajax_newsletter_footer2.'</a>';
    HTML:
    But not the link from the textareas.

    Thanks, i hope you guys will undertsand with my bad english, sry :eek:
     
    MesCasinos, Jun 22, 2010 IP
  2. SNo

    SNo Member

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    is any js code linked to html page?
     
    SNo, Jun 23, 2010 IP
  3. MesCasinos

    MesCasinos Peon

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I solved the problem, for those who want to know:

    in my sendmail.php, i simply replaced the original contenu .= for:

    $contenu .= stripslashes($_POST['message']);


    was just this.. héhéhé ;)
     
    MesCasinos, Jun 23, 2010 IP