Search the Community
Showing results for tags 'phpform'.
-
<?php if(isset($_POST['txtEmail'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "xyz@abc.com"; $email_subject = "Subject"; $email_from = "abc@xyz.com"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below."; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['txtName']) || !isset($_POST['txtEmail']) || !isset($_POST['txtAddress']) || !isset($_POST['txtContact']) || !isset($_POST['txtUpload'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $name = $_POST['txtName']; // required $email = $_POST['txtEmail']; // required $address = $_POST['txtAddress']; // required $contact = $_POST['txtContact']; // not required $upload = $_POST['txtUpload']; // required $email_message = "Form Details are below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Full Name: ".clean_string($name)."\n\n"; $email_message .= "Address: ".clean_string($address)."\n\n"; $email_message .= "Email ID: ".clean_string($email)."\n\n"; $email_message .= "Contact No.: ".clean_string($contact)."\n\n"; $email_message .= "File: ".clean_string($upload)."\n\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <?php } ?> i am a rookie in php I got 2 problems 1) I am not able to insert a code for file upload in the above code. 2) In other type of form (with different textfields).i have a text (it is like a disclaimer) in the html form which i want it in email too.
-
Validation of my PHP form is not working. Here is the code that i used in my form. The data is storing in DB but validation alone not working. After submitting the form i checked the error console, its simply showing 'Type Error document.getElementById('..')null'. i don't know wht it is and how to fix this error. please help me. I am new in this php field so don't mind my mistakes. <html> <body> <script> function art_category() { document.getElementById('halloween_website_directory1').style.display = "none"; document.getElementById('hallo_web_name1').style.display = "none"; document.getElementById('hallo_web_desc1').style.display = "none"; document.getElementById('hallo_web_tags1').style.display = "none"; document.getElementById('msgpost1').style.display = "none"; if(document.getElementById('halloween_website_directory').value=="") { document.getElementById('halloween_website_directory1').style.display = "block"; return false; } else if(document.getElementById('hallo_art_name').value=="") { document.getElementById('hallo_art_name1').style.display = "block"; return false; } else if(document.getElementById('hallo_art_desc').value=="") { document.getElementById('hallo_art_desc1').style.display = "block"; return false; } else if(document.getElementById('hallo_art_tags').value=="") { document.getElementById('hallo_art_tags1').style.display = "block"; return false; } else if(document.getElementById('msgpost').value=="") { document.getElementById('msgpost1').style.display = "block"; return false; } else { document.artcategory.submit(); return true; } } </script> <form name="artcategory" id="artcategory" method="post" enctype="multipart/form-data" onSubmit="return art_category();"> <table align="center" width="69%" height="75%" border="0" bordercolor="#663300";> <tr style="width:60px; height:60px;"> <td width="33%" height="60%" style="color:#FFFFFF;"><p align="center"><FONT SIZE="-1" FACE="Verdana">Select Category:<span style="color:#FF0000;">*</span></FONT></p> </td> <td width="67%" height="60%"> <select name="halloween_website_directory" id="halloween_website_directory"> <option value="">Select Website Category</option> <?PHP $web_cat = mysql_query("SELECT * FROM halloween_website_directory ORDER BY web_cat_name;"); while($cat = mysql_fetch_array($web_cat)) { ?> <option value="<?PHP echo $cat['web_cat_id'] ?>"><?PHP echo $cat['web_cat_name'] ?></option> <?PHP } ?> </select> <span id="halloween_website_directory1" style="color:#FF0000; display:none;">* Select Category</span> </td> </tr> <tr style="width:60px; height:60px;"> <td width="33%" height="60%" style="color:#FFFFFF;"><p align="center"><FONT SIZE="-1" FACE="Verdana">Article Title:<span style="color:#FF0000;">*</span></FONT></p> </td> <td width="67%" height="60%"> <input type="text" name="hallo_art_name" id="hallo_art_name"/> <span id="hallo_art_name1" style="color:#FF0000; display:none;">* Please enter the title of your Article</span> </td> </tr> <tr style="width:60px; height:60px;"> <TD align="center" WIDTH="33%" style="color:#FFFFFF;"><P><FONT SIZE="-1" FACE="Verdana">Article Description:<span style="color:#FF0000;">*</span></FONT></P> </TD> <TD WIDTH="68%"><P> <FONT SIZE="-2" FACE="Verdana" color="#FFCC66"> Max 300 Characters<BR> <TEXTAREA NAME="hallo_art_desc" id="hallo_art_desc" ROWS=5 COLS=33 WRAP="virtual"></TEXTAREA> <span id="hallo_art_desc1" style="color:#FF0000; display:none;">* Enter Description</span> <BR> </FONT> <FONT SIZE="-2" FACE="Verdana" COLOR="#FFCC66"> Do not use "See web site" as your description.</FONT></P> </TD> </TR> <tr style="width:60px; height:60px;"> <td width="33%" height="60%" style="color:#FFFFFF;"><p align="center"><FONT SIZE="-1" FACE="Verdana">Article tags:<span style="color:#FF0000;">*</span></FONT></p> </td> <TD WIDTH="68%"><P><FONT SIZE="-1" FACE="Verdana" color="#FFFFFF"> <input type="text" name="hallo_art_tags" id="hallo_art_tags" value="" size=30> <span id="hallo_art_tags1" style="color:#FF0000; display:none;">* Article Tags</span> </FONT><FONT SIZE="-2" FACE="Verdana" color="#FFCC66"><br> <font> Use a comma to separate each keyword.</font><BR> </FONT></P> </TD> </tr> <tr style="width:60px; height:60px;"> <td width="33%" height="60%" style="color:#FFFFFF;"><p align="center"><FONT SIZE="-1" FACE="Verdana">Article Body:<span style="color:#FF0000;">*</span></FONT></p> </td> <td width="67%" height="60%"> <textarea name="msgpost" id="msgpost" rows="10"/></textarea> <span id="msgpost1" style="color:#FF0000; display:none;">* Enter the Article content</span> </td> </tr> <tr style="width:60px; height:60px;"> <td width="33%" height="60%" style="color:#FFFFFF;"><p align="center"><FONT SIZE="-1" FACE="Verdana">Agree to our Submission Policy</font></p></Td> <TD WIDTH="68%"><P><FONT SIZE="-2" FACE="Verdana"> <INPUT TYPE="checkbox" NAME="policy" VALUE="Y" CHECKED> </FONT></P></TD> </TR> <tr style="width:60px; height:60px;"> <td align="center" colspan="3" width="67%" height="60%"> <input type="submit" name="add_article" id="add_article" value="Submit Article"/> </td> </tr> </table> </form> <?php if(isset($_POST['add_article'])) { $webcat = addslashes($_POST['halloween_website_directory']); $webname = $_POST['hallo_art_name']; $webdesc = $_POST['hallo_art_desc']; $webkeyword = $_POST['hallo_art_tags']; $webart = $_POST['msgpost']; $stripe_name = str_replace(' ','-',$webname); mysql_query("INSERT INTO halloween_directory_articles (hallo_web_cat,article_title,article_desc,article_body,article_stripe_name,article_tags) values ('".$webcat."','".$webname."','".$webdesc."', '".$webart."','".$stripe_name."','".$webkeyword."');"); $r = mysql_insert_id(); if(!empty($r)){ ?> <p align="center" style="color:#FFFFFF; font-size:20px;"><?php echo "Your Article has been added in our database. we will display it after approval";?></p> <?php } else { ?> <p style="color:#FFFFFF;"><?php echo "Article not added please submit again";?></p> <?php } } ?> </body> </html>
-
Okay. I am trying to create a form with 7 simple select options and an 8th dual select option. You can see it here: http://rowlandwilliams.com/seize/test.php The idea is that a user can choose any of the 8 options and the total price associated with that selection will populate the box at the top left of the page. The user can also decide to choose a different option than they previously selected. In that case (if they first selected option #2 and changed their mind and chose #5 next), the default value "Please Select" will replace their initial value at option #2. Everything seems to be working fine, except that the option #8 doesn't work at all. I know that's because #8 has two aspects to it, but it has to have that. Any help will be welcome help, since I am a true novice and confused as hell. Thanks.