adding a hyperlink to a hidden form input

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ardan16
Forum Commoner
Posts: 32
Joined: Fri Aug 01, 2008 6:07 am

adding a hyperlink to a hidden form input

Post by ardan16 »

Hi all,
could be going about this the wrong way.

Code: Select all

<p>Incident Report Id: <input type="text" name="Incident Report Id" size="15" maxlength="15" value="' . $row[0] . '" /></p>
<p>Reported by: <input type="text" name="Reported by" size="15" maxlength="30" value="' . $row[1] . '" /></p>
<p>Description: <textarea name="Details" rows="8" cols="70">' . $row[2] . '</textarea> </p>
<br/>
 
<input type="hidden" name="link" value="<a href = \"http://just4em.com/incident/view_reports.php\">Find Incident</a>"/>
Can someone please give me direction or syntax for the last input.
First a form is shown to enable user to select a recipient of an email then the email is sent.
If I leave it without the input type hidden it shows on the form I only want the link to appear in the email that is sent. Currently my email is showing everything else I want but this last input only shows upto <a href=
Cheers
davegmpd
Forum Newbie
Posts: 14
Joined: Tue Oct 27, 2009 9:42 am
Location: London

Re: adding a hyperlink to a hidden form input

Post by davegmpd »

Sounds like you're going about it the wrong way!

Where's the code that actuall sends the email?

You don't need to have the link on the form to have it be part of the email that gets sent, basically.

Dave
ardan16
Forum Commoner
Posts: 32
Joined: Fri Aug 01, 2008 6:07 am

Re: adding a hyperlink to a hidden form input

Post by ardan16 »

Hi Dave this is the email part.

Code: Select all

<?php
   if ($_SERVER['REQUEST_METHOD']=="POST"){
      // In testing, if you get an Bad referer error
      // comment out or remove the next three lines
     // if (strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])>7 ||
       //  !strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']))
        // die("Bad referer");
// I ADDED BELOW THIS ######################################### 
    $email2 = stripslashes($_POST["email2"]);
if (!empty($email2)) {
exit();
}
 
// TO HERE #####################################################      
      $msg="Your attention is required for the following Incident Report:\n";
      //if((isset($_POST['value']) && (trim($_POST['value']) != ''))
      foreach($_POST as $key => $val){
         //if(trim($val) != ''){
        if(trim($val) != ''){///////////////////////////////////////////////////////
        if (is_array($val)){
            $msg.="Item: $key\n";
            foreach($val as $v){
               $v = stripslashes($v);
               $msg.="   $v\n";
            }
            
         } else {
            $val = stripslashes($val);
            $msg.="$key: $val\n";
         }
      }
      }
      
      $recipient== ($_POST['recipient']);
      $subject="Incident report requires your attention!";
      error_reporting(0);
      if (mail($recipient, $subject, $msg)){
         echo "<p>Thank you<br/>Notification successfully sent:</p>\n";
         //echo nl2br($input);
      } else
         echo "An error occurred and the message could not be sent.";
   } else // echo "Bad request method";
 
?>
davegmpd
Forum Newbie
Posts: 14
Joined: Tue Oct 27, 2009 9:42 am
Location: London

Re: adding a hyperlink to a hidden form input

Post by davegmpd »

Why not just add in to the end of your message generation (line 33 ish):

Code: Select all

 
$msg .= "\n\nView this incident online:\nhttp://just4em.com/incident/view_reports.php";
 
or something similar.

You basically constructing an email message ($msg) from a bunch of submitted form elements. However you don't *only* have to include those elements. You can just add stuff in as you need to.

Dave
Post Reply