Announcement

Collapse
No announcement yet.

Creating a form inside a html / php module

Collapse
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Creating a form inside a html / php module

    Hey there,

    I'm using vB 5.4.0.
    I've got a little problem and it'd be great if someone could give me a nudge in the right direction.
    I want to create a form for users to fill out which will be sent to my email box.

    I added the code inside a HTML module and it works perfectly. I receive the email and all is well.

    BUT I need to know the username of the person who filled out the form. I've tried a lot of things (including somehow using a PHP module - which doesn't work because of Java) but nothing has worked so far.

    Any idea is welcome!
    Thanks in advance!


    This is the code of the form:

    Code:
    <html> 
    <head> 
    <script language="Javascript"> 
    <!-- Start 
    function update_choice() 
    { 
       var categorychoice = document.forms.emailform.category; 
       var subcategorychoice = document.forms.emailform.subcategory; 
    
       subcategorychoice.options.length = 0; 
    
    
       if (categorychoice.options[categorychoice.selectedIndex].value == "Option1") 
       { 
    
          subcategorychoice.options[1] = new Option("Sub-option 1"); 
          subcategorychoice.options[2] = new Option("Sub-option 2"); 
          subcategorychoice.options[3] = new Option("Sub-option 3"); 
          subcategorychoice.options[4] = new Option("Sub-option 4"); 
    
       } 
       else if (categorychoice.options[categorychoice.selectedIndex].value == "Option2") 
       { 
    
          subcategorychoice.options[1] = new Option("Sub-option 1"); 
          subcategorychoice.options[2] = new Option("Sub-option 2"); 
          subcategorychoice.options[3] = new Option("Sub-option 3"); 
          subcategorychoice.options[4] = new Option("Sub-option 4"); 
       } 
    } 
    // End --> 
    </script> 
    
    
    </head> 
    
    <body> 
    <form name="emailform" action="formmail.php" target="_self" method="post">
    <input type="hidden" name="access" value="irregeheim"> 
    <select size="1" name="category" required onChange="update_choice()"> 
    <option value="" selected></option> 
    <option value="Option1">Option 1</option> 
    <option value="Option2">Option 2</option> 
    </select> 
    <br> 
    <br> 
    <select size="1" required name="subcategory"> 
    <option value="" selected></option> 
    </select> 
    <br><br>
     <input type="text" placeholder="Name" id="name" required name="name">
     <button type="submit">SEND</button>
    </form> 
    </body> 
    </html>
    And the code of the formmail.php

    PHP Code:
    <?php
    $recipient 
    "[email protected]";
    $fmtResponseimplode(""file("../../response.php"));
    $fmtMailimplode(""file("mail.htt"));
    foreach(
    $_POST as $key=> $val) {
    $fmtResponsestr_replace("<$key>"$val$fmtResponse);
    $fmtMailstr_replace("<$key>"$val$fmtMail);
    }
    if (
    $_POST["access"] == "irregeheim") {
    mail($recipient$_POST["subject"], $fmtMail);
    }
    echo 
    $fmtResponse;
    ?>

    #2
    Why don't you just use Notice? In notices, you can use the {username} placeholder to show the username of the user.
    Helpful? Donate. Thanks!
    Buy me a coffeePayPal QR Code
    Fast VPS Host for vBulletin:
    A2 Hosting & IONOS

    Comment


    • Prescott
      Prescott commented
      Editing a comment
      Wow! Thank you so much! It finally works.

    • glennrocksvb
      glennrocksvb commented
      Editing a comment
      Glad to help

Users Viewing This Page

Collapse

There is 1 user viewing this forum topic.

  • Guest Guest

Latest Posts

Collapse

Working...
X
Searching...Please wait.
An unexpected error was returned: 'Your submission could not be processed because you have logged in since the previous page was loaded.

Please push the back button and reload the previous window.'
An unexpected error was returned: 'Your submission could not be processed because the token has expired.

Please push the back button and reload the previous window.'
An internal error has occurred and the module cannot be displayed.
There are no results that meet this criteria.
Search Result for "|||"