Postcard

Hi everyone, I was trying to do this postcard tutorial with php. But I’m not sure how to add a field where users can type in their names before sending it to someone. Here’s the script:

<?php

// CHANGE PARAMETERS HERE BEGIN
$columns = 5;
$senderName = ‘E-card’; // Eg.: John’s Postcards
$senderEmail = ‘Sender EMAIL here’; // Eg.: john@postcard.com
// Change only if you have problems with urls
$postcardURL = ‘http://’.$_SERVER[‘HTTP_HOST’].$_SERVER[‘SCRIPT_NAME’];
// CHANGE PARAMETERS HERE END

// This function displays the available images
function displayPhotos(){
global $columns;

$act = 0;
// Open the actual directory
if ($handle = opendir("thumbs")) {
    // Read all file from the actual directory
    while ($file = readdir($handle))  {
        if (!is_dir($file)) {
            if ($act == 0) echo "&lt;tr&gt;";
            echo "&lt;td align='center'&gt;&lt;img src='thumbs/$file' alt='postcard' /&gt;&lt;br/&gt;&lt;input type='radio' name='selimg' value='$file' /&gt;&lt;/td&gt;";
            $act++;
            if ($act == $columns){
                $act = 0;
                echo "&lt;/tr&gt;";
            }
          }
    }
    echo "&lt;/tr&gt;";
}    

}

?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “DTD/xhtml1-transitional.dtd”>
<html>
<head>
<title>Postcard</title>
<link href=“style/style.css” rel=“stylesheet” type=“text/css” />
</head>
<body>
<div id=“container”>

&lt;div id="content"&gt;
&lt;div id="caption"&gt;&lt;/div&gt;

&lt;?php if ( (!isset($_POST['submit'])) && (!isset($_GET['show'])) ) { ?&gt;
    &lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="post"&gt;
        &lt;table align="center"&gt;
               &lt;?php displayPhotos(); ?&gt;
        &lt;/table&gt;        
   &lt;h2&gt;Fill the form&lt;/h2&gt;    
        &lt;table width="100%"&gt;
          &lt;tr&gt;&lt;td&gt;Send to (email address):&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="email" size="30"/&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Message:&lt;/td&gt;&lt;td&gt;&lt;textarea name="message" rows="10" cols="40"&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td colspan="2" align="center"&gt;&lt;input type="submit" value="Send card!" name="submit"/&gt;&lt;/td&gt;&lt;/tr&gt;
        &lt;/table&gt;
   &lt;/form&gt; 
   &lt;?php } else if ( (isset($_POST['submit'])) && (!isset($_GET['show'])) ) { 
        $pic = isset ($_POST['selimg']) ? $_POST['selimg'] : '';
        $filename = date('YmdGis');
        $f = fopen('messages/'.$filename.".txt","w+");         
        fwrite($f,$pic."

“);
fwrite($f,$_POST[‘email’].”
“);
fwrite($f,htmlspecialchars($_POST[‘message’]).”
");
fclose($f);

        // Compose the mail
            $from   = "From: $senderName &lt;$senderEmail&gt;

";
$replay = "Reply-To: $senderEmail
";
$params = "MIME-Version: 1.0
";
$params .= "Content-type: text/plain; charset=iso-8859-1
";
$mailtext = "You have just received an E-card!

"
. “You can pick up your e-card at the following web address:
"
. “$postcardURL”.”?show=$filename

"
. "We hope you enjoy your postcard, and if you do, please take a moment to send a few yourself!

"
. "Regards,
"
. "takeitbackin08.com
"
. $postcardURL;

        // Send email          
          @mail($_POST['email'],"You've received a postcard",$mailtext,$from.$replay.$params);

?>

    &lt;center&gt;
      Your postcard was sent!&lt;br/&gt;&lt;br/&gt;
      &lt;img src='images/&lt;?php echo $pic; ?&gt;' alt="postcard" /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;?php echo nl2br(htmlspecialchars($_POST['message'])); ?&gt;&lt;/center&gt;            
   &lt;?php } else if ( (!isset($_POST['submit'])) && (isset($_GET['show'])) ) { 
$file = isset($_GET['show']) ?  $_GET['show'] : ''          ;
$content = file('messages/'.$file.".txt");
$pic   = $content['0'];
unset ($content['0']);
unset ($content['1']);
$main = "";
foreach ($content as $value) {
    $main .= $value;
}

?>
<center>
Your postcard!<br/><br/>
<img src=‘images/<?php echo $pic; ?>’ alt=“postcard” /><br/><br/><br/><?php echo nl2br(htmlspecialchars($main)); ?></center>

<?php } ?>
<div id=“source”></div>
</div></div>
</body>