Results 1 to 2 of 2

Thread: Some processing script help

  1. #1
    Join Date
    Apr 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Some processing script help

    I got this script from this website

    http://www.4serendipity.com/form/

    and modified it to my needs, here is what I have...

    Code:
    <?
           
    
    //import form information 
    $Fname = $_POST['First Name'];
    $Lname = $_POST['Last Name'];
    $Email = $_POST['Email'];
    $Problem = $_POST['Problem'];
    $Other = $_POST['Other'];
    $Body = $_POST['Body'];
    $message=stripslashes($message);
    
    
    /*
    Simple form validation
    check to see if an email and message were entered
    */
    //if no message entered and no email entered print an error  
    if (empty($Body) && empty($Email)){
      print "No email address and no message was entered. <br>Please include an email and a message";
      }
       //if no message entered send print an error  
      elseif (empty($Body)){
      print "No message was entered.<br>Please include a message.<br>";
      }
      //if no email entered send print an error  
    elseif (empty($Email)){
      print "No email address was entered.<br>Please include your email. <br>";
      }
      //if no First and or Last name isn't entered, print an error
      elseif (empty($Fname) && empty($Lname)){
      print "No First name and or Last name was entered. <br>Please include your First and Last name";
      }
      //if the form has everything needed
      else {
    
    
    
    
    // print a response message
    
    
    //Thank the user by name if they entered a name
    if (!empty($Fname)) {
      print "<b>Thank you $Fname.</b><br>";
    }
    
    
    for ($i=0;$i<count($types);$i++){
      $ctypes=  $ctypes . "\n$types[$i]";
      $screen_ctypes=  $screen_ctypes . "\n$types[$i]";
    }
    
    print "<p><b>The following message has been sent</b>: <br>$Body<br></p><p><b>Comment type(s):</b><br>$screen_ctypes</p>";
    $body= $Body . " \n\nComment type(s)" . $ctypes;
    
    
    //mail the form contents
    mail( "contact@newlightpages.com", "Web site comments", $body, "From: $Email" );
    
    
    
      
      
      }
    
    
    
    
    ?>
    My problem exists when I try to send it with everything entered, it tells me the first and last name are not entered please enter one, and sometimes I get an error telling me that the email was not entered, I don't know why, can someone look at it and tell me why it's doing that?

    Also, the part in the script from the site..

    Code:
    $page = "http://ella.slis.indiana.edu/~PATH/TO/FORM";
    if (!ereg($page, $_SERVER['HTTP_REFERER'])){
    echo "Invalid referer"; 
    die;
    }
    I was not able to get working, even when I put in my site location and the location of the form, it kept returning as "Invalid referrer" so I had to just take that out.
    Thats not inportant to me atm, but I would like to get it up and working, if this is a bad script to use please direct me else where, this is the only one I could find that I understood how to use.

    thanks,
    -TaX

  2. #2
    Join Date
    Jul 2008
    Posts
    138
    Thanks
    13
    Thanked 1 Time in 1 Post

    Default

    the variable names are the same as the POST value such as this...
    PHP Code:
    $name $_POST['name'];
    $email $_POST['email']; 
    Instead of
    PHP Code:
    $Fname $_POST['First Name'];
    $Lname $_POST['Last Name']; 
    Where you post the values give this a try
    PHP Code:
    $Fname $_POST['Fname'];
    $Lname $_POST['Lname']; 
    Fname and Lname will be your field name values in your form like
    <input name="Fname">...</input>

    You might change your first part of validation to this, because you already check $Email below that
    PHP Code:
    if (empty($Body)){
      print 
    "No message was entered.";
      } 
    Last edited by ?foru; 05-16-2009 at 04:24 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •