Web Analytics Made Easy -
StatCounter Question about a simple contact script - CodingForum

Announcement

Collapse
No announcement yet.

Question about a simple contact script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question about a simple contact script

    I would like to have a place on my site where ppl can just enter there name e-mail address/comments ,, and when they click send an e-mail is sent to me with the information they entered.

    i have all the feild done like this
    Code:
    <form name="form1" method="post" action="">
          <table width="249" border="0" cellspacing="2" cellpadding="2">
            <tr>
              <td width="96">Name</td>
              <td width="139"><input name="name" type="text" id="name" size="10"></td>
            </tr>
            <tr>
              <td>E-mail</td>
              <td><input name="email" type="text" id="email" size="10"></td>
            </tr>
            <tr>
              <td>From</td>
              <td><input name="from" type="text" id="from" size="10"></td>
            </tr>
            <tr>
              <td>Commetns</td>
              <td><textarea name="comments" cols="15" id="comments"></textarea></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><input type="submit" name="Submit" value="Submit"></td>
            </tr>
          </table>
        </form>

    How do i get it to send ? and for them to get a Thank you page?

    any help is greatful

    thanks

  • #2
    <form action="sent.php" method="post">
    your forms here
    ----------------------------
    open a new file:

    PHP Code:
    <?php
    mail
    ("[email protected]""$name""$email""$from""$comments");
    echo(
    "Thanks $name!<BR>\nYour mail has been sent!"); 
    ?>
    when your done, save as sent.php!

    OR

    This is example!

    PHP Code:
    <? 
    if($submit//If submit is pressed 

    mail("[email protected]""$subject""$email""$comments"); 
    } else {
    ?> 
    <form method='post' action='<? echo $PHP_SELF?>'> 
    E-Mail: <INPUT TYPE='TEXT' NAME='email' size=60> 
    Subject: <INPUT TYPE='TEXT' NAME='subject' size=60> 
    Comments: <TEXTAREA NAME='comments' ROWS=10 COLS=30></TEXTAREA> 
    <input type='submit' name='submit' value='submit'> 
    </form> 

    <? }?>
    You can change those form fields
    Last edited by fr0stx; Feb 29, 2004, 11:34 AM.
    http://e-hosti.com :: Our low cost web hosting packages... 99% Uptime... 30 Day Money Back Guarantee...

    Comment


    • #3
      ok ,, but whats in teh sent.php file??

      i dont have a sent.php so when is looks for it nothing will happen

      do i need something link this

      Code:
      ?> php
      ',',',
      i seen something like that a while ago

      but i cant remember what it was

      Comment


      • #4
        edited on the top ^^
        http://e-hosti.com :: Our low cost web hosting packages... 99% Uptime... 30 Day Money Back Guarantee...

        Comment


        • #5
          Thanks works great.

          Comment


          • #6
            Your welcome
            http://e-hosti.com :: Our low cost web hosting packages... 99% Uptime... 30 Day Money Back Guarantee...

            Comment


            • #7
              i just noticed ,,

              When i tried it,.

              It dosnt send all the info.

              there are 4 feilds and only 2 of them are sent

              heres the form

              http://www.davidstokes.com/testmail.htm

              Comment


              • #8
                Just rename your page to .php instead of .htm
                PHP Code:
                <?php
                if(!isset($_POST['Submit'])){
                ?>
                    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form1" class="tah10">
                        <table width="170" border="0" cellspacing="2" cellpadding="2">
                            <tr>
                                <td width="26" class="ver10">Name</td>
                                <td width="60" class="ver10"><input name="name" type="text" id="name" size="10"></td>
                            </tr>
                            <tr>
                                <td class="ver10">Email</td>
                                <td class="ver10"><input name="email" type="text" id="email" size="10"></td>
                            </tr>
                            <tr>
                                <td class="ver10">Budget</td>
                                <td class="ver10"><input name="budget" type="text" id="budget" value="$" size="10"></td>
                            </tr>
                        </table>
                        <div align="center"><span class="ver10">
                            <textarea name="required" cols="20" rows="4" id="required">Please write whats required here, ie/Site design/Print work etc.</textarea>
                            <input type="submit" name="Submit" value="Submit">
                            <br>
                        </span> 
                        </div>
                    </form>
                <?php
                }else{
                    
                $name $_POST['name'];
                    
                $email $_POST['email'];
                    
                $from "From: ".$_POST['email']." <".$_POST['email'].">";
                    
                $budget $_POST['budget'];
                    
                $required $_POST['required'];
                    
                    
                $message "You have recieved an email from ".$name." with the budget of ".$budget.". With the required text: ".$required.", contact this member by email: ".$email;
                    
                    
                $sent mail("[email protected]","You got an email",$message,$from);
                    if(
                $sent){
                        echo 
                'Thank you '.$name.', your email has been submitted.';
                    }else{
                        echo 
                'There was an error sending the email';
                    }
                }
                ?>
                Last edited by Nightfire; Feb 29, 2004, 12:37 PM.

                Comment


                • #9
                  thanks thats super

                  Comment

                  Working...
                  X