Welcome to Dream.In.Code
Become a PHP Expert!

Join 137,426 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,916 people online right now. Registration is fast and FREE... Join Now!




Formmail.php

 
Reply to this topicStart new topic

Formmail.php, Grrrr,

GorillaCheif
11 Jan, 2008 - 10:12 AM
Post #1

D.I.C Head
**

Joined: 23 Apr, 2006
Posts: 62


My Contributions
Alright, I'm going to learn this stuff if it kills me....and it just might.
I've gone over this, and over this, to no avail. I don't see what the problem is.
The links are right, the script doesn't seem to have anything wrong...then again, I'm not totally sure I'd recognize a major mess if I saw it.

The scenario:
The form works fine, but when you hit "send" ou get the following error:

Warning: require(/php/scfconfig.php) [function.require]: failed to open stream: No such file or directory in /home/rodstolc/public_html/php/scformproc.php on line 52
Fatal error: require() [function.require]: Failed opening required '/php/scfconfig.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/rodstolc/public_html/php/scformproc.php on line 52


What I'm not getting is, the files are there, the links are correct, why aren't they being seen?
As for line 52, here is the code, starting at line 52

CODE
<?php

    $selfChkStr = $_SERVER['PHP_SELF'];
    $serverChkStr = "http://" . $_SERVER['SERVER_NAME'];
    if(($chkFormRefNotBlank && !$_SERVER['HTTP_REFERER']) ||
       ($chkFormRefNotSelf && preg_match("#$selfChkStr$#i", $_SERVER['HTTP_REFERER'])) ||
       ($chkFormRefOwnServer && $_SERVER['HTTP_REFERER'] &&
        !preg_match("#^$serverChkStr#i", $_SERVER['HTTP_REFERER'])))
    {
    sleep(10);

    print("<div align=\"center\"><font color=\"red\">Disallowed HTTP Referer! (&quot;" .
        $_SERVER['HTTP_REFERER'] .
        "&quot;)</font></div>");
    print("</body></html>");
    exit;
    }

    if($requireVerify)
    print("<div align=\"center\"><font color=\"red\">Cookies must be enabled to use this form.</font></div><p />");
?>
<div align="center"><table width="674" ><tr><td>
<form action="scformproc.php" method="get">
    <table align="center">
    <tr>
        <td align="right" class="style1">
        Send To:        </td>
        <td align="left" class="style1">
            <span class="style3">
            <?php
            // Get a pseudo-random alpha-numeric string (no zeros and O's)
            function pseudo_random_string($length) {
                $string = "";
                while($length--) {
                for($indx = rand(49, 90);
                    ($indx > 57 && $indx < 65) || $indx == 79;
                    $indx = rand(49, 90))
                   ;
                $string .= chr($indx);
                }

                return($string);
            }

            // Read a line from a config file, stripping comments
            // and blank lines
            function read_file_line($fp) {
                while(($inString = fgets($fp, 2048)) != false) {
                $inString = rtrim(preg_replace('/\s*#.*/', '',
                    $inString));
                if(!empty($inString))
                    break;
                }

                return $inString;
            }

            if(!$HTTP_SESSION_VARS['majik_string'])
                $HTTP_SESSION_VARS['majik_string'] = pseudo_random_string(5);

            // Read the contact list keys and descriptions into hash
            if(($fp = fopen($recipientFile, "r")) == false) {
                 die("Can't open data file '$recipientFile'.\n");
            }
            while($inString = read_file_line($fp)) {
                list($key, $description, $value) =
                explode(':', $inString);
                $options[$key] = $description;
            }
            fclose($fp);

            // If we've more than one choice: present a menu
            if(count($options) > 1) {
                // If we were given a single arg, that'll be the
                // selected menu item.
                if(count($_GET) == 1)
                $selected = strtolower(key($_GET));
                print("<select name=\"whoto\">\n");
                foreach($options as $key => $description) {
                print("<option ");
                if(strtolower($key) == $selected)
                    print("selected ");
                print("value=\"" . trim($key) .  "\">" .
                       trim($description) . "\n");
                }
                print("</select>\n");
            } else {
                // There'll be only one...
                foreach($options as $key => $description) {
                print("<input type=\"hidden\" name=\"whoto\" value=\"" .
                       trim($key) . "\">" . trim($description) . "\n");
                }
            }

            // Used by the form processor acknowledgment to create a
            // "take me back" link.
            if(!empty($_SERVER['HTTP_REFERER'])) {
                print("<input type=\"hidden\" name=\"orig_referer\" value=\"" .
                   $_SERVER['HTTP_REFERER'] . "\">\n");
            }
            ?>        
            </span></td>
    </tr>
    <tr>
        <td align="right" class="style1">
        Your name:        </td>
        <td align="left" class="style1">
          <span class="style3">
          <input type="text" name="name" size=30>        
          </span></td>
    </tr>
    <tr>
        <td align="right" class="style1">
        Email address:        </td>
        <td align="left" class="style1">
          <span class="style3">
          <input type="text" name="email" size=30>        
          </span></td>
    </tr>
    <tr>
        <td align="right" class="style1">
        Subject:        </td>
        <td align="left" class="style1">
          <span class="style3">
          <input type="text" name="subject" size=30>        
          </span></td>
    </tr>
    <?php
        // Are we requiring CAPTCHA-style "is a human" verification?
        if($requireVerify) {
        print <<<End_Of_Data
            <tr><td>&nbsp;</td></tr>
            <tr>
            <td colspan="2">
                Please enter the verification string on the right into the box on the left.
            </td>
            </tr>
            <tr>
            <td align="right">
                Verification:
            </td>
            <td align="left">
                <input type="text" name="verify" size=10>
                <img src="scfgenimg.php" width="60" height="20" align="top" alt="Verification string image"/>
            </td>
            </tr></span>
End_Of_Data;
        }
    ?>
    </table>
    <p class="style1">Please enter your comments below.  Click &quot;Submit&quot; when done. <br>
        <textarea name="comments" rows=5 cols=70></textarea>
        <input type="submit" name="s" value="Submit" />
    </p>
    <p>&nbsp;</p>
</form>


I know this will be something ridiculously dumb to fix, but I'm a wee bit lost.
Thanks in advance,

GC
User is offlineProfile CardPM
+Quote Post

ahmad_511
RE: Formmail.php
12 Jan, 2008 - 02:17 AM
Post #2

D.I.C Regular
Group Icon

Joined: 28 Apr, 2007
Posts: 351



Thanked: 8 times
Dream Kudos: 400
My Contributions
Hi there..
Did you upload this code in the same directory where (scformproc.php) file was upload?
User is offlineProfile CardPM
+Quote Post

GorillaCheif
RE: Formmail.php
17 Jan, 2008 - 02:17 PM
Post #3

D.I.C Head
**

Joined: 23 Apr, 2006
Posts: 62


My Contributions
QUOTE(ahmad_511 @ 12 Jan, 2008 - 04:17 AM) *

Hi there..
Did you upload this code in the same directory where (scformproc.php) file was upload?


Yes, I did.

User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Formmail.php
17 Jan, 2008 - 03:22 PM
Post #4

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,550



Thanked: 67 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
The warning is saying that it cannot open /php/scfconfig.php. Either make sure that the permissions are set correctly for the directory & file, or move it to somewhere that the PHP can open it & read it.
User is offlineProfile CardPM
+Quote Post

GorillaCheif
RE: Formmail.php
18 Jan, 2008 - 03:50 PM
Post #5

D.I.C Head
**

Joined: 23 Apr, 2006
Posts: 62


My Contributions
AHHA! there was a referrer in a different file that was point to a bad variable.

Thanks.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/5/08 04:44AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month