Results 1 to 24 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,321
    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,321
    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,321
    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.

  16. #16
    Join Date
    Aug 2003
    Location
    PA
    Posts
    110
    Do you run any other PHP files on your site? Is PHP 4.0+ installed? Your system is a unix/linux, correct?

    Okay, if you answered yes, then there is something else to look at....simply make a file called 'php_test.php' or whatever. Inside, use this code:

    PHP Code:
    <?php

    echo phpinfo();

    ?>
    Okay, using this, if you still get the same error, there is a problem on the install of PHP, or in the config of php.ini

    If there is no error, then eliminate the comment in line 2, and see what happens.

    You also changed the variable in the logic? Quite possibly, this is another reason for the error.

    Please let us know an update on your status, and an update on your code!

    I hope it helps!
    Jim

  17. #17
    Join Date
    Aug 2003
    Location
    St. Louis, Missouri
    Posts
    1,814
    Well I made that test:

    http://at.th4y.com/php_test.php

    Is it all good?

  18. #18
    Join Date
    Aug 2003
    Location
    St. Louis, Missouri
    Posts
    1,814
    Grr, it didnt let me edit, so I need help.

    http://newsourcemedia.com/index_view.php?id=49

    That's the script I was using. How would I put that script into this HTML form?

    Code:
    <HTML>
    <P><CENTER><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
      <TR>
        <TD WIDTH="100%" BGCOLOR="black">
        <TABLE WIDTH="394" BORDER="0" CELLSPACING="1" CELLPADDING="2">
          <TR>
            <TD ALIGN="center" COLSPAN="2" BGCOLOR="#F9C304">
            <B><FONT COLOR="red" SIZE="-1" FACE="Verdana">Order Page</FONT></B></TD>
    <FORM METHOD="POST" ACTION="formtomail.asp">
          </TR>
    	        <TR>
            <TD WIDTH="48%" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Name:</FONT></B></TD>
            <TD WIDTH="52%" BGCOLOR="#636563">
            <INPUT NAME="name" TYPE="text" SIZE="25">
    </TD>
          </TR>
          <TR>
            <TD WIDTH="48%" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Address:</FONT></B></TD>
            <TD WIDTH="52%" BGCOLOR="#636563">
            <INPUT NAME="address" TYPE="text" SIZE="25">
    </TD>
          </TR>
          <TR>
            <TD WIDTH="48%" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">City:</FONT></B></TD>
            <TD WIDTH="52%" BGCOLOR="#636563">
            <INPUT NAME="city" TYPE="text" SIZE="25">
    </TD>
          </TR>
          <TR>
            <TD WIDTH="48%" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">State:</FONT></B></TD>
            <TD WIDTH="52%" BGCOLOR="#636563">
            <INPUT NAME="state" TYPE="text" SIZE="25">
    </TD>
          </TR>
          <TR>
            <TD WIDTH="48%" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Zip Code:</FONT></B></TD>
            <TD WIDTH="52%" BGCOLOR="#636563">
            <INPUT NAME="zipcode" TYPE="text" SIZE="25">
    </TD>
          </TR>
          <TR>
            <TD WIDTH="48%" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Order:</FONT></B></TD>
            <TD WIDTH="52%" BGCOLOR="#636563">
    <select name="order">
    <option value="doubledragonsword">Double Dragon Sword
    <option value="ninjablade">Ninja Blade
    <option value="samurai3000ninja">Samurai 3000 Ninja
    <option value="samurai3000katana">Samurai 3000 Katana
    <option value="shogunkatana">Shogun Katana
    <option value="shogunkatana">Bamboo Katana
    <option value="ramboknife">Rambo Knife
    </select>
    </TD>
          </TR>
     <TR>
            <TD WIDTH="48%" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Payment Method:</FONT></B></TD>
            <TD WIDTH="52%" BGCOLOR="#636563">
    <select name="paymentmethod">
    <option value="creditcard">Credit Card
    <option value="check">Check
    <option value="moneyorder">Money Order
    <option value="paypal">Paypal
    </select>
    </TD>
          </TR>
          <TR>
            <TD WIDTH="48%" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Email:</FONT></B></TD>
            <TD WIDTH="52%" BGCOLOR="#636563">
            <INPUT NAME="email" TYPE="text" SIZE="25">
    </TD>
    </TR>
          <TR>
            <TD COLSPAN="2" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Comments:<BR>
    	<TEXTAREA NAME="comments" ROWS="5" COLS="45"></TEXTAREA></FONT></B></TD>
          </TR>
    	<TR>
            <TD ALIGN="center" WIDTH="50%" BGCOLOR="#636563">
            <input type="submit" value="Send">
            <TD ALIGN="center" WIDTH="50%" BGCOLOR="#636563">
            <input type="reset" value="Reset">
    	</TD>
    	</TR>
    	</FORM>
        </TABLE></TD>
      </TR>
    </TABLE></CENTER></P>
    </HTML>
    Thanks everyone for the help.

  19. #19
    Join Date
    Oct 2002
    Location
    Middle Dearth
    Posts
    21,321
    <FORM METHOD="POST" ACTION="formtomail.asp">
    ASP?

  20. #20
    Join Date
    Aug 2003
    Location
    St. Louis, Missouri
    Posts
    1,814
    oops, srry. I was trying some asp script too on different server, but couldn't configure it. I used action="". I didnt put nothing in between "" when I tested the php script, that's how it said it should be on that site as well.

  21. #21
    Join Date
    Oct 2002
    Location
    Middle Dearth
    Posts
    21,321
    Originally posted by 4ulyrics
    Well I think if you use the following php script , Your form will work well.
    I disagree. There is a parse error at line 53.

  22. #22
    Join Date
    Aug 2003
    Location
    St. Louis, Missouri
    Posts
    1,814
    Yea, I had the same error from that script thats why I didnt use it. I used to have a perfect php mail script last september, but I have no idea where I found it. All of the ones I find now give some errors and I cant set them up. Next time Im going to burn that scrpt so I can have it for future, thats if I ever configure this one. lol

  23. #23
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,099
    Okay -- I think everyone missed this part :

    mail("haris3636@hotmail.com","From: $name <$email>", $subject, $msg);

    The protoype of the mail() function is
    Code:
    bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]])
    What you have up there is something else entirely. Probably why you are getting errors, since its using $msg as headers.

    Also, you have a very, very, wrong way of checking if values are submitted. If someone entered just a blank line, it would consider it set -- which is not what you want. Also, register globals is off by default on PHP installations. You cannot use $from -- you have to use $_POST['from'] (as others suggested).

    I recommend you start over -- since I have no idea what your current script looks like. There are a few tutorials that will show you how to send email. I suggest you read those first.
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

  24. #24
    Join Date
    Apr 2004
    Location
    Port St Lucie, FL
    Posts
    117
    Here's a self-submitting form, based on yours.. make sure it's named with a .php extension.

    Note the import_request_variables call - it's important. Does anyone else use it instead of the _POST method?

    PHP Code:
    <?php

    import_request_variables
    ("pg""p_");  // Import the _POST variables to $p_ variables

    if ($p_submit)
    // if the form was sent do the following

    if (!($p_name == '' || $p_address == '' || $p_city == '' || $p_state == '' ||
    $p_zipcode == '' || $p_order == '' || $p_paymentmethod == '' || $p_email == '' ||
    $p_comments == ''))
    {
        
    $subject "Order";
        
    $msg "Name: $p_name\n  Address: $p_address \n City: $p_city \n ";
        
    $msg .= "State: $p_state \n Zip Code: $p_zipcode\n Order: $p_order\n";
        
    $msg .= "Payment Method: $p_paymentmethod \n Email Address: $p_email\n\n";
        
    $msg .= "Comments: $p_comments\n";

        if (
    mail("haris3636@hotmail.com"$subject$msg))
        {
            echo 
    "Message Sent"// if all went well, display message was sent
        
    }
        else
        {
            echo (
    "Message Failed");
        }
    }
    else
    {
        echo 
    "All fields must be filled in!<BR>"// if not all were filled in, display error message
    }

    }
    else
    {
        
    // Display the form

        
    ?>
        
        
        <HTML>
    <P><CENTER><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
      <TR>
        <TD WIDTH="100%" BGCOLOR="black">
        <TABLE WIDTH="394" BORDER="0" CELLSPACING="1" CELLPADDING="2">
          <TR>
            <TD ALIGN="center" COLSPAN="2" BGCOLOR="#F9C304">
            <B><FONT COLOR="red" SIZE="-1" FACE="Verdana">Order Page</FONT></B></TD>
    <FORM METHOD="POST">
          </TR>
                <TR>
            <TD WIDTH="48%" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Name:</FONT></B></TD>
            <TD WIDTH="52%" BGCOLOR="#636563">
            <INPUT NAME="name" TYPE="text" SIZE="25">
    </TD>
          </TR>
          <TR>
            <TD WIDTH="48%" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Address:</FONT></B></TD>
            <TD WIDTH="52%" BGCOLOR="#636563">
            <INPUT NAME="address" TYPE="text" SIZE="25">
    </TD>
          </TR>
          <TR>
            <TD WIDTH="48%" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">City:</FONT></B></TD>
            <TD WIDTH="52%" BGCOLOR="#636563">
            <INPUT NAME="city" TYPE="text" SIZE="25">
    </TD>
          </TR>
          <TR>
            <TD WIDTH="48%" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">State:</FONT></B></TD>
            <TD WIDTH="52%" BGCOLOR="#636563">
            <INPUT NAME="state" TYPE="text" SIZE="25">
    </TD>
          </TR>
          <TR>
            <TD WIDTH="48%" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Zip Code:</FONT></B></TD>
            <TD WIDTH="52%" BGCOLOR="#636563">
            <INPUT NAME="zipcode" TYPE="text" SIZE="25">
    </TD>
          </TR>
          <TR>
            <TD WIDTH="48%" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Order:</FONT></B></TD>
            <TD WIDTH="52%" BGCOLOR="#636563">
    <select name="order">
    <option value="doubledragonsword">Double Dragon Sword
    <option value="ninjablade">Ninja Blade
    <option value="samurai3000ninja">Samurai 3000 Ninja
    <option value="samurai3000katana">Samurai 3000 Katana
    <option value="shogunkatana">Shogun Katana
    <option value="shogunkatana">Bamboo Katana
    <option value="ramboknife">Rambo Knife
    </select>
    </TD>
          </TR>
     <TR>
            <TD WIDTH="48%" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Payment Method:</FONT></B></TD>
            <TD WIDTH="52%" BGCOLOR="#636563">
    <select name="paymentmethod">
    <option value="creditcard">Credit Card
    <option value="check">Check
    <option value="moneyorder">Money Order
    <option value="paypal">Paypal
    </select>
    </TD>
          </TR>
          <TR>
            <TD WIDTH="48%" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Email:</FONT></B></TD>
            <TD WIDTH="52%" BGCOLOR="#636563">
            <INPUT NAME="email" TYPE="text" SIZE="25">
    </TD>
    </TR>
          <TR>
            <TD COLSPAN="2" BGCOLOR="#636563">
            <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Comments:<BR>
        <TEXTAREA NAME="comments" ROWS="5" COLS="45"></TEXTAREA></FONT></B></TD>
          </TR>
        <TR>
            <TD ALIGN="center" WIDTH="50%" BGCOLOR="#636563">
            <input type="submit" value="Send">
            <TD ALIGN="center" WIDTH="50%" BGCOLOR="#636563">
            <input type="reset" value="Reset">
        </TD>
        </TR>
        </FORM>
        </TABLE></TD>
      </TR>
    </TABLE></CENTER></P>
    </HTML>

    <?php
        
    // end php submission code
    ?>
    Paul Embry
    Knight Software and Web Design
    Paul.Embry@gmail.com
    Quality PHP Web Programming for Reasonable Prices

  25. Newsletters

    Subscribe Now & Get The WHT Quick Start Guide!

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
  •