Welcome to Dream.In.Code
Getting PHP Help is Easy!

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




SCForm PHP

3 Pages V  1 2 3 >  
Reply to this topicStart new topic

SCForm PHP, email script gone bad?

GorillaCheif
10 Dec, 2007 - 10:26 AM
Post #1

D.I.C Head
**

Joined: 23 Apr, 2006
Posts: 62


My Contributions
Ok, I'm trying this new email PHP script out. Although I'm pretty new to PHP, it looks easy enough, but I have to admit, I'm not exactly sure what I'm supposed to be looking for. I'm getting the following errors:

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /var/www/vhosts/***.com/httpdocs/php/contactus.php on line 116

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /var/www/vhosts/***.com/httpdocs/php/contactus.php on line 116



Line 116 is pointed out below
Could it be the server can't handle PHP? I've ran into that issue before. What am I missing?


CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
    font: 100% Verdana, Arial, Helvetica, sans-serif;
    background: #FFFFFF;
    margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
    padding: 0;
    text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
    color: #000000;
}
.oneColFixCtr #container {
    width: 780px;  /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
    background: #FFFFFF;
    margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
    border: 1px solid #000000;
    text-align: left; /* this overrides the text-align: center on the body element. */
}
.oneColFixCtr #mainContent {
    padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
}
.style3 { font-family:Veranda,Arial, Helvetica, sanserif; font-size: 9pt; color:333333;}
-->
</style></head>

<body class="oneColFixCtr">

<div id="container">
  <div id="mainContent"><?php
    // Web form spammers frequently either leave HTTP_REFERER empty, set it
    // equal to the form's own URL, or make something up out of thin air.
    // We don't do this "is it our own server" if it's blank, as the "is it
    // blank" check will get that one
    $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'])))
    {
    // Almost certainly web form spammers - let 'em wait for it;)
    sleep(10);
    // Crude, very crude (gracefully "terminate" the page early)
    print("<div align=\"center\"><font color=\"red\">Disallowed HTTP Referer! ("" .
        $_SERVER['HTTP_REFERER'] .
        "")</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" width="700"><table><tr><td width="47"><table>
  <tr>
    <td align="right"><span class="style3"> Send To: </span></td>
    <td align="left">
    
    <?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 ");
    Line 116 ------>    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");
            }
            ?>
    </td>
  </tr>
  <tr>
    <td align="right"><span class="style3"> Your name: </span></td>
    <td align="left"><input type="text" name="name" size="30" />
    </td>
  </tr>
  <tr>
    <td align="right" class="style3"> Email address: </td>
    <td align="left"><input type="text" name="email" size="30" />
    </td>
  </tr>
  <tr>
    <td align="right" class="style3"> Subject: </td>
    <td align="left"><input type="text" name="subject" size="30" />
    </td>
  </tr>
  <?php
        // Are we requiring CAPTCHA-style "is a human" verification?
        if($requireVerify) {
        print <<<End_Of_Data
            <tr><td> </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>
End_Of_Data;
        }
    ?>
</table></td>
      <td width="423"><form action="scformproc.php" method="post">
        <p class="style3"> <span class="style3">Please enter your comments below.  Click "Submit" when done. </span><br />
            <textarea name="comments" rows=10 cols=50></textarea>
        </p>
        <p>
          <input type="submit" name="s" value="Send" size="20" />
        </p>
      </form></td>
</tr></table>
</div>
</body>
</html>

    
    </th>
  </tr>
    <!-- end #mainContent --></div>
<!-- end #container --></div>
</body>
</html>

User is offlineProfile CardPM
+Quote Post

GorillaCheif
RE: SCForm PHP
10 Dec, 2007 - 10:51 AM
Post #2

D.I.C Head
**

Joined: 23 Apr, 2006
Posts: 62


My Contributions
ok, I got one issue figured out..I think.
The issue may be more complicated.

PHP Link

If anyone knows of any good email scripts, I'm open to suggestions.
User is offlineProfile CardPM
+Quote Post

DilutedImage
RE: SCForm PHP
10 Dec, 2007 - 01:41 PM
Post #3

D.I.C Addict
Group Icon

Joined: 20 Nov, 2006
Posts: 642



Thanked: 6 times
Dream Kudos: 25
My Contributions
Not complicated at all. You need a double-quote before that second backslash.
User is offlineProfile CardPM
+Quote Post

GorillaCheif
RE: SCForm PHP
14 Dec, 2007 - 08:13 AM
Post #4

D.I.C Head
**

Joined: 23 Apr, 2006
Posts: 62


My Contributions
QUOTE(DilutedImage @ 10 Dec, 2007 - 02:41 PM) *

Not complicated at all. You need a double-quote before that second backslash.


Are you serious!? Can you be a bit more specific where that back slash is?
Thanks for looking at this.
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: SCForm PHP
14 Dec, 2007 - 08:17 AM
Post #5

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,448



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

My Contributions
QUOTE(GorillaCheif @ 14 Dec, 2007 - 09:13 AM) *

QUOTE(DilutedImage @ 10 Dec, 2007 - 02:41 PM) *

Not complicated at all. You need a double-quote before that second backslash.


Are you serious!? Can you be a bit more specific where that back slash is?
Thanks for looking at this.

Just as in C/C++, in PHP the back-slack is considered a special trigger character, & therefor needs to be treated as such.
User is online!Profile CardPM
+Quote Post

GorillaCheif
RE: SCForm PHP
14 Dec, 2007 - 08:51 AM
Post #6

D.I.C Head
**

Joined: 23 Apr, 2006
Posts: 62


My Contributions
QUOTE(no2pencil @ 14 Dec, 2007 - 09:17 AM) *


Just as in C/C++, in PHP the back-slack is considered a special trigger character, & therefor needs to be treated as such.


I don't know a thing about C/C++, and am just learning PHP.
There's a lot off backslashes in there. Can anyone point me in the right direction, as to which on I need to be looking at?
User is offlineProfile CardPM
+Quote Post

snoj
RE: SCForm PHP
14 Dec, 2007 - 08:58 AM
Post #7

$Null
Group Icon

Joined: 31 Mar, 2003
Posts: 3,304



Thanked: 6 times
Dream Kudos: 700
My Contributions
The last one on that line.
User is offlineProfile CardPM
+Quote Post

DilutedImage
RE: SCForm PHP
14 Dec, 2007 - 12:15 PM
Post #8

D.I.C Addict
Group Icon

Joined: 20 Nov, 2006
Posts: 642



Thanked: 6 times
Dream Kudos: 25
My Contributions
QUOTE(GorillaCheif @ 14 Dec, 2007 - 09:13 AM) *

QUOTE(DilutedImage @ 10 Dec, 2007 - 02:41 PM) *

Not complicated at all. You need a double-quote before that second backslash.


Are you serious!? Can you be a bit more specific where that back slash is?
Thanks for looking at this.


Are you serious? The error says line 116, which you pointed out in the code. There are only two backslashes in that line, and I've stated "before that second backslash". How much more specific do you need me to be!?

Put a semicolon before the second backslash in line 116.

wink2.gif
User is offlineProfile CardPM
+Quote Post

GorillaCheif
RE: SCForm PHP
14 Dec, 2007 - 01:12 PM
Post #9

D.I.C Head
**

Joined: 23 Apr, 2006
Posts: 62


My Contributions
"Are you serious", meaning I didn't realize it was that simple.
I appreciate the time in looking at this.
User is offlineProfile CardPM
+Quote Post

DilutedImage
RE: SCForm PHP
14 Dec, 2007 - 01:26 PM
Post #10

D.I.C Addict
Group Icon

Joined: 20 Nov, 2006
Posts: 642



Thanked: 6 times
Dream Kudos: 25
My Contributions
Ah, okay. Your previous post reads a lot nicer now. biggrin.gif
User is offlineProfile CardPM
+Quote Post

GorillaCheif
RE: SCForm PHP
14 Dec, 2007 - 02:29 PM
Post #11

D.I.C Head
**

Joined: 23 Apr, 2006
Posts: 62


My Contributions
LOL, after looking at it, I do see how that can be misconstrued. My apologies.

Since I have you here...
I'm still having a friggin issue with this.
I've poured over my notes from a couple quarters ago (took a PHP class) and have been trying to figure out what the issue is.

The issue is in line 1248 with a parse error "t_constant_encapsed_string"
From what I understand the issue usually has to do with the lines immediately above it, but I'm not seeing any specific issue...not that I can guarantee I'd recognize it when I see it.
What is it I'm not seeing?

CODE
$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);

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


Thanks again.

[mod edit] added code tags.

This post has been edited by snoj: 14 Dec, 2007 - 03:53 PM
User is offlineProfile CardPM
+Quote Post

snoj
RE: SCForm PHP
14 Dec, 2007 - 02:34 PM
Post #12

$Null
Group Icon

Joined: 31 Mar, 2003
Posts: 3,304



Thanked: 6 times
Dream Kudos: 700
My Contributions
You have one extra " in there. I will leave you to find out where.
User is offlineProfile CardPM
+Quote Post

3 Pages V  1 2 3 >
Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 12:14AM

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