Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Php Mail

  1. #1
    New Coder
    Join Date
    Jun 2009
    Posts
    50
    Thanks
    20
    Thanked 0 Times in 0 Posts

    Exclamation Php Mail

    Hi Guys,

    I am currently in the process of editing a template for a client. This template has a contact page and a book a table page. Both have the same mail.php form to authenticate and send the mail. The contact form is working grand and that sends perfectly its the Book a table page that aint working please help.

    heres the 2 code snippets for the form for Booking a table and the php form! PLease note i have made a copy of mail.php and renamed it mailbooking.php to distinguish the forms.

    Code:
    <form action="php/mailbooking.php" method="post" enctype="multipart/form-data">
                                    <div class="book-table-form">
                                      <label>Party size:</label>
                                      <input class="input-field mid-short" name="party-size" id="party-size" />
                                      
                                      <label>Date:</label>
                                      <input class="input-field date" name="name" id="datepicker" />
                                      
                                      <label>Meal Type:</label>
                                      <div class="selector" id="uniform-"><span style="-moz-user-select: none;">Please select your meal type:</span>
                                      <select style="opacity: 0;">
                                        <option value="option1">Christmas Menu</option>
                                        <option value="option2">Dinner</option>
                                        <option value="option3">French Value Menu</option>
                                        <option value="option3">Group Menu</option>
                                      </select></div>
                                      
                                      <label>Time:</label>
                                      <input maxlength="2" class="input-field short" name="name" id="hours" /> : <input maxlength="2" class="input-field short" name="minutes" id="time" />
                                      
                                      <label>Name:</label>
                                      <input class="input-field" name="name" id="name1" />
                                      
                                      <label>Email:</label>
                                      <input class="input-field" name="email" id="email1" />
                                      
                                      <label>Phone:</label>
                                      <input class="input-field" name="phone" id="phone1" />
                                      
                                      <label>Notes:</label>
                                      <textarea class="textarea-field" name="message" id="message1" cols="80" rows="5"></textarea>
                                      <br/>
                                      <input type="submit" name="" class="submit" value="Send Email" />
    								  <input type="reset" name="" class="reset" value="Clear form" />
                                    
                                    </div>
                                  </form>
    PHP Code:
    <?php

    // CONFIGURATION --------------------------------------------------------------

    // This is the email where the contact mails will be sent to.
    $config['recipient'] = 'sakura-designs@hotmail.com';

    // This is the subject line for contact emails.
    // The variable %name% will be replaced with the name of the sender.
    $config['subject'] = 'Query from Website %name%';

    // These are the messages displayed in case of form errors.
    $config['errors'] = array
    (
        
    'no_name'       => 'Please enter your name',
        
    'no_email'      => 'Your Email adresse is required.',
        
    'invalid_email' => 'You entered an invalid email address.',
        
    'no_message'    => 'Please, include your message.',
    );

    // END OF CONFIGURATION -------------------------------------------------------


    // Ignore non-POST requests
    if ( ! $_POST)
        exit(
    'Nothing to see here. Please go back to the site.');

    // Was this an AJAX request or not?
    $ajax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');

    // Set the correct HTTP headers
    header('Content-Type: text/'.($ajax 'plain' 'html').'; charset=utf-8');

    // Extract and trim contactform values
    $name    = isset($_POST['name']) ? trim($_POST['name']) : '';
    $email   = isset($_POST['email']) ? trim($_POST['email']) : '';
    $message = isset($_POST['message']) ? trim($_POST['message']) : '';

    // Take care of magic quotes if needed (you really should have them disabled)
    set_magic_quotes_runtime(0);
    if (
    get_magic_quotes_gpc())
    {
        
    $name    stripslashes($name);
        
    $email   stripslashes($email);
        
    $message stripslashes($message);
    }

    // Initialize the errors array which will also be sent back as a JSON object
    $errors NULL;

    // Validate name
    if ($name == '' || strpos($name"\r") || strpos($name"\n"))
    {
        
    $errors['name'] = $config['errors']['no_name'];
    }

    // Validate email
    if ($email == '')
    {
        
    $errors['email'] = $config['errors']['no_email'];
    }
    elseif ( ! 
    preg_match('/^[-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?$/iD'$email))
    {
        
    $errors['email'] = $config['errors']['invalid_email'];
    }

    // Validate message
    if ($message == '')
    {
        
    $errors['message'] = $config['errors']['no_message'];
    }

    // Validation succeeded
    if (empty($errors))
    {
        
    // Prepare subject line
        
    $subject str_replace('%name%'$name$config['subject']);

        
    // Additional mail headers
        
    $headers  'Content-Type: text/plain; charset=utf-8'."\r\n";
        
    $headers .= 'From: '.$email;

        
    // Send the mail
        
    if ( ! mail($config['recipient'], $subject$message$headers))
        {
            
    $errors['server'] = 'There seems to be a technical problem with our server. We are sorry. '.
                                
    'Could you mail your message directly at '.$config['recipient'].'? Thank you.';
        }
    }

    if (
    $ajax)
    {
        
    // Output the possible errors as a JSON object
        
    echo json_encode($errors);
    }
    else
    {
        
    // Show a simple HTML feedback message in case of non-javascript support
        
    if (empty($errors))
        {
            echo 
    '<h1>Thank you</h1>';
            echo 
    '<p>Your message has been sent.</p>';
        }
        else
        {
            echo 
    '<h3>Oops!</h3>';
            echo 
    '<h5>Please go back and fix the following errors:</h5>';
            echo 
    '<ul><li>';
            echo 
    implode('</li><li>'$errors);
            echo 
    '</li></ul>';
        }
    }

  • #2
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    you have a lot of checkings within php script. What do you get when running the script?

  • #3
    New Coder
    Join Date
    Jun 2009
    Posts
    50
    Thanks
    20
    Thanked 0 Times in 0 Posts
    I dunno to be honest. Basically on the website http://www.letirebouchon.ie/newwebsite/book-table.html that is the form im trying to send to the required email but when i fill in all the details its only sending the notes section of the form when i need to send the party size, the date, time etc. aswell.

  • #4
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    look, you pass only the value of the message field to the mail function. You should create a message with all features and then send it.


  •  

    Posting Permissions

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