Announcement

Collapse
No announcement yet.

Advanced Form Needed Javascript

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

  • Advanced Form Needed Javascript

    Okay, I need a script (written in JS) that will process a form...

    Here is the catch:
    I am going to have a pulldown menu that has names... When a person is selected, I want the script to send the form to that person. The other components will be title and body (for the message) I want it to appear just like an email too in the person's email box... With a Title, and a body.

    Why I want it: Because I don't want to use the mailto: command because I don't want bots to get my email adresses. Already had it happen once... Just make the script vague because I know a little JS. I will be able to edit the emal adresses in the script and the names.

    Thanks in advance...
    Comments and suggestions are welcome as well.

  • #2
    Re: Advanced Form Needed Javascript

    You don't neeed Javascript for that, just a slightly modified php script and a very easy to build BV form. F.e. you can use the script described in BlueVoda Form Tutorial 1 modified as follows:

    <?PHP
    $email = $HTTP_POST_VARS[Email];
    $mailto = $HTTP_POST_VARS[Person];
    $mailsubj = $HTTP_POST_VARS[Subject];
    $Message = $HTTP_POST_VARS[Message];
    $mailhead = "From: $email\n";
    $mailbody = "$Message\n"
    . "\n"
    . "Email sent through our Web Mail form\n"
    ;

    mail($mailto, $mailsubj, $mailbody, $mailhead);
    ?>


    I have used the colors only to show you which are the variables that will be passed over to the php script from the form.
    Now, in your form page, include a listbox or combobox with the names of the persons that the emails need to go to. For each one, the value will be his email address. The listbox has to be named "Person", the various items will be the persons, and the respective values will be their email addresses.

    Now the form must also have a text field for the subject, named "Subject" , a textarea box, for the body message, named "Message" and eventually a text field , called "Email" for the email of the person that is sending. This email will also appear as the "From" in the message received.

    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

    Comment


    • #3
      Re: Advanced Form Needed Javascript

      okay... I don't want the persons email on my page at all. I want the script to read the name and convert it. ( I know how to write this in basic, but not in php) I need like a
      This Name -> me@google.com
      In the script.

      Comment


      • #4
        Re: Advanced Form Needed Javascript

        It can also be done very easily. But, as with all hardcoded variables, if in the future you want to make any changes, you will need to change the script accordingly. Here is how you should do it: the script becomes:

        <?PHP
        $email = $HTTP_POST_VARS[email];
        $Person = $HTTP_POST_VARS[Person];
        if ($Person == "John Smith") {
        $mailto = "johnsmith@yourdomain.com";
        }
        if ($Person == "George Smith") {
        $mailto = "georgesmith@yourdomain.com";
        }
        // repeat the above If statement as many times as the persons
        $mailsubj = $HTTP_POST_VARS[Subject];
        $Message = $HTTP_POST_VARS[Message];
        $mailhead = "From: $email\n";
        $mailbody = "$Message\n"
        . "\n"
        . "Email sent through our Web Mail form\n" ;
        mail($mailto, $mailsubj, $mailbody, $mailhead);
        ?>

        Another way would be to have a file with all the names and emails, then the script would read the name and lookup the respective email address. Then you could also have an interface to allow you to easily add or delete names without scripting, just using a form to update this file. But since you don't know php, this goes beyond what you could easily do.

        In the form, the drop down list with the names (or the departments) needs to have as items the Names, and as values the names again. When you add a name in the form dropdown, you need to also add it in the script and reupload it.
        Navaldesign
        Logger Lite: Low Cost, Customizable, multifeatured Login script
        Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
        DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
        Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

        Comment


        • #5
          Re: Advanced Form Needed Javascript

          Sorry about bringing bak a dead thread, but I am getting this error... Help naval design.


          Notice: Use of undefined constant email - assumed 'email' in C:\Sites\www.orrita.com\new\emails.php on line 2

          Notice: Undefined index: email in C:\Sites\www.orrita.com\new\emails.php on line 2

          Notice: Use of undefined constant Person - assumed 'Person' in C:\Sites\www.orrita.com\new\emails.php on line 3

          Notice: Use of undefined constant Subject - assumed 'Subject' in C:\Sites\www.orrita.com\new\emails.php on line 89

          Notice: Use of undefined constant Message - assumed 'Message' in C:\Sites\www.orrita.com\new\emails.php on line 90

          Notice: Undefined variable: mailto in C:\Sites\www.orrita.com\new\emails.php on line 95

          Warning: mail(): SMTP server response: 554 Error: no valid recipients in C:\Sites\www.orrita.com\new\emails.php on line 95

          Comment


          • #6
            Re: Advanced Form Needed Javascript

            Are you trying to use a php script directly from your computer ? Unless you have installed on your computer a php/apache encironment, you can't do that. This is a server side script and you need to test it on the server.

            Please clarify what are you excactly doing.
            Navaldesign
            Logger Lite: Low Cost, Customizable, multifeatured Login script
            Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
            DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
            Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

            Comment


            • #7
              Re: Advanced Form Needed Javascript

              no, it's on my server...

              Now I am getting only this error...

              Parse error: parse error, unexpected $end in C:\Sites\www.orrita.com\emails.php

              Comment


              • #8
                Re: Advanced Form Needed Javascript

                <?php
                if (isset($_POST['email']) && isset($_POST['Person']) && isset($_POST['Message']) && isset($_POST['Subject'])) {
                $email = $_POST['email'];
                $Person = $_POST['Person'];
                if (
                $Person == "John Smith") {
                $mailto = "johnsmith@yourdomain.com";
                }
                if (
                $Person == "George Smith") {
                $mailto = "georgesmith@yourdomain.com";
                }
                $mailsubj = $_POST['Subject'];
                $Message = $_POST['Message'];
                $mailhead = "From: $email\n";
                $mailbody = "$Message\n\nEmail sent through our Web Mail form\n" ;
                mail($mailto, $mailsubj, $mailbody, $mailhead);
                }
                ?>

                This is what I changed it too... What is wrong with this... That is what the error is now...

                Comment

                Working...
                X