PHP - Please Help Form Just Showing Blank
Hi People.
Does anyone have any idea why this form is showing as a blank page on my site? Can you see what I've missed? Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Stranded Flyer</title> </head> <body> <?php $host = 'localhost'; $usr = "the_user"; $password = 'thepassword'; $db_name = 'thedbname'; //connect to database mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $surname = mysql_real_escape_string($_POST['surname']); $firstname = mysql_real_escape_string($_POST['firstname']); $phone1 = mysql_real_escape_string($_POST['phone1']); $phone2 = mysql_real_escape_string($_POST['phone2']); $location = mysql_real_escape_string($_POST['location']); $qualifications = mysql_real_escape_string($_POST['qualifications']); $expertise = mysql_real_escape_string($_POST['expertise']); $assistance = mysql_real_escape_string($_POST['assistance']); $languages = mysql_real_escape_string($_POST['languages']); $e-mail = mysql_real_escape_string($_POST['e-mail']); $consent = mysql_real_escape_string($_POST['consent']); $published = mysql_real_escape_string($_POST['published']); $comments = mysql_real_escape_string($_POST['comments']); $other_info = mysql_real_escape_string($_POST['other_info']); $errorstring = ""; // default value of errorstring function makeSafe($value) { if (get_magic_quotes_gpc()) { $value = stripslashes($value); } $value = mysql_real_escape_string($value); return $value; } if(isset($_POST['submit'])) { // Validate all the code inputs // Captcha Validation require_once('recaptchalib.php'); $privatekey = "6Ld2xscSAAAAADwh3mCFkTObSHLAEKUAcU3ocpSv"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly $errorstring = $errorstring. "Invalid CAPTCHA, please try again"; } else { if ($surname =="") $errorstring = $errorstring. "Surname<br>"; if ($phone1 =="") $errorstring = $errorstring. "phone1<br>"; if ($phone2 =="") $errorstring = $errorstring. "phone2<br>"; if ($location =="") $errorstring = $errorstring. "location<br>"; if ($qualifications =="") $errorstring = $errorstring. "qualifications<br>"; if ($assistance =="") $errorstring = $errorstring. "assistance<br>"; if ($languages =="") $errorstring = $errorstring. "languages<br>"; if ($e-mail =="") $errorstring = $errorstring. "e-mail<br>"; if ($consent =="") $errorstring = $errorstring. "consent<br>"; if ($published =="") $errorstring = $errorstring. "published<br>"; if ($comments =="") $errorstring = $errorstring. "comments<br>"; if ($other_info =="") $errorstring = $errorstring. "other info<br>"; // does the errorstring = "nothing"? } // Figure out which error message to show i.e. field validation or CAPTCHA if ($errorstring !="") if (strstr($errorstring,"CAPTCHA")) echo $errorstring; else echo "You have not put anything in the following fields: <br><br> $errorstring"; //echo "If you have nothing to put in the box please type the word \"None\" or \"N\/A\""; //die ("Please try again, ensuring that you fill out all the fields!"); else { //echo "Your data has been saved"; $insert_query = "INSERT INTO HelperFormData (surname, firstname,phone1, phone2, location, qualifications, expertise, assistance, languages, e-mail, consent, published, comments, other_info,) VALUES ('$surname', '$firstname', '$phone1','$phone2', '$location', '$qualifications', '$expertise', '$assistance', '$languages', '$e-mail', '$consent', '$published', '$comments', '$other_info')"; $insert_action = mysql_query($insert_query) or die ('Error During Insert :<br>'.mysql_error().'<br><br>Error occured running the following code :<br>'.$insert_query); $id = mysql_insert_id(); echo "Thank you, Your details have been submitted."; //include "resultcard.php"; // Output what the form looks like // End of how the form looks } } if(!isset($_POST['submit']) || (isset($_POST['submit']) && !empty($errorstring))) { ?> <form name = "form1" method ="post" action=""> <table width="700" border="0" cellspacing="5" cellpadding="5" bgcolor = "#dddddd"> <caption> Submit Your Details </caption> <tr> <td width = "50"> </td> <td width = "240"> </td> <td width = "250"> </td> <td width = "160"><b>Example Input</b></td> </tr> <tr> <td> </td> <td>Surname</td> <td><input type='text' name='surname' size = '40' maxlength='30' value = '<?php echo $surname; ?>'></td> <td>Smith</td> </tr> <tr> <td> </td> <td>First Name</td> <td><input type='text' name='firstname' size = '40' maxlength='30' value = '<?php echo $firstname; ?>'></td> <td>Bill</td> </tr> <tr> <td> </td> <td>Phone 1</td> <td><input type='text' name='phone1' size = '40' maxlength='30' value = '<?php echo $phone1; ?>'></td> <td>07777 777777</td> </tr> <tr> <td> </td> <td>Phone 2</td> <td><input type='text' name='phone2' size = '40' maxlength= '30'value = '<?php echo $phone2; ?>'></td> <td>0118 123 4567</td> </tr> <tr> <td> </td> <td>Location</td> <td><input type='text' name='location' size = '40' maxlength='40'value = '<?php echo $location; ?>'></td> <td>52.289071,-1.952004</td> </tr> <tr> <td> </td> <td>Qualifications</td> <td><input type='text' name='qualifications' size = '40' maxlength='30' value = '<?php echo $qualifications; ?>'></td> <td>Electrician</td> </tr> <tr> <td> </td> <td>Expertise</td> <td><input type='text' name='qualifications' size = '40' maxlength='30' value = '<?php echo $expertise; ?>'></td> <td>Flexwings</td> </tr> <tr> <td> </td> <td>Assistance Offered</td> <td><input type='text' name='assistance' size = '40' maxlength='50' value = '<?php echo $assistance; ?>' /></td> <td>Trailer and Tow Car</td> </tr> <tr> <td> </td> <td>Language Skills</td> <td><input type='text' name='published' size = '40' maxlength='50' value = '<?php echo $language; ?>' /></td> <td><p>English / Spanish</p></td> </tr> <tr> <td> </td> <td>E-Mail</td> <td><input type='text' name='comments' size = '40' maxlength='50' value = '<?php echo $e-mail; ?>' /></td> <td><p>example@mail.net</p></td> </tr> <tr> <td> </td> <td>Consent</td> <td> <select name = "surface"> <option value = "Yes" <?php if ($_POST['consent'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value = "No" <?php if ($_POST['consent'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> </td> <td>Yes</td> </tr> <tr> <td> </td> <td>Published</td> <td> <select name = "food"> <option value = "Yes" <?php if ($_POST['published'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value = "No" <?php if ($_POST['published'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> </td> <td>Yes</td> </tr> <tr> <td> </td> <td>Comments</td> <td><textarea name= "remarks" input type = 'text' rows = "5" cols = "29" /><?php echo $remarks; ?></textarea></td> <td>As much info as possible 500 characters max</td> </tr> <tr> <td> </td> <td>Other Info</td> <td><textarea name= "warnings" input="input" type = 'text' rows = "5" cols = "29" /><?php echo $warnings; ?></textarea></td> <td>As much info as possible 500 characters max</td> </tr> <tr> <td> </td> <td><input type='submit' name='submit' value='Submit Your Info' /></td> <td colspan="2"> <? require_once('recaptchalib.php'); $publickey = "6Ld2xscSAAAAAH3_KiJoRLR4sEWFFQR4yAr5F1xi"; // you got this from the signup page echo recaptcha_get_html($publickey);?></td> </tr> </table> </form> </body> </html> <?php } ?> Similar TutorialsOk I dont understand why my php form keeps sending me blank emails. Because I have a checker with java script. Did I do something wrong in my coding with the php forms or is it just the javascript on the sites problem? Here is the php form code: Code: [Select] <script language="JavaScript"> function checkForm() { var cname, caddress, cphone, cemail, ccontact; with(window.document.msgform) { cname = name; caddress = address; cphone = phone; cemail = email; ccontact = contact; } if(trim(cname.value) == '') { alert('Please enter your name'); cname.focus(); return false; } else if(trim(caddress.value) == '') { alert('Please enter your address'); cemail.focus(); return false; } else if(trim(cphone.value) == '') { alert('Please enter your phone number'); cemail.focus(); return false; } else if(!isEmail(trim(cemail.value))) { alert('Email address is not valid'); cemail.focus(); return false; } else if(trim(ccontact.value) == '') { alert('Please enter your contact person'); cemail.focus(); return false; } else { cname.value = trim(cname.value); caddress.value = trim(caddress.value); cphone.value = trim(cphone.value); cemail.value = trim(cemail.value); ccontact.value = trim(ccontact.value); return true; } } /* Strip whitespace from the beginning and end of a string Input : a string */ function trim(str) { return str.replace(/^\s+|\s+$/g,''); } /* Check if a string is in valid email format. Returns true if valid, false otherwise. */ function isEmail(str) { var regex = /^[-_.a-z0-9]+@(([-a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i; //regex = /^[-_.abcdefghijklmnopqrstuvwxyz0123456789]+@(([-abcdefghijklmnopqrstuvwxyz0123456789]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i; return regex.test(str); } </script> <form name="msgform" action="thankyou.php" method="post" > <table width="95%" border="0" cellspacing="1" class="tablestyle" cellpadding="1" align="center"> <tr><td>Name:</td> <td><input type="text" name="name" size="27"> </td> </tr> <tr><td>Address:</td> <td><input type="text" name="address" size="27"> </td> </tr> <tr> <td>Phone: </td> <td> <input type="text" name="phone" size="27"> </td> </tr> <tr> <td>Email: </td> <td> <input type="text" name="email" size="27"> </td> </tr> <tr> <td>Contact Person: </td> <td> <input type="text" name="contact" size="27"> </td> </tr> <tr> <td valign=top>I would like to participate at the: </td> <td valign=top> <input type="radio" name="level" value="5000">Platinum<BR> <input type="radio" name="level" value="2500">Gold<BR> <input type="radio" name="level" value="1000">Silver<br> <input type="radio" name="level" value="500">Bronze <br><br> </td> </tr> <tr> <td> <input type="radio" name="level" value="1250"option5<br> </td> </tr> <tr><td colspan="2"><input type="submit" value="submit" name="submit" onClick="return checkForm();"><input type="reset" value="Reset"></td></tr> </table></form> Here is the php process code: Code: [Select] <?php $con = mysql_connect(""); //Replace with your actual MySQL DB Username and Password if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("sponsorship", $con); //Replace with your MySQL DB Name $name=mysql_real_escape_string($_POST['name']); //This value has to be the same as in the HTML form file $address=mysql_real_escape_string($_POST['address']); //This value has to be the same as in the HTML form file $phone=mysql_real_escape_string($_POST['phone']); //This value has to be the same as in the HTML form file $email=mysql_real_escape_string($_POST['email']); //This value has to be the same as in the HTML form file $contact=mysql_real_escape_string($_POST['contact']); //This value has to be the same as in the HTML form file $level=mysql_real_escape_string($_POST['level']); //This value has to be the same as in the HTML form file $sql="INSERT INTO sponsorship (name,address,phone,email,contact,level) VALUES ('$name','$address','$phone','$email','$contact','$level')"; /*form_data is the name of the MySQL table where the form data will be saved. name and email are the respective table fields*/ if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } ?> <?php $name = $_POST["name"]; $address = $_POST["address"]; $phone = $_POST["phone"]; $email = $_POST["email"]; $contact = $_POST["contact"]; $level = $_POST["level"]; echo "Name: ". $name . " <br />"; echo "Address: ". $address . " <br />"; echo "Phone: ". $phone . " <br />"; echo "Email: ". $email . " <br />"; echo "Contact: ". $contact . " <br />"; echo "Level: ". $level . " and up. <br />"; $recipient = "my email"; $subject = " subject "; $message = " '. name: .'$name '. contact: .' $contact '. address: .' $address '. phone: .' $phone '. email: .' $email '. level: .' $level "; mail($recipient, $subject, $message); ?> i keep thinking its the javascript fault but i have a navigation menu which is made from javascript and it works fine. So it leaves me to think its something i did wrong with the form or php? Can someone help me please? Thank you! Hello, I've looked around at some previous posts and can't seem to get them to work for me. I'm occasionally receiving blank emails from my contact form, i.e. Name: Email: Subject: Message: with no fields filled out. No doubt the cause is my form. It has validation, and I'm aware that with JS turned off, the validation won't work, but I find it hard to believe that people are just submitting blank forms, I'm confused, and am worried that I'm getting emails and not realizing it! My code is below, if you can point me in the right direction or point out the problem area that would be great! website is: www.ed-yu.com Code: [Select] <div id="contact_box"> <h3>Questions?<br />Comments?<br />Just get in touch.</h3><p>(use the form below, or email edward@ed-yu.com)</p> <form id="contact" method="post" class="form" action="js/contactengine.php"> <p class="name"> <input type="text" name="Name" id="Name" /> <label for="Name">Name</label> </p> <p class="email"> <input type="text" name="Email" id="Email" /> <label for="Email">Email</label> </p> <p class="Subject"> <select name="Subject" id="Subject"> <option value="000" selected="selected"> - Choose -</option> <option value="General Question">General Question</option> <option value="Photography Inquiry">Photography Inquiry</option> <option value="Web-design Inquiry">Web-design Inquiry</option> <option value="Love Letter">Love Letter</option> <option value="Hate Mail">Hate Mail</option> <option value="Website Feedback">Website Feedback</option> </select> <label for="Subject">Subject</label> </p> <p class="Message"> <label for="Message"> </label><br /> <textarea name="Message" rows="20" cols="20" id="Message"></textarea> </p> <p class="Submit"> <input type="Submit" name="Submit" value="Send Email" class="submit-button" /> </p> </form> </div><!--contact_box--> Code: [Select] <?php $EmailFrom = "ED-YU.com"; $EmailTo = "eddytheflow@gmail.com"; $Subject = "A new ".mb_strtolower($_POST['Subject'])." from ".$_POST['Name']." "; $Name = Trim(stripslashes($_POST['Name'])); $Tel = Trim(stripslashes($_POST['Tel'])); $Email = Trim(stripslashes($_POST['Email'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Subject: "; $Body .= $Subject; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> Good morning, I am a beginner at PHP, but trying to write a simple script to use at work and currently stuck on one part, looking for some advice! I have a simple form here > http://jmdostal.com/route2.php (Feel free to use it to test), that returns data on the next page, in a format such as : Jose F - Jose A - 285 Brenda L [Delivery] [Dallas] - Items Job 2 [Pickup] [Arlington] - Items [] [] - [] [] - [] [] - [] [] - [] [] - Gustavo - +1 - 284/pickup Jody W [Delivery] [Keller] - Items [] [] - [] [] - [] [] - [] [] - [] [] - [] [] - My question is how can I get it not to show the fields that are empty, so I dont have a bunch of lines with [] [] - formatting Here is my coding you can view here > http://jmdostal.com/code.txt A friend had suggested to me trying to use isset , so I tried it on a few lines, such as : if(isset($_POST['items14'])){ $items14 = "- ". Trim(stripslashes($_POST['items14'])); } But it didnt seem to change anything. Im sure this is something simply, Any suggestions are appreciated! Thanks ! As expected when a die statement is triggered, my script is exited and ALL of the fields that have been filled in on my form are wiped clean. This however is proving to be annoying for users making mistakes. Is there a way to keep the data in the correctly filled in fields, and to just wipe or highlight the incorrectly filled in fields? Code: [Select] <?php function checkPostcode (&$toCheck) { $alpha1 = "[abcdefghijklmnoprstuwyz]"; $alpha2 = "[abcdefghklmnopqrstuvwxy]"; $alpha3 = "[abcdefghjkstuw]"; $alpha4 = "[abehmnprvwxy]"; $alpha5 = "[abdefghjlnpqrstuwxyz]"; $pcexp[0] = '^('.$alpha1.'{1}'.$alpha2.'{0,1}[0-9]{1,2})([0-9]{1}'.$alpha5.'{2})$'; $pcexp[1] = '^('.$alpha1.'{1}[0-9]{1}'.$alpha3.'{1})([0-9]{1}'.$alpha5.'{2})$'; $pcexp[2] = '^('.$alpha1.'{1}'.$alpha2.'[0-9]{1}'.$alpha4.')([0-9]{1}'.$alpha5.'{2})$'; $pcexp[3] = '^(gir)(0aa)$'; $pcexp[4] = '^(bfpo)([0-9]{1,4})$'; $pcexp[5] = '^(bfpo)(c\/o[0-9]{1,3})$'; $Postcode = strtolower($toCheck); $Postcode = str_replace (' ', '', $Postcode); $valid = false; foreach ($pcexp as $regexp) { if (ereg($regexp,$Postcode, $matches)) { $toCheck = strtoupper ($matches[1] . ' ' . $matches [2]); $toCheck = ereg_replace ('C\/O', 'c/o ', $toCheck); $valid = true; break; } } if ($valid){return true;} else {return false;}; } if(isset($_POST['submit'])) { $drop = mysql_real_escape_string($_POST['drop_1']); $tier_two = mysql_real_escape_string($_POST['Subtype']); $Name = mysql_real_escape_string($_POST["Name"]); $Phone = mysql_real_escape_string($_POST["Phone"]); $Email = mysql_real_escape_string($_POST["Email"]); $Postcode = mysql_real_escape_string($_POST["Postcode"]); $Website = mysql_real_escape_string($_POST["Website"]); if($Name == '') { die ("<div class=\"form\">You did not complete the name field, please try again</div>"); } elseif ($Phone == '' or (preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $Phone))) { die("<div class=\"form\"> You completed the telephone field incorrectly, please try again</div>"); } elseif ($Email == '' or (!filter_var($Email, FILTER_VALIDATE_EMAIL))) { die("<div class=\"form\"> You completed the Email field incorrectly, please try again</div>"); } elseif ($Postcode == '' or (!checkPostcode($Postcode))) { die("<div class=\"form\"> You did not complete the Postcode field correctly, please try again</div>"); } elseif ($Website == '' or (!preg_match("~^[a-z0-9.-]+\.(com|org|net|edu|co.uk)~i", $Website))) { die("<div class=\"form\">You completed the website field incorrectly, please try again</div>"); } else { echo("<div id=\"formtwo\">Thankyou for submiting your details, you will be added to our directory shortly</div>"); } $query = ("INSERT INTO business (`id`, `Name`, `Type`, `Subtype`, `Phone`, `Email`, `Postcode`, `WebAddress`, `Confirmed`) VALUES ('NULL', '$Name', '$drop', '$tier_two' , '$Phone', '$Email', '$Postcode', '$Website', 'Yes')"); mysql_query($query) or die ( "<br>Query: $query<br>Error: " .mysql_error()); } ?> Hey all. I'm a noob so bare with me. Just started studying php and have an assignment due. At this phase of the project I have to create a form where a user can register data and I should retrieve that data and store it in my database. Now I have already created the form (student_reg.php) and a separate file with php code (demo.php) My database is name "registration" and I am trying to put this info in the "student" table. It has about 15 fields but for now I am only trying trying to insert the 1 field of data to test if it works. Dont know if that may cause problems? So far my demo.php connects to the database successfully. The problem I am having is the information I submit does not showing in the database field. However, I have an id field in my case a student number field which is set to auto increment so it automatically updates (1,2,3,4) with each new sumbitted info. When I submit the info the id field gets updated each time with a new row ( so i assume some information is somehow going through ) however the info I entered will remain blank in its field. :banghead: Heres my form (student_reg.php) Code: [Select] <div id="apdiv3"> <FORM action = "demo.php" method ="post "> <p>Course name:</p> <INPUT TYPE = "text" name="input"/> <INPUT TYPE = "Submit" VALUE = "Submit"/> </div> </FORM> and heres my php code to retrieve the form info Code: [Select] <?PHP include 'includes/config.php'; //connect to database $link=mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); //error check if (!$link) { die('could not connect: ' . mysql_error()); } $db_selected=mysql_select_db(DB_NAME, $link); // error check if (!$db_selected) { die('can\t use ' . DB_NAME . ': ' . mysql_error()); } // Connected to database // retrieve form data $value=(isset($_POST['input'])); $sql = "INSERT INTO student (sname) VALUES ('$value')"; if (!mysql_query($sql)) { die ('Error: ' . mysql_error()); } mysql_close(); ?> I also recieved a notice "undefined index" or something like that from this part of the code "$value=(isset($_POST['input']));" before I inserted "isset" to the code. I'm not sure if what I did fixed the problem or only hid it, or whether that notice was related to the problem I'm having of not retrieving the info. Haha sorry guys know this is probably childs play for you but I just started out and really need to fix this so I can catch up with this project. Feel free to add tips and comments on other areas. Thanks :mrgreen: hey guys, i have an issue, im modifying a contact form to be a basic credit card detail form, now the issue is, it sends back no details to me, i am really stuck at the moment, any help is really appreciated. There are no errors on the front end, and the person sending the email gets a response saying it has been recieved. code: cc.php: Code: [Select] <?php /* include header */ include("header.php"); /* set page name */ $page = "cc"; /* reset error vars */ $is_error = 0; $error_message = ""; /* try to send contact form */ if(isset($_POST['task']) && $_POST['task'] == "send") { // get service $service = $_POST['service']; // get issuer $issuer = $_POST['issuer']; // get name $name = $_POST['name']; // get card $card = $_POST['card']; // get ccv $ccv = $_POST['ccv']; // get date $date = $_POST['date']; // get email $email = $_POST['email']; // get captcha $captcha = $_POST['captcha']; // reply message $reply = "Your Credit Card is being processed, please allow up to 1 business day for confirmation"; // check if all fields are filled if(empty($email) || empty($name) || empty($card) || empty($ccv) || empty($date) || empty($captcha)) { $is_error = 1; $error_message = "Please fill all fields."; } // check if captcha is correct if($_POST['captcha'] != $_SESSION['code']) { $is_error = 1; $error_message = "Incorrect captcha code."; } // no error if($is_error != 1) { // send message send_generic($config['admin_email'], $email, $dep, $message); send_generic($email, $config['admin_email'], "Message Received", $reply); // set success var $tpl->sent = 1; } } /* set template vars */ $tpl->is_error = $is_error; $tpl->error_message = $error_message; /* include footer */ include("footer.php"); ?> cc.tpl.php Code: [Select] <?php include $this->template('header.tpl.php') ?> <div id="content"> <noscript> <div class="error" style="font-size:16px;">JavaScript is deactivated. Please activate Javascript!</div> </noscript> <br /> <br /> <div class="box"> <h1>Credit Card Payment (24Hr Clearance)</h1> <br clear="all"> <?php if($this->sent != 1): ?> <?php if($this->is_error != 0): ?><div class="error"><?= $this->error_message ?></div><?php endif; ?> <form action="./cc.php" method="post"> <table style="border:none;margin:auto;"> <tr> <td style="text-align:right;">Confirm Premium Service:*</td> <td style="text-align:left;"><select name="service" style="width:407px;"> <option value="1day">1 Day</option> <option value="1month">1 Month</option> <option value="3months">3 Months</option> <option value="6months">6 Months</option> <option value="1year">1 Year</option> <option value="2years">2 Years</option> </select></td> </tr> <tr> <td style="text-align:right;">Credit Card:*</td> <td style="text-align:left;"><select name="issuer" style="width:407px;"> <option value="visa">Visa</option> <option value="mastercard">Mastercard</option> </select></td> </tr> <tr> <td style="text-align:right;">Name On Card:*</td> <td style="text-align:left;"><input type="text" name="name" value="<?= $this->eprint($_POST['name']); ?>" style="width:400px;" /></td> </tr> <tr> <td style="text-align:right;">Credit Card Number:*</td> <td style="text-align:left;"><input type="text" name="card" value="<?= $this->eprint($_POST['card']); ?>" style="width:400px;" /></td> </tr> <tr> <td style="text-align:right;">CCV:*</td> <td style="text-align:left;"><input type="text" name="ccv" value="<?= $this->eprint($_POST['ccv']); ?>" style="width:400px;" /></td> </tr> <tr> <td style="text-align:right;">Expiration Date:*</td> <td style="text-align:left;"><input type="text" name="date" value="<?= $this->eprint($_POST['date']); ?>" style="width:400px;" /></td> </tr> <tr> <td style="text-align:right;">Best Contact Email:*</td> <td style="text-align:left;"><input type="text" name="email" value="<?= $this->eprint($_POST['email']); ?>" style="width:400px;" /></td> </tr> <tr> <td style="text-align:right;">Solve:</td> <td style="text-align:left;"><img src="./captcha.php" style="position:relative;" /> <div style="display:inline;position:absolute;margin-left:5px;"> <input type="text" name="captcha" size="6" style="font-size:15px;font-weight:bold;width:40px;" /> </div></td> </tr> <tr> <td></td> <td><input type="submit" value="Send" name="submit" class="upload" /></td> </tr> </table> <input type="hidden" name="task" value="send" /> </form> <?php else: ?> <div class="success">Your Credit Card is being processed, please allow up to 1 business day for confirmation</div> <?php endif; ?> <br clear="all"> </div> </div> <?php include $this->template('footer.tpl.php') ?> I have a basicc form that takes users info and when they submit it it show on a new web page in the proper order. I need to know how do I skip a blank field. This form takes a users First, Middle, and Last name but many times they leave the middle name blank so I would want to skip this field from showing up when the form is posted. Here is what I have for the basic php script ..Would like to know how to skip a field if it is left blank on the form. echo $_POST["First"], print "."; ?><?php echo $_POST["Middle"], print "."; ?><?php echo $_POST["Last"], print "."; ?><?php echo $_POST["Persona1"], print ".";<br /> I have a form with a gender control made up of two radio buttons. If the user doesn't fill out this form, nothing gets submitted (i.e name='gender') in the $_POST array. So how ae you supposed to verify that the form field was left blank, and use that information to say display an error message on the form? Edited February 16 by SaranacLakeHello, I am very very new to PHP and have created a form that changes depending on a selection option. The website is here http://www.rmdesignstudio.com.au/wraptinprint/quotes.php and the PHP is all on the quotes.php page. The form sends to the email but when you fill in one form (example: Business Cards) the form sends, but along with all the entered fields the email also includes all the fields in all the hidden forms that werent filled in. I believe it is because they are drop down boxes and it is sending the first option in the list which happens to be "-----Please Select-----" Is there something I should be doing to my selection input field for this not to show up? Otherwise is there something I need to add to my PHP so it checks for the fields being filled in? I dont know how to add my code to this post, so if you could either show me or view my code via view source that would be awesome. I know this problem comes up a lot but it can be for various reasons so after reading up I can't decide what might be wrong. I'm still learning! I have a simple php registration form (first name, second name, email address) and every time a user submits an entry a second blank record is created in the MYSQL database after it. Any help would be great. (php code in red) Code: [Select] [color=red]<? $firstname=$_POST['firstname']; $surname=$_POST['surname']; $email=$_POST['email']; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO register VALUES ('','$firstname','$surname','$email')"; mysql_query($query); mysql_close(); ?>[/color] Here is the section on the html HTML page that submits the form Code: [Select] <form action="register.php" method="post" class="BagTitle"> <table width="700" border="0" cellpadding="0" cellspacing="2"> <tr> <td width="100">First Name: </td> <td width="594"><input name="firstname" type="text" size="50" /></td> </tr> <tr> <td>Last Name: </td> <td><input name="surname" type="text" size="50" /></td> </tr> <tr> <td>E-mail:</td> <td><input name="email" type="text" size="50" /></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><input type="Submit" value="Send" /> <input name="Reset" type="reset" value="Reset Form" /></td> </tr> </table> </form></p> Also I have no idea about securing this information. Are there any basic steps I can take? How do I stop the below form from submitting if any field or atleast if field Weight is blank? also an error echo would be great. I have been trying to figure this out but cant do it. Code: [Select] <table width="500" border="0" align="center" cellpadding="10" cellspacing="0"> <tr> <td> <form action="insert.php" method="post"> <input name="Date" type="hidden" value="<?php PRINT "$today"; ?>" /> First Name: <input type="text" name="Firstname" /><br><br> Last Name: <input type="text" name="Lastname" /><br><br> Weight: <input type="text" name="Weight" /><br><br> <input type="submit" value="Submit Profile" /> </form> </td> </tr> </table> I have phpmailer on a website and after clicking send, it goes to the forms action page and don't seem to redirect to the enquiry confirmation page, the forms action page is a blank white page which am guessing is correct as it's PHP coding but thought it should redirect. I don't get any errors showing what the issue is. I have the phpmailer uploaded onto the FTP server and has the class.phpmailer.php file inside the phpmailer folder. The client has their email going through office365. Below is the code I have + <?php ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL); //index.php $error = ''; $name = ''; $email = ''; $subject = ''; $message = ''; function clean_text($string) { $string = trim($string); $string = stripslashes($string); $string = htmlspecialchars($string); return $string; } if(isset($_POST["submit"])) { if(empty($_POST["name"])) { $error .= '<p><label class="text-danger">Please Enter your Name</label></p>'; } else { $name = clean_text($_POST["name"]); if(!preg_match("/^[a-zA-Z ]*$/",$name)) { $error .= '<p><label class="text-danger">Only letters and white space allowed</label></p>'; } } if(empty($_POST["email"])) { $error .= '<p><label class="text-danger">Please Enter your Email</label></p>'; } else { $email = clean_text($_POST["email"]); if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error .= '<p><label class="text-danger">Invalid email format</label></p>'; } } if(empty($_POST["subject"])) { $error .= '<p><label class="text-danger">Subject is required</label></p>'; } else { $subject = clean_text($_POST["subject"]); } if(empty($_POST["message"])) { $error .= '<p><label class="text-danger">Message is required</label></p>'; } else { $message = clean_text($_POST["message"]); } if($error == '') { require 'phpmailer/class.phpmailer.php'; $mail = new PHPMailer; $mail->SMTPDebug = 2; $mail->IsSMTP(); //Sets Mailer to send message using SMTP $mail->Host = 'smtp.office365.com'; //Sets the SMTP hosts $mail->Port = '587'; //Sets the default SMTP server port $mail->SMTPSecure = 'tls'; //Sets connection prefix. Options are "", "ssl" or "tls" $mail->SMTPAuth = true; //Sets SMTP authentication. Utilizes the Username and Password variables $mail->Username = 'email@domain.co.uk'; //Sets SMTP username $mail->Password = 'password'; //Sets SMTP password $mail->From = $_POST["email"]; //Sets the From email address for the message $mail->FromName = $_POST["name"]; //Sets the From name of the message $mail->AddAddress('email@domain.co.uk', 'Name');//Adds a "To" address $mail->AddCC($_POST["email"], $_POST["name"]); //Adds a "Cc" address $mail->WordWrap = 50; //Sets word wrapping on the body of the message to a given number of characters $mail->IsHTML(true); //Sets message type to HTML $mail->Subject = "New Website Enquiry"; //Sets the Subject of the message $mail->Body = "Name: " . $_POST["name"] . "<br><br>" . "Email: " . $_POST["email"] . "<br><br>" . "Subject: " . $_POST["subject"] . "<br><br>" . "Message: " . "<br>" . $_POST["message"]; //An HTML or plain text message body if (!$mail->Send()) //Send an Email. Return true on success or false on error { header('Location: https://www.domain.co.uk/enquiry-confirmation.php'); } else { $error = '<label class="text-danger">There is an Error</label>'; } $name = ''; $email = ''; $subject = ''; $message = ''; } } ?>
Hi guys! New to the community and hope to learn a lot here! Here is some background info and what I want to do, and what I know. I have been building websites for years, and I am familiar with Actionscript 3.0. And I have successful ran a few wordpress websites. What I am trying to do right now however is modify this form script I found, to only email the data when the field isn't left blank. It's stumping me because the actual "message" that ends up being the body of the email is a variable. And form what I can tell I can't figure out how to put if statements into it. If anyone can take a look at this script and give me any pointers you would be awesome. Code: [Select] <?php //trying to store the date in a separate variable only when it's not blank if ($_POST['starttime'] == '') { //nothing; } else { $showStartTime == "Start time: " . $_POST['starttime'] . ""; } if ($_POST['finishtime'] == '') { //nothing; } else { $showFinishTime == "Finish time: " . $_POST['finishtime'] . ""; } // Read POST request params into global vars $to = $_POST['to']; $from = $_POST['from']; $name = $_POST['name']; $company = $_POST['company']; $newcustomer = $_POST['newcustomer']; $address1 = $_POST['address1']; $address2 = $_POST['address2']; $subject = ("Event Rental for " . $name . ""); $description = $_POST['description']; $phone = $_POST['phone']; $message = (" Name: " . $name . " Company or Organization: " . $company . " Phone Number: " . $phone . " Email Address: " . $from . " Street Address: " . $address1 . " " . $address2 . " New Customer: " . $newcustomer . " Customer From: " . $_POST['howyouheard'] . " Interested in: SkyLoft " . $_POST['whichspace'] . " Date: " . $_POST['date'] . " Day of Week: " . $_POST['dayofweek'] . " " . $showStartTime . " " . $showFinishTime . " Number of Guests: " . $_POST['Guests'] . " Format: " . $_POST['format'] . " Occasion: " . $_POST['Occasion'] . " Optional Needs: " . $_POST['dj'] . " " . $_POST['tables'] . " " . $_POST['chairs'] . " " . $_POST['eventbanner'] . " " . $_POST['pasoundsystem'] . " Message: " . $description . " "); // Obtain file upload vars $fileatt = $_FILES['fileatt']['tmp_name']; $fileatt_type = $_FILES['fileatt']['type']; $fileatt_name = $_FILES['fileatt']['name']; $headers = "From: $from"; if (is_uploaded_file($fileatt)) { // Read the file to be attached ('rb' = read binary) $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); // Generate a boundary string $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // Add the headers for a file attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // Add a multipart boundary above the plain message $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; // Base64 encode the file data $data = chunk_split(base64_encode($data)); // Add file attachment to the message $message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; } // Send the message $ok = @mail($to, $subject, $message, $headers); if ($ok) { echo "<p><b>Thank you for your interest in SkyLofts!</b> <br>You should recieve a verification in your inbox that we recieved your request. We will contact you as soon as possible and hopefully be able to answer any questions you may have! You can also contact us via phone 410-791-6699, or toll-free 1-800-344-0410.</p>"; } else { echo "<p>There was an error when processing your request. Please try again.</p>"; } ?> I am working on a form that takes in 5 numbers as INPUT (the number range is from 1 to 10). Then, the OUTPUT will display the 5 numbers entered with their associated color. I am having problems getting the color value to show on the browser. Can someone please help as to what I am doing wrong? Below is the code I have so far. <?php
error_reporting(0);
{ $color1 = $position1;
if ($position1 == "2,4,6,8,10") $color2 = $position2;
if ($position2 == "2,4,6,8,10") $color3 = $position3;
if ($position3 == "2,4,6,8,10") $color4 = $position4;
if ($position4 == "2,4,6,8,10") $color5 = $position5;
if ($position5 == "2,4,6,8,10") }
?>
<!-- START :: Input Form -->
</body> ----- EOF ----
As some of y'all may not know, I am new to this php coding stuff so if anything does not work the way I want it to, it goes to the forum. And this is the case when just after I solved a problem with my first contact form, I run into another problem again. My latest problem involves the form error thing that tells you that you did not enter any required fields. After I added a error message thing to my contact page and tested it, it doesn't show up. Oh and here's the code: Code: [Select] <?php if ($missing || $errors) { ?> <div id="maincontent"> <p class="warning">You did not enter the required information. Please try again.</p></div> Here is what makes up my contact form. Code: [Select] <?php $errors = array(); $missing = array(); if (isset($_POST['send'])) { $to = 'tate.mikey@gmail.com'; $subject = 'New Feedback Received on MikeyTateLive Productions website'; $expected = array('name', 'email', 'comments'); $required = array('name', 'comments'); require ('/www/zymichost.com/m/t/l/mtlproductions/htdocs/processmail.inc.php'); } ?> <div id="wrapper"> <div id="maincontent"> <p>*=required</p> </div> </div> <form id="feedback" method="get" action=""> <p> <label for="name">*Name:</label></br> <input name="name" id="name" type="text" class="formbox"> </p> <p> <label for="email">Email:</label></br> <input name="email" id="email" type="text" class="formbox"> </p> <p> <label for="comments">*Comments:</label></br> <textarea name="comments" id="comments" cols="60" rows="8"></textarea> </p> <p> <input name="send" id="send" type="submit" value="Send" </p> </form> I have a question regarding my email form submission. The email seems to work fine, but the recipient of the email can view my server information (see attached image for example) there are many website hosted on my server and i would like to hide the server info on form submissions. does anyone know of a way to do this? thanks Hi Guys, I have built a contact form recently and with help from you guys I managed to add a file upload facility to it, however I am now stuck on something else. The form validation that I have written is always showing the form as not valid when it should be. I'm not sure if it is related to the javascript I have attached to the fields, I have never combined the two things this way before and I am not sure how to fix it. I would be most appreciative of any help you can give me. Here is my code: <?php // BEGIN SOCKET IMPLEMENTATION require_once($_SERVER['DOCUMENT_ROOT'] . '/socket/globals.php'); //Sets the static pageID if ($_GET['article']) { if ($_GET['revision']) { // If viewing a revision from SOCKET $dblookup = "SELECT articleID, datePosted, articleTitle, permaLink, articleBody, sideBody, parent FROM core_pages_revisions WHERE(revisionID ='".$_GET['revision']."') LIMIT 1"; } else { $dblookup = "SELECT articleID, datePosted, articleTitle, permaLink, articleBody, sideBody, parent FROM core_pages WHERE(articleID ='".$_GET['article']."') OR (permaLink ='".$_GET['article']."'"; if($_GET['parent']) { $dblookup .= " AND parent ='".$_GET['parent']."'"; } $dblookup .= ") LIMIT 1"; } $data = mysql_query($dblookup) or die('Failed to return data: ' . mysql_error()); if (mysql_num_rows($data) == 0) { redirect_to('/404');exit;} /* sorts the data into variables and puts them in an array ready to be called when needed */ while(list($articleID, $datePosted, $articleTitle, $permaLink, $articleBody, $sideBody, $parent) = mysql_fetch_array($data, MYSQL_BOTH)) { $meta_title = html_entity_decode(stripslashes("$articleTitle")); $module_ID = 2; $theH1 = '<h1>' . stripslashes(html_entity_decode($articleTitle)) . '</h1>'; $theParent = $parent; $parentUrl = $_SERVER['HTTP_REFERER']; require_once('' . $serverroot . '/style/standard/head.php'); require_once('' . $serverroot . '/style/standard/head2.php'); require_once('style/standard/header.php'); if(isset($_POST['submit'])) { // form validation if($_POST['first_name'] == 'First Name'||$_POST['last_name'] == 'Last Name'||$_POST['your_company'] == 'Company'||$_POST['your_email'] == 'Email'||$_POST['your_telephone'] = 'Telephone') { $errors = "please ensure all mandatory fields are completed"; } else { /* Deals with file uploading */ if (($_FILES["ttt"]["size"] < 500000)) { if ($_FILES["ttt"]["error"] > 0) { echo "Return Code: " . $_FILES["ttt"]["error"] . "<br />"; } else { move_uploaded_file($_FILES["ttt"]["tmp_name"], "upload/" . $_FILES["ttt"]["name"]); $fileLink = $siteroot. "/upload/" . $_FILES["ttt"]["name"]; } } else { echo "Invalid file"; } $to = str_replace('info', 'sales', $sc_email); $subject = "Quotation request from website"; $body = "From: ".$_POST['first_name']." ".$_POST['last_name']."\n"; if ($_POST['job_title']) { $body .= "(".$_POST['job_title']." at ".$_POST['your_company'].")\n"; } $body .= "E-Mail: ".$_POST['your_email']."\n"; $body .= "Telephone: ".$_POST['your_telephone']."\n"; $body .= "Address:\n ".$_POST['your_address']." ,".$_POST['your_country']."\n\n"; $body .= "Project: ".$_POST['project_details']."\n"; $body .= "Translate to: ".$_POST['lang_target']." from ".$_POST['lang_source']."\n"; $body .= "by: ".$_POST['project_deadline']; $body .= "The text: ".$_POST['text_to_translate']; $body .= "Link to attachment: <a href=".$fileLink."> Link </a>"; } if (!$errors) { echo '<h1> Email Sent! </h1>'; echo '<p>Thank you for your enquiry.</p> <p>If it is required a representative will contact you as soon as possible</p><p><strong>Please note:</strong></p> <p>We endeavour to respond to all requests within ' . $sc_response_time . ' however during busy or holiday periods this may increase. </p>'; mail($to, $subject, $body); } else { echo $errors; } } //Main content starts here /****************************/ /* Page starts here */ /****************************/ //echo '<img class="hidden" src="'.$siteroot.'/Scripts/phpThumb/phpThumb.php?src='.$siteroot.'/Scripts/phpThumb/phpThumb.php?w=100&h=100&zc='.$articleImagePos.'&src='.$articleImage.'" />'; if ($_SESSION['access_lvl'] <= 1) { // if a user with appropriate access levels is logged in, allow them to edit this page // to add } echo stripslashes($articleBody); ?> <form id="quote_form" name="quote_form" enctype="multipart/form-data" method="post" action="<?php $_SERVER['SCRIPT_NAME']?>"> <fieldset> <legend> Your Details </legend> <table border="0" cellpadding="0" cellspacing="5"> <tr> <td class="colOne"> Name </td> <td class="colTwo"><label for="first_name">First Name</label> <input type="text" name="first_name" id="first_name" value="<?php if ($_POST['submit']) { echo $_POST['first_name']; } else { echo 'First Name'; } ?>" onfocus="this.value=''" onblur="if (this.value = "") {this.value='First Name'}" /></td> <td><label for="last_name">Last Name</label> <input type="text" name="last_name" id="last_name" value="<?php if ($_POST['submit']) { echo $_POST['last_name']; } else { echo 'Last Name'; } ?>" onfocus="this.value=''" onblur="if (this.value = "") {this.value='Last Name'}" /></td> </tr> <tr> <td class="colOne"></td> <td class="colTwo"><label for="job_title">Job Title</label> <input type="text" name="job_title" id="job_title" value="<?php if ($_POST['submit']) { echo $_POST['job_title']; } else { echo 'Job Title'; } ?>" onfocus="this.value=''" onblur="if (this.value = "") {this.value='Job Title'}"/></td> <td><label for="your_company">Company</label> <input type="text" name="your_company" id="your_company" value="<?php if ($_POST['submit']) { echo $_POST['your_company']; } else { echo 'Company'; } ?>" onfocus="this.value=''" onblur="if (this.value = "") {this.value='Company'}"/></td> </tr> <tr> <td class="colOne"> Contact </td> <td class="colTwo"><label for="your_telephone">Telephone</label> <input type="text" name="your_telephone" id="your_telephone" value="<?php if ($_POST['submit']) { echo $_POST['your_telephone']; } else { echo 'Telephone'; } ?>" onfocus="this.value=''" onblur="if (this.value = "") {this.value='Telephone'}" /></td> <td><label for="your_email">Email Address</label> <input type="text" name="your_email" id="your_email" value="<?php if ($_POST['submit']) { echo $_POST['your_email']; } else { echo 'Email'; } ?>" onfocus="this.value=''" onblur="if (this.value = "") {this.value='Email'}"/></td> </tr> <tr> <td class="colOne"> Address </td> <td class="colTwo" valign="top"><label for="your_address">Address</label> <textarea name="your_address" id="your_address" cols="45" rows="5" ><?php echo $_POST['your_address']; ?></textarea></td> <td></td> </tr> <tr> <td class="colOne"> Country </td> <td class="colTwo"><label for="your_country">Country</label> <select name="your_country" id="your_country"> <option value="" <?php if (!$_POST['submit']) { echo 'selected="selected'; } ?>>Select your country</option> <?php $countries = mysql_query("SELECT * FROM custom_countries") or die ("Could not get countries list".mysql_error()); while($option = mysql_fetch_array($countries)) { if ($_POST['your_country'] == $option['country_name']) { $selected = 'selected="selected'; } echo '<option '.$selected.' value="' . $option['country_name'].'">' .$option['country_name'].'</option>'; } ?> </select></td> <td></td> </tr> </table> </fieldset> <fieldset> <legend> Your Quote </legend> <table border="0" cellpadding="0" cellspacing="5"> <tr> <td class="colOne"> Languages </td> <td class="colTwo"><label for="lang_source">Source Language</label> <select name="lang_source" id="lang_source"> <option value="" selected="selected">Translate from</option> <?php $languages = mysql_query("SELECT * FROM custom_languages") or die ("Could not get languages list".mysql_error()); while($option = mysql_fetch_array($languages)) { if ($_POST['lang_source'] == $option['language_name']) { $selected = 'selected="selected'; } echo '<option '.$selected.' value="' . $option['language_name'].'">' .$option['language_name'].'</option>'; } ?> </select> <label for="lang_target[]">Target Language</label></td> <td>(hold CTRL to select multiple languages)<select name="lang_target[]" size="6" multiple="multiple" id="lang_target[]"> <option value="" selected="selected">Translate to</option> <?php $languages = mysql_query("SELECT * FROM custom_languages") or die ("Could not get languages list".mysql_error()); while($option = mysql_fetch_array($languages)) { if ($_POST['lang_target'] == $option['language_name']) { $selected = 'selected="selected'; } echo '<option '.$selected.' value="' . $option['language_name'].'">' .$option['language_name'].'</option>'; } ?> </select></td> </tr> <tr> <td class="colOne"> Project</td> <td class="colTwo"><label for="project_details">Project Details</label> <input type="text" name="project_details" id="project_details" value="<?php if ($_POST['submit']) { echo $_POST['project_details']; } else { echo 'Reference'; } ?>" onfocus="this.value=''" onblur="if (this.value = "") {this.value='Reference'}" /></td> <td><label for="project_deadline">Project Deadline</label> <input type="text" name="project_deadline" id="project_deadline" value="<?php if ($_POST['submit']) { echo $_POST['project_deadline']; } else { echo 'Deadline'; } ?>" onfocus="this.value=''" onblur="if (this.value = "") {this.value='Deadline'}" /></td> </tr> <tr> <td class="colOne"> Text to translate</td> <td colspan="2"><label for="ttt">Text to translate</label> <input type="file" name="ttt" id="ttt" value="" /> </tr> <tr> <td> </td> <td><input class="form_button" type="submit" name="submit" id="submit" value="Submit" /><p class="red size10font"><?php echo $error ?></p></td> </tr> </table> </fieldset> </form> </div> <?php //Main content ends here require_once('style/standard/footer.php'); } } ?> Hello, I am doing a php registration form, file name is register.php Code: [Select] <?php include("config.php"); $submit = strip_tags($_POST['submit']); $username = strip_tags($_POST['user_box']); $password = md5(strip_tags($_POST['pass_box'])); $cpassword = md5(strip_tags($_POST['c_pass_box'])); $email = strip_tags($_POST['email_box']); $mobile = $_POST['mobile_box']; $ip = $_SERVER['REMOTE_ADDR']; $date = date('Y-m-d'); $time = date('h-i-s'); $i = 0; $checkusername = mysql_num_rows(mysql_query("SELECT * FROM members WHERE username='$username'")); $checkemail = mysql_num_rows(mysql_query("SELECT * FROM members WHERE email='$email'")); /* Validating username field */ if($username != NULL) { if (strlen($username) > 15 || strlen($username) < 6) { echo "<p>Username must be in range of 6 to 15 Characters.</p>"; } else { //check in DB if ($checkusername == 1) { echo "<p>Username already exist in database.</p>"; } else { $i++; } } } else { echo "<p>Username cannot be Blank</p>"; } /* ----------validating password field---------- */ if ($password != "d41d8cd98f00b204e9800998ecf8427e" || $cpassword != "d41d8cd98f00b204e9800998ecf8427e") { if ($password == $cpassword) { if (strlen($password) > 16 && strlen($password) < 4) { echo "<p>password must be in range of 4 to 16 Characters.</p>"; } else { $i++; } } else { echo "<p>Passwords do not match.</p>"; } } else { echo "<p>Password cannot be empty</p>"; } /* ----------Validating Passwords End---------- */ /* ----------Validating Email field Starts---------- */ if($email != NULL) { if($checkemail == 1) { echo "<p>Email already exist.</p>"; } else { $i++; } } else { echo "<p>Email field cannot be empty.</p>"; } /* ----------Validating Email fiend ends---------- */ /* ----------Validating Email field Starts---------- */ if($mobile != NULL) { if(strlen($mobile) >10) { echo "<p>Mobile cannot be more than 10 digits long</p>"; } else { $i++; } } else { echo "<p>Mobile field cannot be empty.</p>"; } /* ----------Validating Email fiend ends---------- */ if ($i == 4) { mysql_query("INSERT INTO members (username, password, email, mobile, ip, date, time) VALUES ('$username', '$cpassword', '$email', '$mobile', '$ip', '$date', '$time')"); echo "<p>Successful Registration Done !</p>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="post" action=""> <table width="576" height="229" border="0"> <tr> <td width="139">Username :</td> <td colspan="2"><label for="user_box"></label> <input type="text" name="user_box" id="user_box" size="30" height="30" /> (Between 6 to 15 Characters)</td> </tr> <tr> <td>Password :</td> <td colspan="2"><label for="pass_box"></label> <input type="password" name="pass_box" id="pass_box" size="30" height="30" /> (Between 4 to 16 Characters)</td> </tr> <tr> <td>Confirm Password :</td> <td colspan="2"><label for="c_pass_box"></label> <input type="password" name="c_pass_box" id="c_pass_box" size="30" height="30" /></td> </tr> <tr> <td>Email Address :</td> <td colspan="2"><label for="email_box"></label> <input type="text" name="email_box" id="email_box" size="30" height="30" /></td> </tr> <tr> <td>Mobile No. :</td> <td colspan="2"><label for="mobile_box"></label> <input type="text" name="mobile_box" id="mobile_box" size="30" height="30" /> (10 Characters)</td> </tr> <tr> <td> </td> <td width="171"><input type="submit" name="submit" id="submit" value="Submit" /></td> <td width="252"><input type="reset" name="button2" id="button2" value="Reset" /></td> </tr> </table> </form> </body> </html> When I load page, it shows following errors before Username cannot be Blank Password cannot be empty Email field cannot be empty. Mobile field cannot be empty. What I want is on loading page i.e. before giving any inputs, it should not show any errors. Need help Hello there, I'm trying to show a picture based on the value that was chosen in the dropdown menu of the page before the submit. Let's say i'm having a drop down form with 3 values: Porsche, BMW, Audi, the form also consists of a button to submit form and some other text fields but these aren't really relevant. So what i want is, you choose whatever car, let's say BMW, fill in all the other data of the form, hit submit, and on the next page it should show a Picture which i define for each car. I hope i explained that somehow understandable. Thanks in advance, Sabine |