Advertisement
lalatino

form submit

Jul 9th, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1. <?php
  2.  
  3. function process_submitted_data() {
  4.     $arr = array();
  5.     $arr['name'] = $_POST['name'];
  6.     $arr['Work Experience'] = $_POST['work_exp'];
  7.     $arr['Work Experience Max'] = $_POST['work_exp_max'];
  8.     $arr['company'] = $_POST['company'];
  9.     $arr['location'] = $_POST['location'];
  10.     var_export($arr); echo ' ... sent array <br/>';
  11.     if (trim($arr["Work Experience Max"])=='') {
  12.         $arr["Work Experience Max"] = $arr["Work Experience"];
  13.     }
  14.     echo '<br/>'; var_export($arr); echo ' ... modified array';
  15.     //file_put_contents('saved_values.php', '$arr='.var_export($arr,true).';'); //save received data to file on server
  16. }
  17.  
  18. function show_form() {
  19.     echo '<div style="margin:1em 0">';
  20.     echo '<form action="" method="post">';
  21.     echo '<input type"text" name="name" value="" > Name <br/>';
  22.     echo '<input type"text" name="work_exp" value="" > Work Exp. <br/>';
  23.     echo '<input type"text" name="work_exp_max" value="" > Work Exp. Max <br/>';
  24.     echo '<input type"text" name="company" value="" > Company <br/>';
  25.     echo '<input type"text" name="location" value="" > Location <br/>';
  26.     echo '<input type="submit" name="send" value="Send form" >';
  27.     echo '</form>';
  28.     echo '<div>';
  29. }
  30.  
  31. ?>
  32.  
  33. <html>
  34.  
  35. <body>
  36.  
  37. <h5> http://stackoverflow.com/questions/11386521/php-remove-the-value-from-array/11386984 </h5>
  38.  
  39. <?php
  40. if (isset($_POST['send'])) {
  41.     process_submitted_data();
  42. }
  43. show_form();
  44. ?>
  45.  
  46. </body>
  47. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement