Page 1 of 2 12 LastLast
Results 1 to 15 of 24

Thread: Email form?

  1. #1
    Join Date
    Aug 2003
    Location
    St. Louis, Missouri
    Posts
    1,814

    Email form?

    Long time ago I used that mailto:emailaddress, and I put that into FORM tag, and it used to open up my email and all the text from the form was inserted into message. Now when I create it like that, all the text from form doesn't show up in the message. I've also tried many php and perl email form scripts, but none of them send. I have no idea what's wrong with it. Any help?

  2. #2
    Join Date
    Oct 2002
    Location
    Middle Dearth
    Posts
    21,045
    Not enough info to help with a script.
    What script?
    What happens?
    Any errors?
    That sort of thing.

  3. #3
    Join Date
    Aug 2003
    Location
    St. Louis, Missouri
    Posts
    1,814
    When I tried to use just html and mailto, everything goes perfect but on the form is has like name, address, etc. and it only inserts TO:, and leaves the message box blank. It doesn't add name=blah blah, address=blah blah, etc. in the message box.

    But here is the code from the script:

    PHP Code:
    <?php
    if ($submit) { // if the form was sent do the following

    if($name && $address && $city && $state && $zipcode && $order && $paymentmethod && $email && $comments) { // if all fields were filled-in send email
    mail("myemail@myhost.com","From: $name <$email>") or die("email 
    error"
    );
    echo 
    "Message Sent"// if all went well, display message was sent
    } else {
    echo 
    "All fields must be filled in!<BR>"// if not all were filled in, display error message
    }
    // end php submission code
    ?>
    Is that right? Any errors? I put that above the start of the FORM.

  4. #4
    Join Date
    Mar 2004
    Location
    USA
    Posts
    4,342
    Download free sample forms:
    Contact Form-- Free PHP Scripts
    Testing 1.. Testing 1..2.. Testing 1..2..3...

  5. #5
    Join Date
    Mar 2004
    Location
    USA
    Posts
    4,342
    it also has a nice tutorial to apply

    peace,
    Testing 1.. Testing 1..2.. Testing 1..2..3...

  6. #6
    Join Date
    Aug 2003
    Location
    St. Louis, Missouri
    Posts
    1,814
    That form has big code, it'll take too long to edit.

  7. #7
    Join Date
    Oct 2002
    Location
    Middle Dearth
    Posts
    21,045
    Originally posted by WHTer
    When I tried to use just html and mailto, everything goes perfect but on the form is has like name, address, etc. and it only inserts TO:, and leaves the message box blank. It doesn't add name=blah blah, address=blah blah, etc. in the message box.

    But here is the code from the script:

    PHP Code:
    <?php
    if ($submit) { // if the form was sent do the following

    if($name && $address && $city && $state && $zipcode && $order && $paymentmethod && $email && $comments) { // if all fields were filled-in send email
    mail("myemail@myhost.com","From: $name <$email>") or die("email 
    error"
    );
    echo 
    "Message Sent"// if all went well, display message was sent
    } else {
    echo 
    "All fields must be filled in!<BR>"// if not all were filled in, display error message
    }
    // end php submission code
    ?>
    Is that right? Any errors? I put that above the start of the FORM.
    OKay, your form first.
    Does it have the action set to post to this same page?
    Are the fields in your form named just like you see in the PHP fields ($name, $address)?
    Is this page parsed by PHP (typically requires being named something like "page.php", not "page.html")
    Could you post a link to the actual page where this is located?

  8. #8
    Join Date
    Aug 2003
    Location
    St. Louis, Missouri
    Posts
    1,814
    ok, I've made seperate html and php files. But when I fill out the form and click submit, this message comes.

    Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/atth4y/public_html/shop/sendmail.php on line 2

    Parse error: parse error, unexpected T_STRING in /home/atth4y/public_html/shop/sendmail.php on line 2
    This is whole php code in sendmail.php starting with line 1:

    PHP Code:
    <?php
    if ($submit) { // if the form was sent do the following

    if($name && $address && $city && $state && $zipcode && $order && $paymentmethod && $email && $comments) { // if all fields were filled-in send email
    $subject="Order";
    $msg $name "\n" $address "\n" $city "\n" $state "\n" $zipcode "\n" $order "\n" $paymentmethod "\n" $email "\n" $comments;
    mail("haris3636@hotmail.com","From: $name <$email>"$subject$msg);
    mail($to,"From: $name <$email>",$subject,$message) or die("email 
    error"
    );
    echo 
    "Message Sent"// if all went well, display message was sent
    } else {
    echo 
    "All fields must be filled in!<BR>"// if not all were filled in, display error message
    }
    // end php submission code
    ?>
    Click here to go directly to that page

  9. #9
    Join Date
    Aug 2003
    Location
    PA
    Posts
    110
    A big problem, and especially if you cut and pasted this, is that all of your form variables, since you are using the POST method, must be like this $_POST['form_field_name']. Otherwise, you will have stuff going wrong right off the bat.

    The error usually means that you are using a function or logic with a space between them. Try making your logic call on line two if($_POST['submit']), instead of if ($_POST['submit']) and see if that eliminates the error.

    Hope all of this helps!
    Jim

  10. #10
    Join Date
    Aug 2003
    Location
    St. Louis, Missouri
    Posts
    1,814
    Sorry w3needs, I didnt understand anything you said. I tried deleting that one space between if and ($submit) but i received same error.

  11. #11
    Join Date
    Aug 2003
    Location
    PA
    Posts
    110
    All form fields are transported through pages via normal http calls. But, in order to extract the data in those variables that you used to name the forms, you use the method value to call those variables.

    Now, your form was using the method POST to transport the variables in the fields(values in the fields) to the next page. To extract them, so that they can be used throughout your script for whatever purpose you have in mind, you must call them this way:

    $_POST['field_name']

    not, $field_name

    I hope this helps!
    Jim

  12. #12
    Join Date
    Jun 2004
    Location
    India
    Posts
    71
    use .js or php.

    have an search in http://www.hotscripts.com

  13. #13
    Join Date
    Oct 2002
    Location
    Middle Dearth
    Posts
    21,045
    Originally posted by webhoststalk
    use .js or php.
    ^^ that is PHP. ^^

  14. #14
    Well I think if you use the following php script , Your form will work well.

    PHP Code:
    <?php        
        
        
    //This is the location of your sendmail variable
        //if you don't know, contact your sysadmin
        
    $mail_path "/usr/sbin/sendmail -i -t";
        
        
    //The email address to be receiving emails from this form
        
    $mail_to "zan@stargeek.com";
        
        
    //the subject of the email sent by the form
        
    $mail_subject "Contact Form";

        
    //the name of the buisness or website that the form contacts
        
    $buisness_name "Stargeek";
        
        
    //this is the html of the form used to create the email
        
    $form_html '$html = "
                        <h1>
                            To Contact $buisness_name:
                            </h1>                    
                            <form action=\"$PHP_SELF\" method=\"post\">
                                <table class=\"mainText\" border=\"0\" cellspacing=\"5\">                
                                    <tr>
                                        <td>Your Name:    </td>
                                        <td>$name </td>
                                    </tr>    
                                    <tr>
                                        <td>Your Email Address:</td>
                                        <td>$reply<td>
                                    </tr>    
                                    <tr>
                                        <td colspan=\"2\" align=\"center\">Your Message</td>
                                    </tr>
                                    <tr>
                                        <td colspan=\"2\" align=\"center\">$message</td>
                                    </tr>
                                    <tr>
                                        <td colspan=\"2\"  align=\"center\">$send</td>
                                    </tr>
                                </table>
                            </form>
                            Script by <a href="http://www.stargeek.com">Stargeek</a>
                ";'
    ;


        
    ini_set("sendmail_from"$mail_from);
        
    ini_set("sendmail_path"$mail_path);
        
        if (
    $_POST)
        {
            if(
    $_POST['userEmail'])
            {
                if( 
    mail($mail_to,$mail_subject,"\t From: ".$_POST['userName']."\n \t Email: ".$_POST['userEmail']. "\n\n\n\n".stripslashes($_POST['userMessage']).'this email was generated by <a href="http://www.stargeek.com">Stargeek</a>\'s script'.,"From: $_POST[userEmail]\r\n"."Reply-To: $_POST[userEmail]\r\n")  )            
                {
                    
    $html  'Thank you for contacting '.$buisness_name.', '.$_POST['userName'].'. <br/>Your email was sent <br/>Script by <a href="htp://www.stargeek.com">Stargeek</a>';
                }
                else 
                {
                    
    $html 'There was an error';    
                }
            }                
        }
        else 
        {        
            
    $message '<textarea name="userMessage" rows="20" cols="70"></textarea>';
            
    $name '<input type="text" name="userName" size="30">';
            
    $reply '<input type="text" name="userEmail" size="30">';
            
    $send '<input type="submit" name="submit" value="Send">';
            
            eval(
    $form_html);
        }
    ?> 



    <html>
    <head>
    <title>-{Title Here}-</title>
    </head>
    <body>
    <?=$html?>
    </body>
    </html>
    You can get more information about this script by visiting http://www.stargeek.com/php_scripts.php?script=12
    <4ulyrics>Cheers ,
    Think Lyrics .... Think 4ULYRICS</4ulyrics>

  15. #15
    Join Date
    Aug 2003
    Location
    St. Louis, Missouri
    Posts
    1,814
    No, it doesn't really matter what script it is. I just dont know what the problem could be. w3needs, I tried the suggestion you said, but same error. Error still at line #2.

Page 1 of 2 12 LastLast

Related Posts from theWHIR.com

Posting Permissions

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