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 12 of 12
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP form/email help

    Hi all,

    I'm somewhat new to the world of php and my brother has asked me to help him with his web site. i've been working on a way to send form information by e-mail. Simple enough, but for some reason it just isn't working.

    This is the form which I see no problem with.

    Code:
    <FORM action="http://www.dormpaper.com/orderform.php" method="post">
    
    <LABEL for="firstname">First Name: </LABEL><br>
    	<INPUT type="text" id="firstname"><p>
    <LABEL for="lastname">Last Name: </LABEL><br>
    	<INPUT type="text" id="lastname"><p>
    <LABEL for="email">E-mail Address: </LABEL><br>
    	<INPUT type="text" id="email"><p>
    <LABEL for="heightft">Height: </LABEL><br>
    	<INPUT type="text" id="heightft" size="5"> feet
    <LABEL for="heightin"></LABEL>
    	<INPUT type="text" id="heightin" size="5"> inches <p>
    <LABEL for="widthft">Width: </LABEL><br>
    	<INPUT type="text" id="widthft" size="5"> feet 
    <LABEL for="widthin"></LABEL>
    	<INPUT type="text" id="widthin" size="5"> inches <p>
    <LABEL for="comments">Comments: </LABEL><br>
    	<TEXTAREA id="comments" rows="10" cols="50"></TEXTAREA><p>
    <LABEL for="image">Upload Image: <LABEL>
    	<INPUT type="file" id="image"><p>
    <INPUT type="submit" value="Submit!">
    
    </FORM>
    I can't seem to figure out the problem. I've tried to take the (.) out of the ($_REQUEST['whatever']) and it hasn't worked. I think I also have the attachment wrong, it seems like too little for an attachment.

    PHP Code:
    <?php
    $to 
    "orders@dormpaper.com";
    $subject "New Order";
    $body = .$_REQUEST['firstname']."\n";
    $body .= .$_REQUEST['lastname']."\n";
    $body .= .$_REQUEST['email']."\n";
    $body .= .$_REQUEST['heightft']."\n";
    $body .= .$_REQUEST['heightin']."\n";
    $body .= .$_REQUEST['widthft']."\n";
    $body .= .$_REQUEST['widthin']."\n";
    $body .= .$_REQUEST['comments'].;
    $fileatt = .$_REQUEST['image'].;
    mail($to$subject$body$fileatt)
    ?>
    Any help would be greatly appreciated.

  • #2
    New Coder
    Join Date
    Mar 2009
    Location
    Chicago, IL
    Posts
    69
    Thanks
    0
    Thanked 15 Times in 15 Posts
    No need for dot next to $_REQUEST.

    Also you can't just include image like that, first you have to upload it and then properly add it: http://www.webcheatsheet.com/PHP/sen...attachment.php

  • #3
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I changed it, but it still doesn't seem to work. It brings me to the page, but when I check the email, it doesn't show up.


    PHP Code:
    <?php
    $to 
    "orders@dormpaper.com";
    $subject "New Order";
    $body $_REQUEST['firstname']"\n";
    $body .= $_REQUEST['lastname']"\n";
    $body .= $_REQUEST['email']"\n";
    $body .= $_REQUEST['heightft']"\n";
    $body .= $_REQUEST['heightin']"\n";
    $body .= $_REQUEST['widthft']"\n";
    $body .= $_REQUEST['widthin']"\n";
    $body .= $_REQUEST['comments'];
    mail($to$subject$body)
    ?>
    Also, after going to that page, when I click "View Source", it shows up as:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
    <BODY></BODY></HTML>
    I'm not sure if that is an issue, but I would think it is.

  • #4
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Im suprised that works surely you need a semicolon after mail($to, $subject, $body)

    to become
    PHP Code:
    mail($to$subject$body); 
    Anyway have you checked your spam folder in your email. Sometimes mail sent from a webserver without any additional headers in this way is automatically set to spam.

    You could try making a page with

    PHP Code:
    <?PHP
     mail
    ("tgold_69@yahoo.com""Hello""Hello");
    ?>
    and I'll tell you if it comes through.
    You can not say you know how to do something, until you can teach it to someone else.

  • #5
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I put the semicolon in, but it still doesn't work. I tested it and I got an e-mail, but I cannot seem to figure out why the code isn't working.

  • #6
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    try
    PHP Code:
    print_r($_REQUEST); 
    somewhere in your code to make sure the request data is working. I wonder what would happen if you tried

    PHP Code:
    mail("tgold_69@yahoo.com""hello"""); 
    in other words tried sending a mail with the body completely blank would it send? not sure.

    Try

    PHP Code:
    echo $body
    Just before the mail funtion to see if body is NULL.

    finally you can add

    PHP Code:
    if(mail($to$subject$body))
    {
     echo 
    "mail sent";
    }
    else
    {
     echo 
    "mail not sent";

    The mail function returns false if there was a problem sending your mail.
    You can not say you know how to do something, until you can teach it to someone else.

  • #7
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Ignore all that it looks like theres a syntax problem is in your code

    Your Code:
    PHP Code:
    <?php
    $to 
    "orders@dormpaper.com";
    $subject "New Order";
    $body $_REQUEST['firstname']"\n";
    $body .= $_REQUEST['lastname']"\n";
    $body .= $_REQUEST['email']"\n";
    $body .= $_REQUEST['heightft']"\n";
    $body .= $_REQUEST['heightin']"\n";
    $body .= $_REQUEST['widthft']"\n";
    $body .= $_REQUEST['widthin']"\n";
    $body .= $_REQUEST['comments'];
    mail($to$subject$body)
    ?>
    Correction

    PHP Code:
    <?php
    $to 
    "orders@dormpaper.com";
    $subject "New Order";
    $body $_REQUEST['firstname']."\n";
    $body .= $_REQUEST['lastname']."\n";
    $body .= $_REQUEST['email']."\n";
    $body .= $_REQUEST['heightft']."\n";
    $body .= $_REQUEST['heightin']."\n";
    $body .= $_REQUEST['widthft']."\n";
    $body .= $_REQUEST['widthin']."\n";
    $body .= $_REQUEST['comments'];
    mail($to$subject$body)
    ?>
    Its the dots you need after the requests.

    I guess you must have error reporting turned off on your server or it would show you your syntax problems.
    Last edited by timgolding; 03-22-2009 at 08:11 PM.
    You can not say you know how to do something, until you can teach it to someone else.

  • #8
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried that and it still does not work for some reason. COuld it have somethign to do with the form.

  • #9
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Sorry i missed the semi colon after the mail again

    try this

    PHP Code:
    <?php
    $to 
    "orders@dormpaper.com";
    $subject "New Order";
    $body $_REQUEST['firstname']."\n";
    $body .= $_REQUEST['lastname']."\n";
    $body .= $_REQUEST['email']."\n";
    $body .= $_REQUEST['heightft']."\n";
    $body .= $_REQUEST['heightin']."\n";
    $body .= $_REQUEST['widthft']."\n";
    $body .= $_REQUEST['widthin']."\n";
    $body .= $_REQUEST['comments'];
    mail($to$subject$body);
    ?>
    You can not say you know how to do something, until you can teach it to someone else.

  • #10
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    actually the form is wrong also
    should be
    Code:
    <FORM action="http://www.dormpaper.com/orderform.php" method="post">
    
    <LABEL for="firstname">First Name: </LABEL><br>
    	<INPUT type="text" id="firstname" name="firstname"><p>
    <LABEL for="lastname">Last Name: </LABEL><br>
    	<INPUT type="text" name="lastname" id="lastname"><p>
    <LABEL for="email">E-mail Address: </LABEL><br>
    	<INPUT type="text" id="email" name="email"><p>
    <LABEL for="heightft">Height: </LABEL><br>
    	<INPUT type="text" id="heightft" size="5" name="heightft"> feet
    <LABEL for="heightin"></LABEL>
    	<INPUT type="text" id="heightin" size="5" name="heightin"> inches <p>
    <LABEL for="widthft">Width: </LABEL><br>
    	<INPUT type="text" id="widthft" size="5" name="widthft"> feet 
    <LABEL for="widthin"></LABEL>
    	<INPUT type="text" id="widthin" size="5" name="widthin"> inches <p>
    <LABEL for="comments">Comments: </LABEL><br>
    	<TEXTAREA id="comments" rows="10" cols="50" name="comments"></TEXTAREA><p>
    <LABEL for="image">Upload Image: <LABEL>
    	<INPUT type="file" id="image"><p>
    <INPUT type="submit" value="Submit!">
    
    </FORM>
    You need the name attribute for all the form elements to pass it on through post.
    You can not say you know how to do something, until you can teach it to someone else.

  • #11
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't know why but it still is not working. It's very frustrating, but thank you for your help so far. I'll take break from it and play aorund with it later on.

  • #12
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Did you add print_r($_REQUEST); and also since you know the data is coming from the POST method why not change all the $_REQUEST's to $_POST's?


  •  

    Posting Permissions

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