Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. PHP Form help

PHP Form help

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phplampsecurityarchitecturehelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dave McCool
    wrote on last edited by
    #1

    Hi, I have a form that I am creating for my website, and its for people to use if they find a butterfly or moth and cannot identify it. Basically what I want is for the user to fill in the form and if they have an image to send, select an image and send the message. Code I have: <form action="mailer.php" method="post" name="form1" id="form1" style="margin:0px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px; width:300px;" onsubmit="MM_validateForm('from','','RisEmail','subject','','R','verif_box','','R','message','','R');return document.MM_returnValue"> Your Name:<br /> <input name="name" type="text" id="name" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['name'];?>"/> <br /> <br /> Your e-mail:<br /> <input name="from" type="text" id="from" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['from'];?>"/> <br /> <br /> Stage:<br /> <select name="stage"> <option value="Caterpillar">Caterpillar</option> <option value="Pupa">Pupa</option> <option value="Cocoon">Cocoon</option> <option value="Adult">Cocoon</option> <option value="Leaf Mine">Leaf Mine</option> <option value="Leaf Mine Vaccated">Leaf Mine (Vaccated)</option> </select><br /> <br /> Method:<br /> <select name="method"> <option value="UV Light Trap">UV Light Trap</option> <option value="MV Lamp">Mercury Vapour Lamp</option> <option value="Tungsten Light">Tungsten Light</option> <option value="Actinic Light">Actinic light</option> <option value="Household Bulb">Household Bulb</option> <option value="Camping Lamp">Camping Lamp</option> <option value="Infrared">Infrared Light</option> <option value="LED Lights">LED Lights</option> <option value="Carlights">Car Headlights</option> <option value="Lighted Window">Attracted to Lighted Window</option> <option value="Streetlight">At street light</option> <option value="Security light">At security light</option> <option value="Torch">Found via torchlight</option> <option val

    P 1 Reply Last reply
    0
    • D Dave McCool

      Hi, I have a form that I am creating for my website, and its for people to use if they find a butterfly or moth and cannot identify it. Basically what I want is for the user to fill in the form and if they have an image to send, select an image and send the message. Code I have: <form action="mailer.php" method="post" name="form1" id="form1" style="margin:0px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px; width:300px;" onsubmit="MM_validateForm('from','','RisEmail','subject','','R','verif_box','','R','message','','R');return document.MM_returnValue"> Your Name:<br /> <input name="name" type="text" id="name" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['name'];?>"/> <br /> <br /> Your e-mail:<br /> <input name="from" type="text" id="from" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['from'];?>"/> <br /> <br /> Stage:<br /> <select name="stage"> <option value="Caterpillar">Caterpillar</option> <option value="Pupa">Pupa</option> <option value="Cocoon">Cocoon</option> <option value="Adult">Cocoon</option> <option value="Leaf Mine">Leaf Mine</option> <option value="Leaf Mine Vaccated">Leaf Mine (Vaccated)</option> </select><br /> <br /> Method:<br /> <select name="method"> <option value="UV Light Trap">UV Light Trap</option> <option value="MV Lamp">Mercury Vapour Lamp</option> <option value="Tungsten Light">Tungsten Light</option> <option value="Actinic Light">Actinic light</option> <option value="Household Bulb">Household Bulb</option> <option value="Camping Lamp">Camping Lamp</option> <option value="Infrared">Infrared Light</option> <option value="LED Lights">LED Lights</option> <option value="Carlights">Car Headlights</option> <option value="Lighted Window">Attracted to Lighted Window</option> <option value="Streetlight">At street light</option> <option value="Security light">At security light</option> <option value="Torch">Found via torchlight</option> <option val

      P Offline
      P Offline
      Peter_in_2780
      wrote on last edited by
      #2

      Briefly, you will need to add a scrap of javascript to your page. In your <form ... > add something like onsubmit="return check_fields()" Somewhere in your page (I put it in the head section) put something like

      <script type="text/javascript">
      function check_fields() {
      if (document.getElementById("xxx").checked || document.getElementById("yyy").checked)
      return true;
      alert("You must select either xxx or yyy!");
      return false;
      }
      </script>

      The function should return true if it's OK to submit. If there's something wrong, spit out an alert to say what the problem is, and return false so the form won't actually be submitted. Obviously, your checking will be more complex than this example which I ripped out of one of my sites. Cheers, Peter If this answers your question, vote for it.

      Software rusts. Simon Stephenson, ca 1994.

      D 1 Reply Last reply
      0
      • P Peter_in_2780

        Briefly, you will need to add a scrap of javascript to your page. In your <form ... > add something like onsubmit="return check_fields()" Somewhere in your page (I put it in the head section) put something like

        <script type="text/javascript">
        function check_fields() {
        if (document.getElementById("xxx").checked || document.getElementById("yyy").checked)
        return true;
        alert("You must select either xxx or yyy!");
        return false;
        }
        </script>

        The function should return true if it's OK to submit. If there's something wrong, spit out an alert to say what the problem is, and return false so the form won't actually be submitted. Obviously, your checking will be more complex than this example which I ripped out of one of my sites. Cheers, Peter If this answers your question, vote for it.

        Software rusts. Simon Stephenson, ca 1994.

        D Offline
        D Offline
        Dave McCool
        wrote on last edited by
        #3

        Thanks Peter, will try that.

        In the end we're all just the same

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups