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 9 of 9
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    41
    Thanks
    6
    Thanked 0 Times in 0 Posts

    feedback form...whats wrong with this...not working

    guyz...am tryin to insert this page on my godaddy for my site...and its a feedback for where people give me feedback or they want me tocontact them ...what they do is...enter their name and email and hit the send which should send me an email showin me the contact form....some how i cant get this thing to work....is there anythin i should add to this or is there any other way to do a simple contact us or a feedback form....plz help me....thanx
    Code:
    <?php
    
    
    
    /**
    
     * Change the email address to your own.
    
     *
    
     * $empty_fields_message and $thankyou_message can be changed
    
     * if you wish.
    
     */
    
    
    
    // Change to your own email address
    
    $your_email = "you@example.com";
    
    
    
    // This is what is displayed in the email subject line
    
    // Change it if you want
    
    $subject = "Message via your contact form";
    
    
    
    // This is displayed if all the fields are not filled in
    
    $empty_fields_message = "<p>Please go back and complete all the fields in the form.</p>";
    
    
    
    // This is displayed when the email has been sent
    
    $thankyou_message = "<p>Thankyou. Your message has been sent.</p>";
    
    
    
    // You do not need to edit below this line
    
    
    
    $name = stripslashes($_POST['txtName']);
    
    $email = stripslashes($_POST['txtEmail']);
    
    $message = stripslashes($_POST['txtMessage']);
    
    
    
    if (!isset($_POST['txtName'])) {
    
    
    
    ?>
    
    
    
    <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
    
    
    
        <p><label for="txtName">Name:</label><br />
    
        <input type="text" title="Enter your name" name="txtName" /></p>
    
    
    
        <p><label for="txtEmail">Email:</label><br />
    
        <input type="text" title="Enter your email address" name="txtEmail" /></p>
    
    
    
        <p><label for="txtMessage">Your message:</label><br />
    
        <textarea title="Enter your message" name="txtMessage"></textarea></p>
    
    
    
        <p><label title="Send your message">
    
        <input type="submit" value="Send" /></label></p>
    
    
    
    </form>
    
    
    
    <?php
    
    
    
    }
    
    
    
    elseif (empty($name) || empty($email) || empty($message)) {
    
    
    
        echo $empty_fields_message;
    
    
    
    }
    
    
    
    else {
    
    
    
        // Stop the form being used from an external URL
    
        // Get the referring URL
    
        $referer = $_SERVER['HTTP_REFERER'];
    
        // Get the URL of this page
    
        $this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];
    
        // If the referring URL and the URL of this page don't match then
    
        // display a message and don't send the email.
    
        if ($referer != $this_url) {
    
            echo "You do not have permission to use this script from another URL.";
    
            exit;
    
        }
    
    
    
        // The URLs matched so send the email
    
        mail($your_email, $subject, $message, "From: $name <$email>");
    
    
    
        // Display the thankyou message
    
        echo $thankyou_message;
    
        
    
    }
    
    
    
    ?>

  • #2
    New Coder
    Join Date
    Sep 2007
    Location
    US
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 4 Posts
    First off, you'll want to send the mail to your own mailbox. The youremail@host.com at the beginning of the script should be changed to your own email.

    In fact, just use this email form instead.
    PHP Code:
    <form name="form1" method="post" action="">
    <table width="100%" border="0" cellspacing="0" cellpadding="2">
      <tr>
        <td width="10%">Email Address: </td>
        <td width="90%"><input name="email" type="text" id="email"></td>
      </tr>
      <tr>
        <td>Name:</td>
        <td><input name="name" type="text" id="name"> 
          (optional) </td>
      </tr>
      <tr>
        <td>Message:</td>
        <td><textarea name="message" cols="40" rows="6"></textarea></td>
      </tr>
        <tr>
        <td colspan="2"><input type="submit" name="Submit" value="Submit"></td>
      </tr>
    </table>

    </form>

    <?php

    if(isset($_POST['email']) && isset($_POST['message']))
    {
        
        
    $name $_POST['name'];
        
    $email $_POST['email'];
        
    $msg $_POST['message'];
        
        
    // You'll want to validate the email and make sure that no one is trying to send this feedback to some one else as well.
        
    if(eregi("to:",$email) || eregi("cc:",$email) || eregi('bcc:',$email)) 
            echo
    'Sorry, we couldn\'t send your message, please try again.';
        
        if(!
    ereg('^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$'$email))
            echo
    'Sorry, you entered an invalid email address!';

    /*
    * You may also want to run a strip_tags on the message so you don't get radnom html/JS in your emails
    */
        
    $msg strip_tags($msg);
        
    /*
    * Please be away that this can still be attacked by spam bots and they may use this to send you junk emails.
    */

        
    $to "Youremail@yourhost.com";
        
    $subject "Feedback";
        
    $headers "From: $name <$email>";

        
    mail($to,$subject,$msg,$headers);

    }

    ?>
    You can find more info on it here:
    http://codingforums.com/showthread.php?t=131341
    I need to find a book about all this stuff. God, thats gonna be one big book!

    http://www.gamezftw.com
    Play On!

  • Users who have thanked Digicoder for this post:

    daraptor (01-19-2008)

  • #3
    New Coder
    Join Date
    Dec 2006
    Posts
    41
    Thanks
    6
    Thanked 0 Times in 0 Posts
    hey digicoder...i did what u gave man....i created a .html file and put the html part in that and the php part in the php file and also changed the form action to the php page and also gave my email ....i tried to give te details and hit teh submit and ..it doesnt do anything...is there anything else i should change or add....ithis is what i did accordin to ur script

    Code:
    <form name="form1" method="post" action="conta.php">
    <table width="100&#37;" border="0" cellspacing="0" cellpadding="2">
      <tr>
        <td width="10%">Email Address: </td>
        <td width="90%"><input name="email" type="text" id="email"></td>
      </tr>
      <tr>
        <td>Name:</td>
        <td><input name="name" type="text" id="name"> 
          (optional) </td>
      </tr>
      <tr>
        <td>Message:</td>
        <td><textarea name="message" cols="40" rows="6"></textarea></td>
      </tr>
        <tr>
        <td colspan="2"><input type="submit" name="Submit" value="Submit"></td>
      </tr>
    </table>
    
    </form>
    Code:
    <?php
    
    if(isset($_POST['email']) && isset($_POST['message']))
    {
        
        $name = $_POST['name'];
        $email = $_POST['email'];
        $msg = $_POST['message'];
        
        // You'll want to validate the email and make sure that no one is trying to send this feedback to some one else as well.
        if(eregi("to:",$email) || eregi("cc:",$email) || eregi('bcc:',$email)) 
            echo'Sorry, we couldn\'t send your message, please try again.';
        
        if(!ereg('^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$', $email))
            echo'Sorry, you entered an invalid email address!';
    
    /*
    * You may also want to run a strip_tags on the message so you don't get radnom html/JS in your emails
    */
        $msg = strip_tags($msg);
        
    /*
    * Please be away that this can still be attacked by spam bots and they may use this to send you junk emails.
    */
    
        $to = "elivalaparla@gmail.com";
        $subject = "Feedback";
        $headers = "From: $name <$email>";
    
        mail($to,$subject,$msg,$headers);
    
    }
    
    ?>

  • #4
    New Coder
    Join Date
    Dec 2006
    Posts
    41
    Thanks
    6
    Thanked 0 Times in 0 Posts
    can someone help me....plz

  • #5
    New Coder
    Join Date
    Sep 2007
    Location
    US
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Sorry for the wait.
    I've been working.

    As long as you have the email address entered correctly it should send the email to that address.
    Depending on your email host, it may be marked as spam and you wouldn't know.


    In another situation, the PHP CLI you are using may not have the send mail enabled. in which case you should get an error.

    This script won't output anything to the browser unless you set it up to.
    Its simply used for sending email and giving errors when they are encountered.
    I need to find a book about all this stuff. God, thats gonna be one big book!

    http://www.gamezftw.com
    Play On!

  • #6
    New Coder
    Join Date
    Dec 2006
    Posts
    41
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Digicoder View Post
    Sorry for the wait.
    I've been working.

    As long as you have the email address entered correctly it should send the email to that address.
    Depending on your email host, it may be marked as spam and you wouldn't know.


    In another situation, the PHP CLI you are using may not have the send mail enabled. in which case you should get an error.

    This script won't output anything to the browser unless you set it up to.
    Its simply used for sending email and giving errors when they are encountered.

    do u have any other examples scripts for the contact us script...if so plz direct me man...i need it real bad

  • #7
    New Coder
    Join Date
    Sep 2007
    Location
    US
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 4 Posts
    The send mail function is pretty straight forward.
    All the info on that function and the things that control it are here:
    http://us.php.net/mail

    You can find other tutorials on PHP in general, the send mail included, here as well.
    http://www.w3schools.com/php/php_mail.asp

    The script looks fine to me, I would say that you don't have the SMTP settings configured in your PHP ini.

    If you don't mind, what area do you live in and what host are you using(if it all.)
    I need to find a book about all this stuff. God, thats gonna be one big book!

    http://www.gamezftw.com
    Play On!

  • Users who have thanked Digicoder for this post:

    daraptor (01-21-2008)

  • #8
    New Coder
    Join Date
    Dec 2006
    Posts
    41
    Thanks
    6
    Thanked 0 Times in 0 Posts
    yo digicoder....i followd ur example from the w3....and my site is hosted in the godady.....what i did was i created a file named mailform.php and i cut and paste the code in w3 and edited the email to my email address....but still it wont send the info man...is there something wrong am doin or doesnt godady support php.....
    this is what i pasted
    Code:
    <html>
    <body>
    
    <?php
    if (isset($_REQUEST['email']))
    //if "email" is filled out, send email
      {
      //send email
      $email = $_REQUEST['email'] ; 
      $subject = $_REQUEST['subject'] ;
      $message = $_REQUEST['message'] ;
      mail( "someone@example.com", "Subject: $subject",
      $message, "From: $email" );
      echo "Thank you for using our mail form";
      }
    else
    //if "email" is not filled out, display the form
      {
      echo "<form method='post' action='mailform.php'>
      Email: <input name='email' type='text' /><br />
      Subject: <input name='subject' type='text' /><br />
      Message:<br />
      <textarea name='message' rows='15' cols='40'>
      </textarea><br />
      <input type='submit' />
      </form>";
      }
    ?>
    
    </body>
    </html>

  • #9
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    GoDaddy requires the use of their own email script, not yours.

    Read the information provided by GoDaddy about processing forms.

    See this:
    http://codingforums.com/archive/index.php?t-49998.html
    Last edited by mlseim; 01-22-2008 at 08:35 PM.


  •  

    Posting Permissions

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