Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Double-check a contact form

  1. #1
    Join Date
    Jul 2011
    Posts
    113
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default Double-check a contact form

    I borrowed this form from a previous website I "frankensteined" - my friend helped me with this script.... I was hoping to use it again for this website http://richieadams.com (click on contact)

    Does all the documentation look correct, will this form work?

    HTML Code:
     <div id="contactFormContainer" class="clearfix">
            <form action="email.php" method="POST" class="form" id="contactForm">
            <span class="hidden isSubmitted">Submitted</span>
              <label for="name">Name</label>
              <input type="text" id="name" name="name" class="validate[required,custom[onlyLetterSp],maxSize[30]] text-input" />
              <label for="email">Email</label>
              <input type="email" id="email" name="email" class="validate[required,custom[email]] text-input" />
              <label for="subject">Subject</label>
              <input type="text" id="subject" name="subject" class="validate[required,custom[onlyLetterSp],maxSize[40]] text-input" />
              <label for="message">Messsage</label>
              <textarea name=message id=message class="validate[required] text-input"></textarea><br />
              <input type="submit" value="Submit" name="submit" class="submit">
              <input type="reset" value="Clear" name="clear" class="submit">
            </form>
          </div>
    PHP Code:
    <?php

    require_once 'lib/swift_required.php';

    // Set who is going to get the email
    $to 'info@rrc.la';

    // Set the subject.  This is being pulled from posted form
    $subject $_POST['subject'];
    $from $_POST['email'];
    $name $_POST['name'];
    $message $_POST['message'];
    $date date("F j, Y, g:i a"strtotime('2 hours'));

    $message Swift_Message::newInstance()

      ->
    setSubject('RRC.LA Contact Form: ' $subject)

      
    //Set the From address with an associative array
      
    ->setFrom(array($from => $name))

      
    //Set the To addresses with an associative array
      
    ->setTo(array($to))

      
    //Give it a body
      
    ->setBody("Subject: $subject \n From: $name \n Message: $message \n\n timestamp: $date")

      
    //And optionally an alternative body
      
    ->addPart("<h3>RRC.LA Contact Form</h3><b>Subject:</b> $subject <br /><br /> <b>From:</b> $name <br /><br /> <b>Message:</b> $message <br /><br /><br /><i>timestamp: $date"'text/html')
      ;

    $transport Swift_MailTransport::newInstance();

    $mailer Swift_Mailer::newInstance($transport);

    $result $mailer->send($message);

    $host  $_SERVER['HTTP_HOST'];
    $uri   rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $extra 'contact.html#submitted';
    header("Location: http://$host$uri/$extra");

  2. #2
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default

    did you test it?
    Thanks,

    Bud

  3. #3
    Join Date
    Jul 2011
    Posts
    113
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    I just tested it and am waiting for my boss to let me know if he got the test email or not... I have a white page after hitting submit. I thought there was something in the PHP to have it load the same page, but with "submitted" in the contact form box.

  4. #4
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    It looks alright, when it is submitted, it should go to a page called email.php which might be blank. Only now thing, in add
    Art, you forgot to end an <I> tag.
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
    Anime Views Forums
    Bernie

  5. #5
    Join Date
    Jul 2011
    Posts
    113
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    Where is this <i> tag? I apologize for my ignorance. Also, it would seem that a) my boss did not receive the TEST email and b) I am not sure how to program the page to populate the way it did on the other site, see http://riverroadcreative.co/contact.html... I need it to work like that and I'm not sure what I am doing/doing wrong. Thank you.

  6. #6
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    the <i> tag is here:
    Code:
      //And optionally an alternative body 
      ->addPart("<h3>RRC.LA Contact Form</h3><b>Subject:</b> $subject <br /><br /> <b>From:</b> $name <br /><br /> <b>Message:</b> $message <br /><br /><br /><i>timestamp: $date", 'text/html')
       ;
    another point, is that the whole code? Because there is no php ending (?>).

    I would put in some trouble shooting code there, ie printing some variables and seeing if they come up, ie:
    PHP Code:
    <?php 

    require_once 'lib/swift_required.php'

    // Set who is going to get the email 
    $to 'info@rrc.la'

    // Set the subject.  This is being pulled from posted form 
    $subject $_POST['subject']; 
    $from $_POST['email']; 
    $name $_POST['name']; 
    $message $_POST['message']; 
    $date date("F j, Y, g:i a"strtotime('2 hours'));

    [
    color=red]
    echo 
    $subject// troubleshooting code
    echo $from;
    echo 
    $name;
    echo 
    $message;
    echo 
    $date;
    [/
    color

    $message Swift_Message::newInstance() 

      ->
    setSubject('RRC.LA Contact Form: ' $subject

      
    //Set the From address with an associative array 
      
    ->setFrom(array($from => $name)) 

      
    //Set the To addresses with an associative array 
      
    ->setTo(array($to)) 

      
    //Give it a body 
      
    ->setBody("Subject: $subject \n From: $name \n Message: $message \n\n timestamp: $date")
     
      
    //And optionally an alternative body 
      
    ->addPart("<h3>RRC.LA Contact Form</h3><b>Subject:</b> $subject <br /><br /> <b>From:</b> $name <br /><br /> <b>Message:</b> $message <br /><br /><br /><i>timestamp: $date"'text/html')
       ; 

    $transport Swift_MailTransport::newInstance(); 

    $mailer Swift_Mailer::newInstance($transport); 

    $result $mailer->send($message); 

    $host  $_SERVER['HTTP_HOST']; 
    $uri   rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); 
    $extra 'contact.html#submitted'
    header("Location: http://$host$uri/$extra"); 
    ?>
    if that echos the variables, then it must be a problem with the mailing system.
    Last edited by keyboard; 10-04-2012 at 12:30 AM. Reason: Format: Fixed BBcode
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
    Anime Views Forums
    Bernie

  7. #7
    Join Date
    Jul 2011
    Posts
    113
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    Unfortunately, I don't really know PHP, so the lingo is over my head... I don't understand the suggestion or what it is would do. Can you dumb it down for me? I'm sorry.

  8. #8
    Join Date
    Jul 2011
    Posts
    113
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    I think I am getting closer, see richieadams.com (click contact) - However, when I submit I get a white page.

  9. #9
    Join Date
    Jul 2011
    Posts
    113
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    I'm now a little concerned that neither site is actually forwarding the contact form... I am so clueless at all of this. I really need help.

  10. #10
    Join Date
    Jul 2011
    Posts
    113
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    Ok, so I am no trying another form that another friend recommended, but i sent and got the message 'Thank you for the message. We will contact you shortly.' Which is hopeful... but I keep checking my email... nothing is coming in. Thoughts?:
    Code:
    form class="form" action="contact-form.php" method="post">
                    <div class="move-over">
                      <h3>Name:</h3><input type="text" name="cf_name" value="" /><br />
                      
                      <h3>Email Address:</h3><input type="text" name="cf_email" value="" /><br />
                    </div>
                    <div class="move-over">
                      <h3>Message:</h3><textarea class="bigger" name="cf_message" value="" ></textarea><br />
                      <br />
                      <input type="submit" value="Send" />
                      <input type="reset" value="Clear" />
                    </div>
                </form>
    PHP Code:
    <?php
    $field_name 
    $_POST['cf_name'];
    $field_phone $_POST['cf_phone'];
    $field_email $_POST['cf_email'];
    $field_message $_POST['cf_message'];

    $mail_to 'katie@rrc.la';
    $subject 'Message from RA website';

    $body_message 'From: '.$field_name."\n";
    $body_message .= 'E-mail: '.$field_email."\n";
    $body_message .= 'Message: '.$field_message;

    $headers 'From: '.$field_email."\r\n";
    $headers .= 'Reply-To: '.$field_email."\r\n";

    $mail_status mail($mail_to$subject$body_message$headers);

    if (
    $mail_status) { ?>
        <script language="javascript" type="text/javascript">
            alert('Thank you for the message. We will contact you shortly.');
            window.location = 'contact.html';
        </script>
    <?php
    }
    else { 
    ?>
        <script language="javascript" type="text/javascript">
            alert('Message failed. Please, send an email to katie@rrc.la');
            window.location = 'contact.html';
        </script>
    <?php
    }
    ?>

Similar Threads

  1. double submit button form
    By Hollywood in forum HTML
    Replies: 5
    Last Post: 03-20-2010, 08:39 PM
  2. Contact Form
    By funkyspyspy in forum PHP
    Replies: 1
    Last Post: 12-21-2009, 02:29 PM
  3. Contact form using php
    By biomike in forum PHP
    Replies: 13
    Last Post: 12-26-2008, 03:25 AM
  4. Help with contact form please
    By cbleep in forum HTML
    Replies: 6
    Last Post: 09-14-2007, 07:12 PM
  5. Using a form to do a double post
    By blast4 in forum Looking for such a script or service
    Replies: 2
    Last Post: 08-15-2007, 02:44 PM

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
  •