0

my problem is am not able send a downladable link to mail , actually i have selected two variable which i have get the values of (userID ,userPic) below the so now am not able to send the link to mail

 <?php
    if(isset($_POST['useremail'])) {


    $uploadID =  $_GET['uploadID'];
    $filename =    $_GET['userPic'];
    $memberID =$_SESSION['memberID'];
    $email   =     $_SESSION['email'];
    $mail  =     $_POST['useremail'];

    $stmt = $DB_con->prepare('INSERT INTO share(uploadID,useremail,userPic,memberID) VALUES(:uploadID, :useremail,:userPic, :memberID)');
                $stmt->bindParam(':uploadID',$uploadID);
                $stmt->bindParam(':useremail',$mail);
                $stmt->bindParam(':userPic',$filename);
                $stmt->bindParam(':memberID',$memberID);

                if($stmt->execute())
                {
                    $successMSG = "succesfully sended mail ..." ;
                    header("location:user.php"); 
                }   


    > Blockquote
    $url = "<p>

 <a href='http://www.adroitsws.com/data_transfer/download.php?filename=<?php echo $row['userPic']; ?>'>http://www.adroitsws.com/data_transfer/download.php?filename=<?php echo $row['userPic']; ?></a></p>"

     $email_from =$email;

        $email_subject = "Your email subject line";

        function died($error) {

            // your error code can go here

            echo "We are very sorry, but there were error(s) found with the form you submitted. ";

            echo "These errors appear below.<br /><br />";

            echo $error."<br /><br />";

            echo "Please go back and fix these errors.<br /><br />";

            die();

        }
            if(!isset($_POST['useremail'])  ) {   

            died('We are sorry, but there appears to be a problem with the form you submitted.');       

        }

        $email_to = $_POST['useremail']; // required

        $error_message = "";

        $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';

      if(!preg_match($email_exp,$email_to)) {

        $error_message .= 'The Email Address you entered does not appear to be valid.<br />';

      }


        function clean_string($string) {

          $bad = array("content-type","bcc:","to:","cc:","href");

          return str_replace($bad,"",$string);

        }

        $email_message .= "mail: ".clean_string($email_to)."\n";

    // create email headers

    $headers = 'From: '.$email_from."\r\n".

    'Reply-To: '.$email_to."\r\n" .

    'X-Mailer: PHP/' . phpversion();

    @mail( $email_to, $email_subject,$url, $email_message, $headers);  

    ?>

1 Answers1

1

You can check following links which shows how to send mail with attachment in php.

  1. From stackoverflow
  2. From sanwebe
  3. From tutdepot

Also Find out that in your code there is error. Please replace your $URL by below code and check.

$url = "<p> <a href=http://www.adroitsws.com/data_transfer/download.php?filename=".$row['userPic'].">"
            . "http://www.adroitsws.com/data_transfer/download.php?filename=".$row['userPic']."</a></p>";
Community
  • 1
  • 1
vijay
  • 731
  • 5
  • 15