Web Hosting Vodahost    

Home Take The Royal Tour! Order Now Features Prices
Go Back   Web Hosting > BlueVoda Website Builder Forums > Forms

Notices

Forms Discussion and help related to designing and implementing forms in the BlueVoda Website Builder.

Reply
 
LinkBack Thread Tools
  #1  
Old 09-17-2007, 04:07 AM
Aliens Anonymous's Avatar
The Night Watchman
 
Join Date: Jan 2006
Location: Dark side of the moon
Posts: 1,189
Cool Generated Form

I have been messing about with the idea of having a web site form generator, it is generating the forms ok and when you use them everything looks ok, you get pass to the thankyou page, the problem is no email is recieved i thought that it was not sending any but after checking my web mail on the server their they all are siting their with Mail delivery failed: returning message to sender this is the script for the form is it possible that the generator is getting something wrong as in the Mail delivery failed: returning message to sender the Email address has changed. Thanks

PHP Code:
<?php
 $comments_textarea_1 
"<text";
 
$comments_textarea_2 'area name="comments" cols="60" rows="6">';
 
$end_textarea_1 "</text";
 
$end_textarea_2 "area>";
 if (!
function_exists('str_split')) {
  function 
str_split($string$split_length 1) {
   return 
explode("\r\n"chunk_split($string$split_length));
  }
 }
 
 function 
generateDropDown($values,$value_selected) {
  
$value_array explode(',',$values);
  
$i 0;
  while (
$value_array[$i] != '') {
   if (
$value_array[$i] == $value_selected) {
    
$selected ' selected ';
   } else {
    
$selected '';
   }
   
$options .= '<option value="' $value_array[$i] . '" ' $selected '>' $value_array[$i] . '</option>';
   
$i++;
  }
  return 
$options;
 }
 
 function 
checkValidChars($string,$valid_chars) {
  
$string_array str_split($string);
  
$valid_chars_array str_split($valid_chars);
  
$i 0;
  while (
$string_array[$i] != '') {
   if (!
in_array($string_array[$i],$valid_chars_array)) {
    return 
false;
   }
   
$i++;
  }
  return 
true;
 }
 
 function 
getResultDiv($value,$type='error') {
  
// Formats successful or error results whether they are in an array or a snippet.
  
if ($type == 'success') {
   
$class 'success-div';
  } elseif (
$type == 'test') {
   
$class 'test-div';
  } else {
   
$class 'error-div';
  }
  if (
is_array($value)) {
   for (
$i 0$value[$i] != ''$i++) {
    
$result_div .= '<li>' $value[$i] . '</li>';
   }
   if (
$result_div != '') {
    
$result_div '<div class="' $class '"><ul>' $result_div '</ul></div>';
   }
  } else {
   if (
$value != '') {
    
$result_div '<div class="' $class '">' $value '</div>';
   }
  }
  return 
$result_div;
 }
 function 
getValidation($add_edit,$name,$msg,$type,$value='') {
  global 
$edit_action;
  global 
$add_action;
  global 
$error_div;
  global 
$_POST;
  global 
$_GET;
  if  (
$_POST['action'] == "submit_form") {
   
$do 1;
  } 
  
// No value
  
if ($type == 'novalue') {
   if (
$do == 1) {
    if (
strlen($_POST[$name]) < '1') {
     
$error_div .= getResultDiv($msg);
    }
   }
   
$js_clause 'form.' $name '.value == ""';
   return 
jsCheck($js_clause,$msg,$name);
  }
  
  
// Number is less than
  
if ($type == 'less_than') {
   if (
$do == 1) {
    if (
$_POST[$name] < $value) {
     
$error_div .= getResultDiv($msg);
    }
   }
   
$js_clause 'form.' $name '.value < ' $value;
   return 
jsCheck($js_clause,$msg,$name);
  }
  
  
// Number is greater than
  
if ($type == 'greater_than') {
   if (
$do == 1) {
    if (
$_POST[$name] > $value) {
     
$error_div .= getResultDiv($msg);
    }
   }
   
$js_clause 'form.' $name '.value > ' $value;
   return 
jsCheck($js_clause,$msg,$name);
  }
  
  
// Value equals
  
if ($type == 'equals') {
   if (
$do == 1) {
    if (
$_POST[$name] == $value) {
     
$error_div .= getResultDiv($msg);
    }
   }
   
$js_clause 'form.' $name '.value == ' $value;
   return 
jsCheck($js_clause,$msg,$name);
  }
  
  
// Less Than String Length
  
if ($type == 'strlen_less') {
   if (
$do == 1) {
    if (
strlen($_POST[$name]) < $value) {
     
$error_div .= getResultDiv($msg);
    }
   }
   
$js_clause 'form.' $name '.value.length < ' $value;
   return 
jsCheck($js_clause,$msg,$name);
  }
  
  
// String Length
  
if ($type == 'strlen') {
   if (
$do == 1) {
    if (
strlen($_POST[$name]) != $value) {
     
$error_div .= getResultDiv($msg);
    }
   }
   
$js_clause 'form.' $name '.value.length != ' $value;
   return 
jsCheck($js_clause,$msg,$name);
  }
  
  
// Zip Code
  
if ($type == 'zip') {
   
$valid_chars "0123456789";
   if (
$do == 1) {
    if (
strlen($_POST[$name]) != 5) {
     
$error_div .= getResultDiv('Please enter 5 digits for the zip code');
    } elseif (!
checkValidChars($_POST[$name],$valid_chars)) {
     
$error_div .= getResultDiv('Please enter only digits for the zip code');
    }
   }
   
$js_clause_1 'form.' $name '.value.length != 5';
   
$js_clause_2 '!ValidChars(form.' $name '.value,"' $valid_chars '")';
   return 
    
jsCheck($js_clause_1,'Please enter 5 numbers for the zip code',$name) . 
    
jsCheck($js_clause_2,'Please enter only numbers in the zip code',$name);
  }
  
  
// Price
  
if ($type == 'price') {
   
$valid_chars "0123456789.,";
   
   if (
$do == 1) {
    
$post_value str_replace(',','',$_POST[$name]);
    if (!
checkValidChars($post_value,$valid_chars)) {
     
$error_div .= getResultDiv('Please enter only a number for ' $msg);
    } elseif (
strlen($post_value) > $value) {
     
$error_div .= getResultDiv('Please enter a smaller value for ' $msg);
    }
   }
   
$js_clause_1 'form.' $name '.value.length > ' $value;
   
$js_clause_2 '!ValidChars(form.' $name '.value,"' $valid_chars '")';
   return 
    
jsCheck($js_clause_1,'Please enter no more than ' $value ' characters for ' $msg,$name) . 
    
jsCheck($js_clause_2,'Please enter only numbers for ' $msg,$name);
  }
  
  
// Number
  
if ($type == 'number') {
   
$valid_chars "0123456789";
   if (
$do == 1) {
    
$post_value str_replace(',','',$_POST[$name]);
    if (!
checkValidChars($post_value,$valid_chars)) {
     
$error_div .= getResultDiv('Please enter only a number for ' $msg);
    } elseif (
strlen($post_value) > $value) {
     
$error_div .= getResultDiv('Please enter a smaller value for ' $msg);
    }
   }
   
$js_clause_1 'form.' $name '.value.length > ' $value;
   
$js_clause_2 '!ValidChars(form.' $name '.value,"' $valid_chars '")';
   return 
    
jsCheck($js_clause_1,'Please enter no more than ' $value ' numbers for ' $msg,$name) . 
    
jsCheck($js_clause_2,'Please enter only numbers for ' $msg,$name);
  }
  
  
// Phone Number
  
if ($type == 'phone') {
   
$valid_chars "0123456789-() ";
   
$value 7;
   if (
$do == 1) {
    if (!
checkValidChars($_POST[$name],$valid_chars)) {
     
$error_div .= getResultDiv('Please enter only a phone number for ' $msg);
    } elseif (
strlen($post_value) > $value) {
     
$error_div .= getResultDiv('Please enter a smaller value for ' $msg);
    }
   }
   
$js_clause_1 'form.' $name '.value.length < ' $value;
   
$js_clause_2 '!ValidChars(form.' $name '.value,"' $valid_chars '")';
   return 
    
jsCheck($js_clause_1,'Please enter no more than ' $value ' numbers for the phone number',$name) . 
    
jsCheck($js_clause_2,'Please enter a valid phone number',$name);
  }
  
  
  
// Password
  
if ($type == 'password') {
   
$valid_chars "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   if (
$do == 1) {
    if (!
checkValidChars($_POST[$name],$valid_chars)) {
     
$error_div .= getResultDiv('Please enter only alpha-numeric values for ' $msg);
    } elseif (
strlen($_POST[$name]) < $value || $_POST[$name] == '') {
     
$error_div .= getResultDiv($msg ' must be at least 6 characters long');
    }
   }
   
$js_clause_1 'form.' $name '.value.length < ' $value ' && ' ' form.' $name '.value.length > 0';
   
$js_clause_2 '!ValidChars(form.' $name '.value,"' $valid_chars '")';
   return 
    
jsCheck($js_clause_1,$msg ' must be at least 6 characters long',$name) . 
    
jsCheck($js_clause_2,'Please enter only alpha-numeric values for ' $msg,$name);
  }
  
  
// Duplicate
  
if ($type == 'duplicate') {
   if (
$do == 1) {
    
$value_array explode(':',$value);
    
$table $value_array[0];
    
$column $value_array[1];
    
$content $_POST[$name];
   }
  }
  
 }
 
 function 
jsCheck($clause,$msg,$name) {
  return 
'
   if (' 
$clause ') {
    alert( "' 
$msg '" );
    form.' 
$name '.focus();
    return false;
   }
  '
;
 }
 
 
$subject_options generateDropDown("",$_POST['subject']);
 
 
$email['to'] = "aliendude@angies-cyberscriptes.org";
 
$email['subject_prefix'] = "contact form";
 
 
 if (
$_POST['action'] == 'submit_form') {
  
     if (
strlen($_POST['fullname']) < 1) {
      
$error_div .= getResultDiv('Please enter a value for your name');
     }
     if (
strlen($_POST['email']) < 1) {
      
$error_div .= getResultDiv('Please enter a value for your email address');
     }
     if (
strlen($_POST['phone']) < 6) {
      
$error_div .= getResultDiv('Please enter a valid phone number (too short) ');
     }
    
    
$valid_chars "0123456789-() ";
    if (!
checkValidChars($_POST['phone'],$valid_chars)) {
      
$error_div .= getResultDiv('Please enter a valid (numbers, dashes and parenthesis) ');
    }
     if (
strlen($_POST['company']) < 2) {
      
$error_div .= getResultDiv('Please enter your company name');
     }
     if (
strlen($_POST['comments']) < 10) {
      
$error_div .= getResultDiv('Please enter 10 or more characters for the comments');
     }
  
$result_div .= $error_div;
  if (
$error_div == '') {
   if (
strlen($_POST["subject"] ) > 1) {
    
$message .= "SUBJECT: " $_POST["subject"] . "\n";
   }
   if (
strlen($_POST["fullname"]) > 1) {
    
$message .= "FROM: " $_POST["fullname"] . "\n";
   }
   if (
strlen($_POST["email"]) > 1) {
    
$message .= "EMAIL: " $_POST["email"] . "\n";
   }
   if (
strlen($_POST["phone"] ) > 1) {
    
$message .= "PHONE: " $_POST["phone"] . "\n";
   }
   if (
strlen($_POST["company"] ) > 1) {
    
$message .= "COMPANY: " $_POST["company"] . "\n";
   }
   if (
strlen($_POST["address"] ) > 1) {
    
$message .= "Address: " $_POST["address"] . "  " .  $_POST["address_2"] . "  " $_POST["city"] . ", " $_POST["state"] . " " $_POST["zip"] . "\n";
   }
   if (
strlen($_POST["comments"] ) > 1) {
    
$message .= "COMMENTS:\n" $_POST["comments"] . "\n\n";
   }
   
$message "Below is the information submitted to your online Contact form on " date('F j, Y') . " at " date('j:i a') . ":\n\n" $message;
   
   if (
mail($email['to'],$email['subject_prefix'] . $_POST['subject'], $message"From: " $_POST['email'])) {
    
header("Location: results.php");
   }
  } else {
   
$form $_POST;
  }
 } 
 
?>
 <html>
 <head>
  <style>
   .required {
    font-weight:bold;
    color:red;
   }
   
   .error-div {
    border:1px solid #FF0000;
    background-color:#FFDEDE;
    padding:10px;
    margin-bottom:5px;
    color:#CC0000;
   }
   
   .success-div {
    border:1px solid #09BD00;
    background-color:#EEFFED;
    padding:10px;
    margin-bottom:5px;
    color:#006600;
   }
  </style>
  <script language="JavaScript" type="text/javascript">
  
  
  var IE = (document.all) ? 1 : 0;
var DOM = 0; 
if (parseInt(navigator.appVersion) >=5) {DOM=1};
        function txtShow( cId, txt2show ) {
            // Detect Browser
            if (DOM) {
       var viewer = document.getElementById(cId);
              viewer.innerHTML=txt2show;
            } else if(IE) {
               document.all[cId].innerHTML=txt2show;
            }
        }//txtshow
        
        function getTxt( cId ) {
            var output = "";
            // Detect Browser
            if (DOM) {
  var viewer = document.getElementById(cId);
  output = viewer.value;
            }
            else if(IE) {
                output = document.all[cId].value;
            }
            return output;
        }//getTxt
  
  function countChars(cBoxName, cTxtName, maxKeys) {
   var str = new String(getTxt(cBoxName));
   var len = str.length;
   var showstr = '<span class="alert-pos">' + len + ' characters of ' + maxKeys + ' entered</span>';
   if (len > maxKeys) showstr = '<span class="alert">' + len + ' characters of ' + maxKeys + ' entered</span><br /><span class="alert">Too many characters, please edit content</span>';
   txtShow( cTxtName, showstr );
  }
  
  function ValidChars(sText,ValidChars) {
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) { 
    Char = sText.charAt(i); 
    if (ValidChars.indexOf(Char) == -1)  {
     IsNumber = false;
    }
   }
   return IsNumber;
  }
  
  function checkform (form) {
   
   if (form.fullname.value == "") {
    alert( "Please enter your full name" );
    form.fullname.focus();
    return false;
   }
  
   if (form.email.value.length < 5) {
    alert( "Please enter your email" );
    form.email.focus();
    return false;
   }
  
   if (form.phone.value.length < 6) {
    alert( "Please enter a valid phone number" );
    form.phone.focus();
    return false;
   }
  
   if (!ValidChars(form.phone.value,"0123456789-() ")) {
    alert( "Please enter only a phone number for Please enter your phone number" );
    form.phone.focus();
    return false;
   }
  
   if (form.company.value == "") {
    alert( "Please enter your company name" );
    form.company.focus();
    return false;
   }
  
   if (form.comments.value.length < 10) {
    alert( "Please enter 10 or more characters for the comments" );
    form.comments.focus();
    return false;
   }
  
  }
  </script>
  <title>contact form</title>
 </head>
 <body>
  <?php echo $result_div?>
  <h1>contact form</h1>
  <form action="contact.php" onSubmit="return checkform(this);" method="post">
   <input type="hidden" name="action" value="submit_form" />
   <table>
    <tr>
     <td><span class="required">*</span>Full Name: </td>
     <td><input type="text" name="fullname" value="<?php echo $form['fullname']; ?>" size="40" /></td>
    </tr>
    <tr>
     <td><span class="required">*</span>E-mail: </td>
     <td><input type="text" name="email" size="40" value="<?php echo $form['email']; ?>" /></td>
    </tr>
    <tr>
     <td><span class="required">*</span>Phone: </td>
     <td><input type="text" name="phone" size="40" value="<?php echo $form['phone']; ?>" /></td>
    </tr>
    <tr>
     <td><span class="required">*</span>Company: </td>
     <td><input type="text" name="company" size="40" value="<?php echo $form['company']; ?>" /></td>
    </tr>
    <tr>
     <td><span class="required">*</span>Comments: </td>
     <td><?php echo $comments_textarea_1 $comments_textarea_2?><?php echo $form['comments']; ?><?php echo $end_textarea_1 $end_textarea_2?></td>
    </tr>
   </table>
    <input type="submit" value="Submit Contact Form" />
  </form>
 </body>
 </html>
__________________
Angies CyberScripts
Web Designs by the Boom Crew
The Showcase Now Closed
PhpBB and web design
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old 09-17-2007, 04:16 AM
Karen Mac's Avatar
General & Forum Moderator
 
Join Date: Apr 2006
Posts: 4,486
Send a message via MSN to Karen Mac
Default Re: Generated Form

Im not sure it has anything to do with the form not working, but,

Quote:
<form action="contact.php" onSubmit="return checkform(this);" method="post">
<input type="hidden" name="action" value="submit_form" />
I dont think you need the HIDDEN, and i would think it would need to be named Contact the same as your action. Try removing it and/or changing it to the same name.

Karen
__________________
KMAC Enterprise
Granny's Country Nook 10%Off, your code: Forum Discounts
Charming Noveltees~Sports Logos Charms, Jewelry, Collectibles- 10% off, your code: VodaHost
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 02:56 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC7
2005-2009 VodaHost Web Hosting Your Perfect Web Host - All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176