The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 3 of 3

Thread: PHP Contact Form

  1. #1

    PHP Contact Form

    Hi,

    I am new to PHP, I am trying to create a contact form using html and php. I found the tutorial on this website to create one. Problem is, whenever I submit the form it displays the php code in the browser. Any help on how to resolve this would be greatly appreciated.

    The code I have is,

    HTML Code:
    <html>
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 1</title>
    </head>
    <body>
    <form method="POST" action="mailer.php">
     Name:
     <input type="text" name="name" size="19"><br>
     <br>
     E-Mail:
     <input type="text" name="email" size="19"><br>
     <br>
     
     <input type="checkbox" name="check[]" value="blue_color"> Blue<br>
     <input type="checkbox" name="check[]" value="green_color"> Green<br>
     <input type="checkbox" name="check[]" value="orange_color"> Orange<br>
     <br>
     <input type="radio" value="yes" name="radio"> YES<br>
     <input type="radio" value="no" name="radio"> NO
     <br>
     <br>
     <select size="1" name="drop_down">
     <option>php</option>
     <option>xml</option>
     <option>asp</option>
     <option>jsp</option>
     </select><br>
     <br>
     Message:<br>
     <textarea rows="9" name="message" cols="30"></textarea><br>
     <br>
     <input type="submit" value="Submit" name="submit">
    </form>
    </body>
    </html>
    PHP Code:
    <?php
    if(isset($_POST['submit'])) {
     
    $to "iduthie@acandco.com"
     
    $subject "Form Tutorial";
     
    $name_field $_POST['name'];
     
    $email_field $_POST['email'];
     
    $message $_POST['message'];
     
    $option $_POST['radio'];
     
    $dropdown $_POST['drop_down'];
     foreach(
    $_POST['check'] as $value) {
      
    $check_msg .= "Checked: $value\n";
     }
     
     
    $body "From: $name_field\n E-Mail: $email_field\n $check_msg Option: $option\n Drop-Down: $dropdown\n Message:\n $message\n";
     echo 
    "Data has been submitted to $to!";
     
    mail($to$subject$body);
     
    } else {
     echo 
    "blarg!";
    }
    ?>
    Thanks

    Towsie

  2. #2
    jwilliam's Avatar
    476
    posts
    An intellectual carrot!
    If you're seeing the php code in your web browser then your web server is not setup to run php scripts correctly. If this is shared hosting, then check out the company's website or contact their customer support to get it resolved. If you're setting it up yourself there are plenty of tutorials online for configuring php with Apache... and I'm sure for IIS (or whatever you're using) as well...

  3. #3

    It Works!!!!!!!!`

    Hello towise,

    its run @ my end so it it problem with php. Please check any php file is run or not or might be you are trying to run our of host(where we can run php/asp like scripting file)

    Get back to me if you have an issue

    Regards,
    Kunjan

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012