Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Form submission - little thing  (Read 5408 times)

0 Members and 1 Guest are viewing this topic.

Psy

    Topic Starter


    Rookie
    Form submission - little thing
    « on: November 26, 2007, 04:28:31 PM »
    Hi guys.. i've made a form and am trying to get it to send it to my email..

    I have this as the form:

    Code: [Select]
    <form action="form.php" method="post">

    <h3><font color="red">Please fill in this form correctly and honestly to join our community.</font></h3>
    <font color="blue">First Name</font>:
    <input type="text" name=""
    value="" size="40">
    <br>
    <font color="blue">Login Name</font>:
    <input type="text" name=""
    value="" size="40">
    <br>
    <input type="submit" value="send mail">

    and in that it refers to a file called "form.php"

    which i have made as this:

    Code: [Select]
    <?php
    $fname
    =$_POST['firstname'];/*this line is text field name */

    //Declarate the necessary variables
    $mail_to="[email protected]";
    $mail_from="[email protected]";
    $mail_sub="Form Data";


    $mail_mesg=$fname;

    //Check for success/failure of delivery
    if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from/r/nReply-to:$mail_from"))
    echo 
    "<span class='textred'>Your Application has been sent successfully! We will get back to you within 24 hours. Regards, Psy.</span>";
    else
    echo 
    "<span class='textred'>Failed to send your application!<br>This was either caused by &bull;an internet fault, in which case, try again. or &bull;We are carrying out maintenance work, in which case, please try again later. Thankyou.</span>";



    ?>


    Now when i fill in the form and hit send, it sends an email to my account, which is great.. BUT.. all the email shows is the who it's to, who its from and the name. ie Form Data.

    There is no form results sent in the email.. how do i get them there? and why does it not send to a hotmail account but will to a gmail account?

    This is the email i get:

    Code: [Select]
         Message text garbled?
     from  @ msn. com/r/nreply-to <myemail>    hide details  23:15 (1 hour ago) 
     reply-to
     @ msn. com/r/nreply-to <meemail>,
    [email protected]   
     to  [email protected]
     date  26 Nov 2007 23:15   
     subject  Form Data   
     mailed-by  mail.jellybaby.net

    Thanks
    « Last Edit: November 26, 2007, 05:32:07 PM by Psy »
    Psy.. Genius at work!

    michaewlewis



      Intermediate
    • Thanked: 26
      • Yes
      • Yes
    • Experience: Expert
    • OS: Unknown
    Re: Form submission - little thing
    « Reply #1 on: November 27, 2007, 01:20:31 PM »
    Put this in the third line in form.php: print "$fname";
    Does it print out anything?

    Computer Hope Admin

    • Administrator


    • Prodigy

      Thanked: 248
      • Yes
      • Yes
      • Yes
      • Computer Hope
    • Certifications: List
    • Computer: Specs
    • Experience: Guru
    • OS: Windows 10
    Re: Form submission - little thing
    « Reply #2 on: November 27, 2007, 01:21:16 PM »
    It doesn't look as if you have the body specified (e.g. body of e-mail being sent). Unfortunately I'm not that familiar with PHP (I'm a Perl guy), but I'd assume it would need some type of body message section.

    Try reviewing this page and see if it helps.

    http://email.about.com/cs/phpemailtips/qt/et031202.htm
    Everybody is a genius. But, if you judge a fish by its ability to climb a tree, it will spend its whole life believing that it is stupid.
    -Albert Einstein

    Psy

      Topic Starter


      Rookie
      Re: Form submission - little thing
      « Reply #3 on: November 28, 2007, 03:38:18 PM »
      Quote
      Put this in the third line in form.php: print "$fname";
      Does it print out anything?
      No lol.

      yeah it seems like i need a body i'll try that page thanks.
      Psy.. Genius at work!

      Psy

        Topic Starter


        Rookie
        Re: Form submission - little thing
        « Reply #4 on: November 28, 2007, 03:46:48 PM »
        i tried this:

        Code: [Select]
        <?php
        $fname
        =$_POST['firstname'];/*this line is text field name */
        print "$fname";
        //Declarate the necessary variables
        $mail_to="[email protected]";
        $mail_from="[email protected]";
        $mail_sub="Form Data";
        $body "Hi,\n\nHow are you?";


        $mail_mesg=$fname;

        //Check for success/failure of delivery
        if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from"))
        echo 
        "<span class='textred'>Your Application has been sent successfully! We will get back to you within 24 hours. Regards, Psy.</span>";
        else
        echo 
        "<span class='textred'>Failed to send your application!<br>This was either caused by &bull;an internet fault, in which case, try again. or &bull;We are carrying out maintenance work, in which case, please try again later. Thankyou.</span>";



        ?>
        but it didn't work! it was basically copied from the site lol.. i also tried it with the $body = "Hi,\n\nHow are you?"; replaced as $mail_body ="Hi,\n\nHow are you?" but no lol
        « Last Edit: November 28, 2007, 04:04:01 PM by Psy »
        Psy.. Genius at work!

        Psy

          Topic Starter


          Rookie
          Re: Form submission - little thing
          « Reply #5 on: November 28, 2007, 04:00:04 PM »
          right if i enter this:

          Code: [Select]
          <?php
          $fname
          =$_POST['Name'];

          //Declarate the necessary variables
          $mail_to="[email protected]";
          $mail_from="[email protected]";
          $mail_sub="Enquiry";
          $mail_mesg="hi how are you";

          //Check for success/failure of delivery
          if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from"))
          echo 
          "<span class='textred'>Your Application has been sent successfully! We will get back to you within 24 hours. Regards, Psy.</span>";
          else
          echo 
          "<span class='textred'>Failed to send your application!<br>This was either caused by &bull;an internet fault, in which case, try again. or &bull;We are carrying out maintenance work, in which case, please try again later. Thankyou.</span>";



          ?>
          i get the message "Hi, how are you" naturally.. so where it says "mail_mesg=" i need something that will collect the data that was entered into the forms
          Psy.. Genius at work!

          michaewlewis



            Intermediate
          • Thanked: 26
            • Yes
            • Yes
          • Experience: Expert
          • OS: Unknown
          Re: Form submission - little thing
          « Reply #6 on: November 28, 2007, 04:34:05 PM »
          I decided to check out the code on my xampp server and found out the obvious. In your html form, you don't have any names for your text boxes! ::)
          Name your text boxes and try it again.

          Psy

            Topic Starter


            Rookie
            Re: Form submission - little thing
            « Reply #7 on: November 28, 2007, 04:48:21 PM »
            nope still blank lol
            Psy.. Genius at work!

            michaewlewis



              Intermediate
            • Thanked: 26
              • Yes
              • Yes
            • Experience: Expert
            • OS: Unknown
            Re: Form submission - little thing
            « Reply #8 on: November 28, 2007, 06:13:04 PM »
            make sure you're calling the same variable in your php file. If you named your text box "Name", then make sure you call it with $_POST['Name'];

            Psy

              Topic Starter


              Rookie
              Re: Form submission - little thing
              « Reply #9 on: November 28, 2007, 07:20:10 PM »
              that worked.:) cheers guys!
              Psy.. Genius at work!

              Astoria



                Intermediate

                Re: Form submission - little thing
                « Reply #10 on: December 12, 2007, 11:38:04 PM »
                Two things:

                The proper way to do an IF statement:

                if(condition) {

                statement here

                } else {

                other statement

                }


                Also, using quotes.

                Instead of double quotes:
                echo "<span> blah blah blah</span>";

                use single quotes:

                echo '<span>blah blah blah</span>';

                EXCEPT!! when you echo a variable.
                If you want to echo a line that has a variable in it, than you use double quotes.

                echo "$variable";





                michaewlewis



                  Intermediate
                • Thanked: 26
                  • Yes
                  • Yes
                • Experience: Expert
                • OS: Unknown
                Re: Form submission - little thing
                « Reply #11 on: December 13, 2007, 01:17:52 PM »
                Two things:

                The proper way to do an IF statement:

                if(condition) {

                statement here

                } else {

                other statement

                }


                Also, using quotes.

                Instead of double quotes:
                echo "<span> blah blah blah</span>";

                use single quotes:

                echo '<span>blah blah blah</span>';

                EXCEPT!! when you echo a variable.
                If you want to echo a line that has a variable in it, than you use double quotes.

                echo "$variable";

                Have you ever done any programming at all? ::)
                There's several ways to set up an if statement. You don't need the curly brackets for a one line if, else, for, or while, and it doesn't matter how it's formatted. every interpreter and compiler ignores white space anyway.
                Quotes don't matter either!
                Besides, the original poster already resolved his problem, why'd you bring it back up? ??? :P

                Astoria



                  Intermediate

                  Re: Form submission - little thing
                  « Reply #12 on: December 13, 2007, 02:21:39 PM »
                  Two things:

                  The proper way to do an IF statement:

                  if(condition) {

                  statement here

                  } else {

                  other statement

                  }


                  Also, using quotes.

                  Instead of double quotes:
                  echo "<span> blah blah blah</span>";

                  use single quotes:

                  echo '<span>blah blah blah</span>';

                  EXCEPT!! when you echo a variable.
                  If you want to echo a line that has a variable in it, than you use double quotes.

                  echo "$variable";

                  Have you ever done any programming at all? ::)
                  There's several ways to set up an if statement. You don't need the curly brackets for a one line if, else, for, or while, and it doesn't matter how it's formatted. every interpreter and compiler ignores white space anyway.
                  Quotes don't matter either!
                  Besides, the original poster already resolved his problem, why'd you bring it back up? ??? :P

                  I was trying to help... ???
                  It's a bad habit not to do your if/else staements without curly brackets, THAT'S WHY I brought it back up.
                  And FYI, yes I've done tons of programming, and from what I've seen, quotes have cause ppl's lots of headaches.

                  And in the scripts that he posted, he didn't resolve my tips.



                  michaewlewis



                    Intermediate
                  • Thanked: 26
                    • Yes
                    • Yes
                  • Experience: Expert
                  • OS: Unknown
                  Re: Form submission - little thing
                  « Reply #13 on: December 14, 2007, 10:57:46 AM »
                  It's a bad habit to think that everyone has to conform to your own coding style.
                  The guy wasn't trying to make his code look pretty, he was trying to fix his code. Your comments didn't help him solve anything.

                  Astoria



                    Intermediate

                    Re: Form submission - little thing
                    « Reply #14 on: December 14, 2007, 11:31:43 AM »
                    It's a bad habit to think that everyone has to conform to your own coding style.
                    The guy wasn't trying to make his code look pretty, he was trying to fix his code. Your comments didn't help him solve anything.


                    No, you're wrong. It's a bad habit to code scripts in a way that can lead to many mistakes.
                    I'm not trying to force my coding on anyone, and his problems were already solved when I made that post.

                    All I am trying to say is that it's better to be safe than sorry.
                    But apparently that's not allowed on this forum...at least in your opinion.