logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 12-14-2011, 04:02 AM   #1
BullDog
 
Join Date: Nov 2011
Location: Alameda, CA
Posts: 156
Default contact form error

I had this working earlier today. all I've done is move it to the root directory. www.bugorama.com check out the contact page to see the parse error. I did not create the contact form so I am a bit lost as to where the error is coming from.
BullDog is offline   Reply With Quote
Old 12-14-2011, 04:43 AM   #2
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

post the code so i can see it please
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 12-14-2011, 04:58 AM   #3
BullDog
 
Join Date: Nov 2011
Location: Alameda, CA
Posts: 156
Default

contact.php
Code:
<?php
/**
 * No errors in form initially
 */
require_once 'is_email.php';
$error    = array(
    'name' => 0,
    'email' => 0,
    'category' => 0,
    'message' => 0
);
$errorFlag    = 0;

if( isset( $_POST[ 'email' ] ) ) {
    function clean_string( $string ) {
        $bad = array( "content-type", "bcc:", "to:", "cc:", "href" );
        return trim( str_replace( $bad, "", $string ) );
    }

    $category    = clean_string( $_POST['category'] );
    $name        = clean_string( $_POST['name'] );
    $email        = clean_string( $_POST['email'] );
    $message    = clean_string( $_POST['message'] );
    $phone        = clean_string( $_POST['phone'] );
    $subject    = clean_string( $_POST['subject'] );

    if( !$category ) {
        $error[ 'category' ]    = 1;
        $errorFlag    = 1;
    }

    if( !isset( $message ) || strlen( $message ) < 2 ) {
        $error[ 'message' ]    = 1;
        $errorFlag    = 1;
    }

    $string_exp = "    /^[A-Za-z.'-]+$/";
    //if( !isset( $name ) || !preg_match( $string_exp, $name ) ) {
    // if( !isset( $name ) ) {
        
    if( !isset( $name ) || strlen( $name ) < 1 ) {
        
        $error[ 'name' ]    = 1;
        $errorFlag    = 1;
    }

    $email_exp = '/^[A-Za-z0-9\._%-]+@[A-Za-z0-9\.-]+\.+[A-Za-z] (2,4)$/';
    //if( !isset( $email ) || !preg_match( $email_exp, $email ) ) {
    if( !isset( $email ) || !is_email( $email ) ) {
        $error[ 'email' ]    = 1;
        $errorFlag    = 1;
    }

    // no errors in form, continue sending the mail..
    if( ! $errorFlag ) {
        // determine the mail recipient
        switch ( $category ) {
            case 'will@bugorama.com':
                $email_to    = 'will@bugorama.com';
                break;
            case 'mike@bugorama.com':
                $email_to    = 'mike@bugorama.com';
                break;
            case 'info@bugorama.com':
                $email_to    = 'info@bugorama.com';
                break;
            default:
                $email_to    = 'info@bugorama.com';
        }

        // Here is the email to information
        $email_subject = "From Website 2012 Contact Form - " . $name;
        $email_from = "Bugorama Promotions 2012";

        $email_message .= "Name: " . $name . "\r\n";
        $email_message .= "Email: " . $email . "\r\n";
        $email_message .= "Phone: " . $phone . "\r\n";
        $email_message .= "Subject: " . wordwrap( $subject, 70 ) . "\r\n";
        $email_message .= "Message:" . wordwrap( $message, 70 ) . "\r\n";

        //    Create email headers
        $headers = 'From: ' .$email_from . "\r\n" . 'Reply-To:' . $email . "\r\n" . 'X-Mailer: PHP/' . phpversion();
        @mail( $email_to, $email_subject, $email_message, $headers );

        //@mail( $email, $email_subject, $email_message, $headers );

        //header( 'Location: send_form.php' );
        echo '<form action="send_form.php" method="post" name="sdset" id="sdset"><input type="hidden" name="category" id="category" value="'.$category.'" /><input type="hidden" name="name" value="'.$name.'" /><input type="hidden" name="email" id="email" value="'.$email.'" /><input type="hidden" name="message" value="'.$message.'" /><input type="hidden" name="phone" id="phone" value="'.$phone.'" /><input type="hidden" name="subject" value="'.$subject.'" /><input type="submit" value="Continue" style="height: 1px; width: 1px; display: none;" /><script type="text/javascript">document.sdset.submit();</script></form>';
    }
}
?>
<!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" />

<meta name="robots" content="noindex" />

<style type="text/css">

*{ margin:0; padding:0;}
body{ font:100% normal Arial, Helvetica, sans-serif; }
form,input,select,textarea{margin:0; padding:0; color:#000000;}

/* contact form title box */
div.box {
margin:0 auto;
width:500px;
background:#b40610;
position:relative;
top:50px;
border:2px solid #b40610;
}

/* contact form box */
div.box h1 {
color:#ffffff;
font-size:18px;
text-transform:uppercase;
padding:5px 0 5px 5px;
}

div.box div {
width:100%;
display: block;
background:#ffffff;
padding:10px 0 10px 0;
}

div.box div span {
display: block;
color:#000000;
font-size:12px;
Font-weight: bold;
float:left;
width:110px;
text-align:right;
padding:5px 20px 0 0;
}

div.box .input_text {
padding:10px 10px;
width:300px;
background:#e1e1e1;
border: 1px solid #000000;
}

div.box .message{
padding:7px 7px;
width:330px;
background:#e1e1e1;
border: 1px solid #000000;
height:250px;
}

div.box .button
{
position: relative;
left:400px;
}
.errValid {
color: #FF0000;
}
.errMsg {
padding: 0px 0px 5px 130px;
background-color: #FFF;
font-size: 11px;
}
</style>

<title>Bugorama Promotions - CONTACT US</title>
<link href="css/default.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryCollapsiblePanel.js" type="text/javascript"></script>
<link href="SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> 

<!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"></script> -->
<script src="jquery.min.js" type="text/javascript"></script>
<script src="jquery.Scroller-1.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
$(document).ready(function() {

    //create scroller for each element with "horizontal_scroller" class...
    $('.horizontal_scroller').SetScroller({    velocity:      40,
                                            direction:      'horizontal',
                                            startfrom:      'right',
                                            loop:         'infinite',
                                            movetype:      'linear',
                                            onmouseover: 'pause',
                                            onmouseout:  'play',
                                            onstartup:      'play',
                                            cursor:      'pointer'
                                        });
    /*
        All possible values for options...

        velocity:         from 1 to 99                                 [default is 50]
        direction:         'horizontal' or 'vertical'                     [default is 'horizontal']
        startfrom:         'left' or 'right' for horizontal direction     [default is 'right']
                        'top' or 'bottom' for vertical direction    [default is 'bottom']
        loop:            from 1 to n+, or set 'infinite'                [default is 'infinite']
        movetype:        'linear' or 'pingpong'                        [default is 'linear']
        onmouseover:    'play' or 'pause'                            [default is 'pause']
        onmouseout:        'play' or 'pause'                            [default is 'play']
        onstartup:         'play' or 'pause'                            [default is 'play']
        cursor:         'pointer' or any other CSS style            [default is 'pointer']
    */

    //how to overwrite options after setup and without deleting the other settings...
    $('#no_mouse_events').ResetScroller({    onmouseover: 'play', onmouseout: 'play'   });
    $('#scrollercontrol').ResetScroller({    velocity: 85, startfrom: 'left'   });

    //if you need to remove the scrolling animation, uncomment the following line...
    //$('#scrollercontrol').RemoveScroller();

});
//-->
</script>

</head>

<body>

<div class="container">

<?php include_once("_top.php");?>

  <div class="clearfloat"></div> <!-- clear floats -->

<?php include_once("_side.php");?>

  <div class="content">

    <div class="title">
    <img src="graphics/titles/contact.jpg" width="600" height="91" alt="Contact Us" />
    </div> <!-- end title div -->

 
  <div style="width: 500px; margin: 20px auto 0px auto;">
  <strong>Mailing Address:</strong><br />
  P.O. Box 60873<br />
  Sacramento,CA 95860<br />
  <strong>Phone:</strong><br />
  1-800-929-0077<br />
  </div>
  

  <form name="contactform" method="post" action="<?php echo $_SERVER[ 'PHP_SELF' ];?>">
    <div class="box">

        <h1>Contact Form :</h1>
            <div>
                <span>&nbsp;</span>
                <p class="errValid">* marked fields are required</p>
            </div>
            <div>
                <span>Category<font color="red"> *</font></span>
                  <select name="category" id="category">
                <option value="0">Required Selection</option>
                <option value="will@bugorama.com" <?php if(isset($_POST['category'])&&($_POST['category']=='will@bugorama.com')){echo 'selected="selected"';}?>>New Parts Vendor</option>
                <option value="mike@bugorama.com" <?php if(isset($_POST['category'])&&($_POST['category']=='mike@bugorama.com')){echo 'selected="selected"';}?>>Sponsorship</option>
                <option value="info@bugorama.com" <?php if(isset($_POST['category'])&&($_POST['category']=='info@bugorama.com')){echo 'selected="selected"';}?>>Other</option>
                </select>
                <?php
                if( $error[ 'category' ] ) {
                ?>
                <p class="errValid errMsg">Please select a category.</p>
                <?php
                }
                ?>
            </div>

            <div>
                <span>Full Name<font color="red"> *</font></span>
                <input type="text" class="input_text" name="name" id="name" value="<?php if(isset($_POST['name'])){echo $_POST['name'];};?>" />
                <?php
                if( $error[ 'name' ] ) {
                ?>
                <p class="errValid errMsg">Please enter your full name.</p>
                <?php
                }
                ?>
            </div>

            <div>
                <span>Email<font color="red"> *</font></span>
                <input type="text" class="input_text" name="email" id="email" value="<?php if(isset($_POST['email'])){echo $_POST['email'];};?>" />
                <?php
                if( $error[ 'email' ] ) {
                ?>
                <p class="errValid errMsg">Please enter your email address.</p>
                <?php
                }
                ?>
            </div>

            <div>
                <span>Phone</span>
                <input type="text" class="input_text" name="phone" id="phone" value="<?php if(isset($_POST['phone'])){echo $_POST['phone'];};?>" />
            </div>

            <div>
                <span>Subject</span>
                <input type="text" class="input_text" name="subject" id="subject" value="<?php if(isset($_POST['subject'])){echo $_POST['subject'];};?>" />
            </div>

            <div>
                <span>Message<font color="red"> *</font></span>
                <textarea name="message" id="message" class="message" rows="5" cols="50"><?php if(isset($_POST['message'])){echo $_POST['message'];};?></textarea>
                <?php
                if( $error[ 'message' ] ) {
                ?>
                <p class="errValid errMsg">Please enter your message.</p>
                <?php
                }
                ?>
            </div>

            <div>
                <input type="submit" value="submit" style="color: #b40610;" class="button" />
            </div>
    </div>

</form>

  </div> <!-- end content div -->

<?php include_once("_bottom.php");?>

<div class="clearfloat"></div> <!-- clear floats -->

</div> <!-- end container div -->

<?php include_once("_end.php");?>

<p>&nbsp;</p>
<script type="text/javascript">
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});
var CollapsiblePanel2 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel2", {contentIsOpen:false});
var CollapsiblePanel3 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel3", {contentIsOpen:false});
var CollapsiblePanel4 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel4", {contentIsOpen:false});
var CollapsiblePanel5 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel5", {contentIsOpen:false});
var CollapsiblePanel6 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel6", {contentIsOpen:false});
</script>
</body>
</html>
default.css
Code:
@charset "UTF-8";
/* CSS Document */

/* ~~ Element/tag selectors ~~ */
ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
    padding: 0;
    margin: 0;
}

a {
   outline: 0;
}

a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
    border: none;
}

/* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
a:link {
    color: #b40610;
    text-decoration: none; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
}

.hiddenPic {display: none;}

a:link {color:#B40610; text-decoration:none;}      /* unvisited link */
a:visited {color:#B40610; text-decoration:none;}  /* visited link */
a:hover {color:#B40610; text-decoration:underline;}  /* mouse over link */
    
a.specialLink:link { color: #ffea00; text-decoration:none; font-size: small }
a.specialLink:visited { color: #ffea00; text-decoration:none; }
a.specialLink:hover { color: #ffea00; text-decoration:underline; }
    
a.designedBy:link { color: #999999; text-decoration:none; }
a.designedBy:visited { color: #999999; text-decoration:none; }
a.designedBy:hover { color: #999999; text-decoration:underline; }
div:active, div:focus, div:hover {outline-style: none; -moz-outline-style:none;} 

a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
    text-decoration: underline;
}

body {
    /* background-attachment: fixed; */
    /* background-image:url(../graphics/backchainlink.jpg); */
    
    background-image:url(../graphics/black-red-white-bg.jpg);
    background-repeat: repeat-x;
    
    margin: 0;
    padding: 0;
    color: #000;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 100%;
    line-height: 1.4;
    background-color: #ffffff;
}

/* ~~this fixed width container surrounds the other divs~~ */
.container {
    width: 960px;
    background: #f1f1f1;
    border: 2px solid #000000;
    margin: 20px auto 0px; /* the auto value on the sides, coupled with the width, centers the layout */
}

.divcenter{
    text-align: center;
}

.header {
    background: #ffffff;
}

/* CSS for the scrollers */
    div.horizontal_scroller {
        position:relative;
        height:24px;
        width:960px;
        display:block;
        overflow:hidden;
        
    }
    div.scrollingtext{
        position:absolute;
        white-space:nowrap;
        font-family:'Trebuchet MS',Arial;
        font-size:16px;
        color:#000000;
    }

.navbar {
    width: 960px;
    height: 49px;
    background-color: #ffffff;
    background-repeat: no-repeat;
}

.navbar ul {
    list-style-type: none;
}

/* default nav */

#nav {
    width: 960px;
    height: 49px;
    position: relative;
    background: url(../graphics/nav_main.png);
    margin: 0px;
    padding: 0px;
}

#nav li {
    float: left;
}

#nav li a {
    position: absolute;
    top: 0;
    margin: 0;
    padding: 0;
    display: block;
    height: 49px;
    background: url(../graphics/nav_main.png) no-repeat;
    text-indent: -9999px;
    overflow: hidden;
}

/* up nav */

li#nav_home a {
    left: 0;
    width: 108px;
    background-position: 0 0;
}

li#nav_about a {
    left: 108px;
    width: 111px;
    background-position: -108px 0;
}

li#nav_events a {
    left: 219px;
    width: 140px;
    background-position: -219px 0;
}

li#nav_sponsors a {
    left: 339px;
    width: 143px;
    background-position: -339px 0;
}

li#nav_vendor a {
    left: 482px;
    width: 174px;
    background-position: -482px 0;
}

li#nav_drag a {
    left: 656px;
    width: 178px;
    background-position: -656px 0;
}

li#nav_contact a {
    left: 834px;
    width: 126px;
    background-position: -834px 0;
}

/* over nav */

li#nav_home a:hover {
    background-position: 0 -49px;
}

li#nav_about a:hover {
    background-position: -108px -49px;
}

li#nav_events a:hover {
    background-position: -219px -49px;
}

li#nav_sponsors a:hover {
    background-position: -339px -49px;
}

li#nav_vendor a:hover {
    background-position: -482px -49px;
}

li#nav_drag a:hover {
    background-position: -656px -49px;
}

li#nav_contact a:hover {
    background-position: -834px -49px;
}

.sidebar1 {
    float: left;
    width: 230px;
    background: #f1f1f1;
    padding-bottom: 10px;
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 30px;
}

.content {
    padding: 10px 10px;
    width: 690px;
    float: left;
}

.main_sponsors {
    width: 690px;
    height: 400px;
}

.small_sponsors {
    width: 690px;
    height: 400px;
}

.sponsors {
    width: 690px;
}


.sponsor_left {
    width: 344px;
    float: left;
}

.sponsor_right {
    width: 344px;
    float: right;
}

.title {    
    width: 690px;
    padding-bottom: 20px;
}

/* index divs flyer & videos */
#leftcolumn { 
    width: 420px; 
    float:left;
}
#rightcolumn { 
    width: 270px; 
    float: right; 
}
    
iframe {
    margin-bottom: 20px;
}

.bigvideo {
    padding-top: 20px;
}

.bottomnav{
    width: 960px;
}

.bottomcol {
    float: left;
    width: 210px;
    padding: 15px;
    vertical-align: top;
}

/* ~~ The footer ~~ */
.footer {
    padding: 10px 0px 0px 10px;
    position: relative;/* this gives IE6 hasLayout to properly clear */
    clear: both; /* this clear property forces the .container to understand where the columns end and contain them */
}

/* ~~ miscellaneous float/clear classes ~~ */
.fltrt {  /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
    float: right;
}

.fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
    float: left;
}

.clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the #footer is removed or taken out of the #container */
    clear:both;
    height: 0px;
    font-size: 1px;
    line-height: 0px;
}
BullDog is offline   Reply With Quote
Old 12-14-2011, 05:02 AM   #4
BullDog
 
Join Date: Nov 2011
Location: Alameda, CA
Posts: 156
Default

is_email.php

too big to post

Last edited by BullDog; 09-05-2015 at 05:30 AM..
BullDog is offline   Reply With Quote
Old 12-14-2011, 05:27 AM   #5
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

yeesh!! lot to dredge through. can you try this as a de bug, is_email line 183

Code:
function is_email($email, $checkDNS = false, $errorlevel = false, &$parsedata = array()) {
try

Code:
function is_email($email, $checkDNS = false) {
just to see if error persists
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 12-14-2011, 05:39 AM   #6
BullDog
 
Join Date: Nov 2011
Location: Alameda, CA
Posts: 156
Default

I will try in a few... I got a hold of the guy that did the form for me via vworker.com

here is what he used to validate email:

http://code.google.com/p/isemail/sou..._email.php?r=6

weird because it worked and validated before and now neither work.

Last edited by BullDog; 12-14-2011 at 05:43 AM..
BullDog is offline   Reply With Quote
Old 12-14-2011, 06:03 AM   #7
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

i also now saw
require_once 'is_email.php';
did you change this from?
require_once ('is_email.php');
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 12-14-2011, 06:24 AM   #8
BullDog
 
Join Date: Nov 2011
Location: Alameda, CA
Posts: 156
Default

he made the changes and my ftp access is down so I cant compare but he updated the function you mentioned and listed on the open source page I posted.

The form and validation is still over my head and hate that I cant figure it out. now I cant even get in to look at the changes he made. he made the changes and had me try it then neither of us could get back in. it displays, sends, and validates. but will have to test with the client to see if he is getting the emails correctly.
BullDog is offline   Reply With Quote
Old 12-14-2011, 06:33 AM   #9
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

its a pretty heavy duty script, i think its the validation thts throwing a wobbly , all links seem ok other than what i mentioned,
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 12-14-2011, 06:35 AM   #10
BullDog
 
Join Date: Nov 2011
Location: Alameda, CA
Posts: 156
Default

way over my head and maybe too much as there is a noticeable delay even when submitting the email.

All I wanted to do was validate it was a valid email. I see more straight forward methods but this is what he uses for all his forms. I may be asking for some direction soon as I have another site to do for the same person.

Last edited by BullDog; 12-14-2011 at 06:42 AM..
BullDog is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:30 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com