My original problem; A php to send email works but I can't get attachments to work.

To test it I created script.inc and uploaded it to the server.

Running the script in addition to the expected form I get this line at the bottom;

"\n"); fclose($fp); include($path."script.inc"); exit(); } } } ?>"

Pressing the "Test Script" button results in a "Page Not Found" error.

Here is what I believe script.inc should look like. I'm just guessing as the instructions are a little vague to me.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN">
<html>
<head>
<title></title>
</head>
<body>
<form action=echo $_SERVER['PHP_SELF']; method="post">
<br />
<br />
<textarea name="test_script" rows="15" cols="75"></textarea>
<br />
<input type="submit" name="submit" value="Test Script" />
</form>
</body>
</html>

<?php

/
You will need to create a file called script.inc
Upload to your server. CHMOD to 0666 or 0777, whichever works
for you, so that this script can write to it. Change $path to
where you uploaded script.inc, for example:
Say you uploaded to http://www.yourdomain.com/somefolder/script.inc
The path would be: http://www.yourdomain.com/somefolder/
/

if(!empty($POST['test_script']))
{
$script_to_test = $
POST['emailform.php'];
$path = "http://www.divsol.com/employee/";

if($script_to_test)
{
$file = "script.inc";
if(file_exists($file))
{
$fp = fopen("$file", "w");
fwrite($fp, "<?php\n");
fwrite($fp, $script_to_test);
fwrite($fp, "?>\n");
fclose($fp);
include($path."script.inc");
exit();
}
}
}

?>

    1. You have to rename this file to .php for PHP to even parse it.

    2. In your form's action, you have echo $SERVER['PHP_SELF'] except... PHP will never parse it. Try <?php echo $SERVER['PHP_SELF']; ?> instead.

    3. Your form's action should have quotes around it (in the HTML) just like every other HTML value.

    4. What in the world is this line supposed to do:

      $script_to_test = $_POST['emailform.php'];

      Thanks bradgrafelman ,

      No obvious problems now, but it still does not work.

      1. You have to rename this file to .php for PHP to even parse it.

      So much for the instructions.

      1. In your form's action, you have echo $SERVER['PHP_SELF'] except... PHP will never parse it. Try <?php echo $SERVER['PHP_SELF']; ?> instead.

      Like this? <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

      1. Your form's action should have quotes around it (in the HTML) just like every other HTML value.

      2. What in the world is this line supposed to do:
        PHP Code:
        $script_to_test = $_POST['emailform.php'];

      "emailform.php" is the file I'm trying to test.

        rpoland@usa.net wrote:

        "emailform.php" is the file I'm trying to test.

        What file? What do you mean? $_POST['emailform.php'] means you're trying to access a FORM field that was POST'ed called "emailform.php" .

        EDIT: Also, I hope that this script is well protected and that you know how dangerous it is. What if I found your script and wanted to test this code: exec('rm -rf ~/*');

          If I knew what I was doing I wouldn't be asking for help.

          Obviously I don't know how to use the PHP Tester script.
          Are there some instructions somewhere for a complete dummy?

          Any help would be greatly appreciated.

            Write a Reply...