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. why not submit

why not submit

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phpcombeta-testingcode-review
4 Posts 3 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.
  • K Offline
    K Offline
    KARFER
    wrote on last edited by
    #1

    hi all i try to develope feedback system by php and i make two pages the first is feedback.php and this is it's code //this is feedback.php <form name="feedback" method="post" action="FeedBackCheck.php"> <table width="550" border="0" align="center" cellpadding="1" cellspacing="2"> <tr> <td colspan="2"><div align="center"> </div></td> </tr> <tr> <td width="114">&nbsp;</td> <td width="426">&nbsp;</td> </tr> <tr> <td>Name</td> <td><label> <input name="txtName" type="text" id="txtName" tabindex="0" size="54" maxlength="254" /> </label></td> </tr> <tr> <td>Subject</td> <td><label> <input name="txtSubject" type="text" id="txtSubject" tabindex="1" size="54" maxlength="254" /> </label></td> </tr> <tr> <td>Email</td> <td><label> <input name="txtEmail" type="text" id="txtEmail" tabindex="2" size="54" maxlength="254" /> </label></td> </tr> <tr> <td>Message</td> <td><label> <textarea name="txtMessage" cols="41" rows="7" id="EDITOR" tabindex="3"></textarea> </label></td> </tr> <tr> <td colspan="2"><label> <div align="center"> <input name="btnSend" type="submit" id="btnSend" tabindex="4" value="send" /> </div> </label></td> </tr> </table> </form> and the second page name FeedBackCheck.php and it's code $txtName = trim($_POST['txtName']); $txtSubject = trim($_POST['txtSubject']); $txtEmail = trim($_POST['txtEmail']); $txtMessage = trim($_POST["txtMessage"]); $txtDate = date('d-m-Y'); if ($btnSend == "send") { $to = "jameil_hamzh@yahoo.com"; $insertFe

    M 1 Reply Last reply
    0
    • K KARFER

      hi all i try to develope feedback system by php and i make two pages the first is feedback.php and this is it's code //this is feedback.php <form name="feedback" method="post" action="FeedBackCheck.php"> <table width="550" border="0" align="center" cellpadding="1" cellspacing="2"> <tr> <td colspan="2"><div align="center"> </div></td> </tr> <tr> <td width="114">&nbsp;</td> <td width="426">&nbsp;</td> </tr> <tr> <td>Name</td> <td><label> <input name="txtName" type="text" id="txtName" tabindex="0" size="54" maxlength="254" /> </label></td> </tr> <tr> <td>Subject</td> <td><label> <input name="txtSubject" type="text" id="txtSubject" tabindex="1" size="54" maxlength="254" /> </label></td> </tr> <tr> <td>Email</td> <td><label> <input name="txtEmail" type="text" id="txtEmail" tabindex="2" size="54" maxlength="254" /> </label></td> </tr> <tr> <td>Message</td> <td><label> <textarea name="txtMessage" cols="41" rows="7" id="EDITOR" tabindex="3"></textarea> </label></td> </tr> <tr> <td colspan="2"><label> <div align="center"> <input name="btnSend" type="submit" id="btnSend" tabindex="4" value="send" /> </div> </label></td> </tr> </table> </form> and the second page name FeedBackCheck.php and it's code $txtName = trim($_POST['txtName']); $txtSubject = trim($_POST['txtSubject']); $txtEmail = trim($_POST['txtEmail']); $txtMessage = trim($_POST["txtMessage"]); $txtDate = date('d-m-Y'); if ($btnSend == "send") { $to = "jameil_hamzh@yahoo.com"; $insertFe

      M Offline
      M Offline
      Marc Firth
      wrote on last edited by
      #2

      because you are trying to get a value from a submit button. to see what data has been sent from a form try this:

      <?php
      if (!empty($_POST)){
      foreach ($_POST as $key=>$value){
      $info .= $key.": ".$value."<br />";
      }
      echo $info;
      } else {
      echo "no data";
      }
      ?>

      Portfolio | Surrey Web Design, Web Hosting & IT Support

      K C 2 Replies Last reply
      0
      • M Marc Firth

        because you are trying to get a value from a submit button. to see what data has been sent from a form try this:

        <?php
        if (!empty($_POST)){
        foreach ($_POST as $key=>$value){
        $info .= $key.": ".$value."<br />";
        }
        echo $info;
        } else {
        echo "no data";
        }
        ?>

        Portfolio | Surrey Web Design, Web Hosting & IT Support

        K Offline
        K Offline
        KARFER
        wrote on last edited by
        #3

        thanks a lot Mr.Marc Firth it's working now thank you again Regrads KARFER

        -*-*-*-*-*-*-*-*-* To Be Or Not To Be (KARFER) -*-*-*-*-*-*-*-*-*

        1 Reply Last reply
        0
        • M Marc Firth

          because you are trying to get a value from a submit button. to see what data has been sent from a form try this:

          <?php
          if (!empty($_POST)){
          foreach ($_POST as $key=>$value){
          $info .= $key.": ".$value."<br />";
          }
          echo $info;
          } else {
          echo "no data";
          }
          ?>

          Portfolio | Surrey Web Design, Web Hosting & IT Support

          C Offline
          C Offline
          cjoki
          wrote on last edited by
          #4

          I would not process a post like this....I would suspect an exploit is opened this way. Instead just change the $_POST to $_POST['form_elm_name'] where form_elm_name = the value of the forms name attribute. also do not trust the users input to be harmless. If the expected value of a form is a age, then check that the post only has numbers in it php is_numeric($_POST['form_elm_name']; if it is going to be text only then I usually include a custom function to remove all non-characters from the input. This funct only permits lowercase letters a dash and a space as valid. It alse swaps all spaces for a dash.

          function clean_input($input)
          {
          $valid = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','-',' ');
          $cnt = strlen($input);
          $input = strtolower($input);
          $output='';
          for($i=0;$i<$cnt;$i++)
          {
          if(in_array($input[$i],$valid))
          {
          if($input[$i]==' ')
          {
          $output.='-';
          }
          else
          {
          $output.=$input[$i];
          }
          }
          }
          return $output;
          }

          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