Please help me to create a form...

Discussion in 'HTML & Website Design' started by lokielookies, Apr 22, 2008.

  1. #1
    I've been trying to create an 'invisable' form, where the visitor only needs to click a button to send me some information about the page he's on.
    Unfortunately, without any success :(

    Somehow, the message doesn't get sent.

    This is the code I came up with:

      <form method="post" action="MAILTO:[I]myemailaddress[/I]">
              <div>
              <input type="hidden" name="info1" value="info1" />
                <input type="hidden" name="info2" value="info2" />
              </div>
              <p align="center">
                <input type="submit" name="submit" value="submit" />
              </p>
            </form> 
    Code (markup):
    Can someone please help me out?
     
    lokielookies, Apr 22, 2008 IP
  2. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #2
    I don't think you can use mailto in that manner.

    You could use your form as is, submit it to a php page and use mail() to send it to yourself using php.

    If you do not have php there is usually some type of form mail script on the server.
     
    Colbyt, Apr 22, 2008 IP
  3. itcn

    itcn Well-Known Member

    Messages:
    795
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    118
    #3
    This would work:

    
    <form action="mailto:you@yourdmainhere.com" method="post" enctype="text/plain" >
    FirstName:<input type="text" name="FirstName">
    Email:<input type="text" name="Email">
    <input type="submit" name="submit" value="Submit">
    </form>  
    
    Code (markup):
    But it is NOT advisable. Colbyt is correct, use a server-side solution and clean/format the user input before sending it.
     
    itcn, Apr 22, 2008 IP
  4. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Actually, it should look like this: (Note that I am adding a "script" page - this is the file that will process the form and send the email - to the action attribute.)

    
    <form action="form-processor.php" id="subscription-form" method="post">
    	<div class="fieldset">
    		<fieldset>
    			<legend><span>Subscribe Via Email</span></legend>
    			<label for="first-name">First Name:</label> <input id="first-name" name="first-name"size="25" type="text"><br>
    			<label for="email">Email Address:</label> <input id="email" name="email" size="25" type="text">
    		</fieldset>
    		<input class="submit" type="submit" value="Subscribe">
    	</div>
    </form>
    
    Code (markup):
    Note that the form is written using elements that structure and identify what the form components are. The DIV and SPAN are used to get around an IE and Firefox bug. Details can be found here (I don't like the "update" since it relies on sending code to IE only) - http://www.tyssendesign.com.au/articles/legends-of-style/

    But as for the original poster's request, a server-side programming language IS required to pull this off (the programming language will gather the data about the page and the user, such as the current page, IP address, and other such information).

    lokielookies, what information are you trying to gather? (Bear in mind I'm not a server-side developer; but I can try to help nonetheless.)
     
    Dan Schulz, Apr 23, 2008 IP
  5. lokielookies

    lokielookies Well-Known Member

    Messages:
    1,246
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    150
    #5
    Thanks for the tips :)

    I want to create a button on my 404 error page that -when clicked - sends the missing page url to my mailbox.
     
    lokielookies, Apr 24, 2008 IP
  6. rhoula

    rhoula Well-Known Member

    Messages:
    875
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    145
    #6
    Did you get your form working, if not please pm me.
    Thank you
     
    rhoula, Apr 24, 2008 IP
  7. newgenservices

    newgenservices Well-Known Member

    Messages:
    862
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    105
    Digital Goods:
    1
    #7
    Easy Solution for you. I have integrated the form in this PHP page for you. This should work as a contact page. You can add / remove values as per your needs.

    mail.php

    
    <?
    //------------------------------------------------
    // File: 'mail.php' You can have this anything...
    // Func: using mail();
    //------------------------------------------------
    
    $Subject = "PHP Test E-mail";                         
    $toEmail = "your_email@here.extn";       
    
    if(submit)
    {
    mail($fromEmail, $Subject, $nMessage."\nFrom: ".$fromName."<".$fromEmail.">");
    }
    ?>
    
    <html>
    <head>
    <title>Mail Sender</title>
    <!--- You can change the Title above to something else of your choice --->
    </head>
    <body bgcolor="#FFFFFF">
    <form method="post" action="<? echo($PHP_SELF) ?>">
    Your E-mail: 
    
    <input type="text" name="fromEmail" size="25"> 
    
    Your Name: <input type="text" name="fromName" size="25"> 
    
    Your Message: 
    
    <textarea cols="50" rows="5" name="Test Message to check VPS"></textarea>
    <br>
    <input type="submit" name="Submit" />
    </form>
    
    Code (markup):
     
    newgenservices, Apr 24, 2008 IP
  8. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Actually, if it's a 404 page, just write a PHP script that acts as a custom 404 page that will automatically email you whenever it's "returned".
     
    Dan Schulz, Apr 24, 2008 IP
  9. lokielookies

    lokielookies Well-Known Member

    Messages:
    1,246
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    150
    #9
    That's what I have now.

    I just want to replace the automated report feature and have the page only sent to me when a button is clicked.
     
    lokielookies, Apr 24, 2008 IP