jalea148 Posted July 15, 2008 Share Posted July 15, 2008 I'm able to pass the data ok, but the form fields First and Last are blank. In IE there are not clues the data is being passed. But, in Firefox when either form field is double clicked, a pull down menu appears and one of the menu items has the passed data - other menu items are passed values from prior tests. <?php session_start(); $_SESSION['sessFirst']; $_SESSION['sessLast']; $sessFirst = $_POST['First']; $sessLast = $_POST['Last']; ?> <!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>Untitled Document</title> </head> .................. <form action=".......................... > .................. <p> <input name="First" id="First" type="text" class="req" size="20" tabindex="1" value="<?php echo $sessFirst; ?>"/> <span class="style12"> Last </span> <input name="Last" id="Last" type="text" class="req" size="20" tabindex="2" value="<?php echo $sessLast; ?>" /> </p> .................... <body> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/114926-form-field-blank/ Share on other sites More sharing options...
MadTechie Posted July 15, 2008 Share Posted July 15, 2008 okay. whats the exact problem ? are sessions being used? as $_SESSION['sessFirst']; $_SESSION['sessLast']; isn't doing anything usful also the form is incomplete.. really need more complete data and a better understanding of the problem Quote Link to comment https://forums.phpfreaks.com/topic/114926-form-field-blank/#findComment-591072 Share on other sites More sharing options...
jalea148 Posted July 16, 2008 Author Share Posted July 16, 2008 I think you missed the snippit within my question. okay. whats the exact problem ? are sessions being used? as $_SESSION['sessFirst']; $_SESSION['sessLast']; isn't doing anything usful also the form is incomplete.. really need more complete data and a better understanding of the problem Quote Link to comment https://forums.phpfreaks.com/topic/114926-form-field-blank/#findComment-591501 Share on other sites More sharing options...
MadTechie Posted July 16, 2008 Share Posted July 16, 2008 really need more complete data and a better understanding of the problem Quote Link to comment https://forums.phpfreaks.com/topic/114926-form-field-blank/#findComment-591504 Share on other sites More sharing options...
ag3nt42 Posted July 16, 2008 Share Posted July 16, 2008 <input name="First" id="First" type="text" class="req" size="20" tabindex="1" value="<?php echo $sessFirst; ?>"/> <span class="style12"> the above code will only put a "Default" value into the text box... if "$sessFirst" doesn't have a value or the value is null.. you will have a null default value for the text input. Quote Link to comment https://forums.phpfreaks.com/topic/114926-form-field-blank/#findComment-591510 Share on other sites More sharing options...
ag3nt42 Posted July 16, 2008 Share Posted July 16, 2008 FYI: your form doesn't do anything.. unless of course its being sent to a different page.. inwhich we can't help you because that code is not posted here.. i'm assuming you are submitting names into a database then retrieving them all in the other page this form is being sent to... then possibly sending the info back to this form via POST... if you don't have another page.. your code simply submits a form to itself and refreshes the new default text input value with the value just submitted.. inwhich case.. really does nothing. so if there is more code please post it so we can further help you. Quote Link to comment https://forums.phpfreaks.com/topic/114926-form-field-blank/#findComment-591512 Share on other sites More sharing options...
jalea148 Posted July 16, 2008 Author Share Posted July 16, 2008 A variation of this snippit was working with php4 [obsolete variables replaced]. The session array is not null - the vaules are assigned from a post from a pror page and display in a pull down menu in Firefox. So, php4 doesn't think the default values are null; php5 appears to interpret the values as null. Redirection to another page requires validation - null fields are invalid. Here's the setup: <?php session_start(); $_SESSION['sessFirst']; $_SESSION['sessLast']; $sessFirst = $_POST['First']; $sessLast = $_POST['Last']; ?> Also, here's the beginning of the form: <form action="http://Rxyz.com/webqq.php" method="get" enctype="multipart/form-data" name="quote_form" id="quote_form" onSubmit="MM_validateForm('First','','R','Last','','R','address1','','R','city','','R','Zip','','R','Email','','RisEmail','Phone','','R','Appl_DOB','','R','County','','R','Spouse_DOB','','R'); FDK_AddRadioValidation('quote_form','document.quote_form.Appl_Uses_Tobacco',true,'\'Field is required,\\nplease make a choice.\''); FDK_AddRadioValidation('quote_form','document.quote_form.Marital',true,'\'Field is required,\\nplease make a choice.\''); FDK_AddRadioValidation('quote_form','document.quote_form.Spouse_Sex',true,'\'Field is required,\\nplease make a choice.\''); FDK_AddRadioValidation('quote_form','document.quote_form.Spouse_Uses_Tobacco',true,'\'Field is required,\\nplease make a choice.\''); FDK_AddRadioValidation('quote_form','document.quote_form.Dep2_Sex',true,'\'Field is required,\\nplease make a choice.\''); FDK_AddRadioValidation('quote_form','document.quote_form.Dep3_Sex',true,'\'Field is required,\\nplease make a choice.\''); FDK_AddRadioValidation('quote_form','document.quote_form.Dep1_Sex',true,'\'Field is required ,\\nplease make a choice.\'');return document.MM_returnValue" > Quote Link to comment https://forums.phpfreaks.com/topic/114926-form-field-blank/#findComment-591874 Share on other sites More sharing options...
jalea148 Posted July 17, 2008 Author Share Posted July 17, 2008 I hate dumping all this messycode on you [as it is I removed a bunch that I think is unrelated] code <?php session_start(); $_SESSION['sessFirst']; $_SESSION['sessLast']; $_SESSION['sessAddr']; $_SESSION['sessAddr2']; $_SESSION['sessCity']; $_SESSION['sessZip']; $_SESSION['sessPhone']; $_SESSION['sessEmail']; $sessFirst = $_POST['First']; $sessLast = $_POST['Last']; $sessAddr = $_POST['Addr']; $sessAddr2 = $_POST['Addr2']; $sessCity = $_POST['City']; $sessZip = $_POST['Zip']; $sessPhone = $_POST['Phone']; $sessXmail = $_POST['Email']; ?> <!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" /> <style type="text/css"> <!-- #Layer1 { position:absolute; width:228px; height:402px; z-index:-1; left: 19px; top: 2966px; visibility: visible; } .style26 a { } --> </style> <script> function hiderow() { rowhide.style.display="none"; tblChoice2.style.display=""; tblChoice3.style.display="none"; } </script> <script type="text/javascript"> <!-- function MM_goToURL() { //v3.0 var i, args=MM_goToURL.arguments; document.MM_returnValue = false; for (i=0; i<(args.length-1); i+=2) eval(args+".location='"+args[i+1]+"'"); } //--> </script> <!-- TemplateBeginEditable name="doctitle" --> <title>Request Quote from Insurance Source</title> <meta name="language" content="en-us" /> <meta name="robots" content="ALL" /> <meta name="rating" content="SAFE FOR KIDS" /> <meta name="distribution" content="NC" /> <meta name="classification" content="Insurance" /> <meta name="copyright" content="Richard" /> <meta name="author" content="Richard" /> <meta name="revisit-after" content="30 Days" /> <script src="file:///C|/RND/richard.com/Progs/usableforms.js"></script> <script type="text/javascript" src="file:///C|/RND/richard.com/form-validation.js"></script> <script language = "JavaScript" type="text/javascript"> /** * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) */ // Declaring valid date character, minimum year and maximum year var dtCh= "/"; var minYear=1900; var maxYear=2100; function isInteger(s){ var i; for (i = 0; i < s.length; i++){ // Check that current character is number. var c = s.charAt(i); if (((c < "0") || (c > "9"))) return false; } // All characters are numbers. return true; } function stripCharsInBag(s, bag){ var i; var returnString = ""; // Search through string's characters one by one. // If character is not in bag, append to returnString. for (i = 0; i < s.length; i++){ var c = s.charAt(i); if (bag.indexOf© == -1) returnString += c; } return returnString; } function daysInFebruary (year){ // February has 29 days in any year evenly divisible by four, // EXCEPT for centurial years which are not also divisible by 400. return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 ); } function DaysArray(n) { for (var i = 1; i <= n; i++) { this = 31 if (i==4 || i==6 || i==9 || i==11) {this = 30} if (i==2) {this = 29} } return this } function isDate(dtStr){ var daysInMonth = DaysArray(12) var pos1=dtStr.indexOf(dtCh) var pos2=dtStr.indexOf(dtCh,pos1+1) var strMonth=dtStr.substring(0,pos1) var strDay=dtStr.substring(pos1+1,pos2) var strYear=dtStr.substring(pos2+1) strYr=strYear if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1) if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1) for (var i = 1; i <= 3; i++) { if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1) } month=parseInt(strMonth) day=parseInt(strDay) year=parseInt(strYr) if (pos1==-1 || pos2==-1){ alert("The date format should be : mm/dd/yyyy") return false } if (strMonth.length<1 || month<1 || month>12){ alert("Please enter a valid month") return false } if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){ alert("Please enter a valid day") return false } if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){ alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear) return false } if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){ alert("Please enter a valid date") return false } return true } function ValidateForm(){ var dt=document.RequestQuote.Appl_DOB if (isDate(dt.value)==false){ dt.focus() return false } return true } function ValidateForm0(){ var dt=document.RequestQuote.Spouse_DOB if (isDate(dt.value)==false){ dt.focus() return false } return true } function ValidateForm1(){ var dt=document.RequestQuote.Dep1_DOB if (isDate(dt.value)==false){ dt.focus() return false } return true } function ValidateForm2(){ var dt=document.RequestQuote.Dep2_DOB if (isDate(dt.value)==false){ dt.focus() return false } return true } function ValidateForm3(){ var dt=document.RequestQuote.Dep3_DOB if (isDate(dt.value)==false){ dt.focus() return false } return true } function ValidateForm4(){ var dt=document.RequestQuote.Dep4_DOB if (isDate(dt.value)==false){ dt.focus() return false } return true } function ValidateForm5(){ var dt=document.RequestQuote.Dep5_DOB if (isDate(dt.value)==false){ dt.focus() return false } return true } function ValidateForm6(){ var dt=document.RequestQuote.Dep6_DOB if (isDate(dt.value)==false){ dt.focus() return false } return true } function ValidateForm7(){ var dt=document.RequestQuote.Dep7_DOB if (isDate(dt.value)==false){ dt.focus() return false } return true } </script> <script type="text/javascript"> <!-- function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_validateForm() { //v4.0 var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args); if (val) { nm=val.id; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == ''); } //--> </script> <script> function show_hide_column(col_no, do_show) { var stl; if (do_show) stl = 'block' else stl = 'none'; var tbl = document.getElementById('Single'); var rows = tbl.getElementsByTagName('tr'); for (var row=0; row<rows.length;row++) { var cels = rows[row].getElementsByTagName('td') cels[col_no].style.display=stl; } } </script> <script> /* Submit Once form validation- © Dynamic Drive (www.dynamicdrive.com) For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com */ function submitonce(theform){ //if IE 4+ or NS 6+ if (document.all||document.getElementById){ //screen thru every element in the form, and hunt down "submit" and "reset" for (i=0;i<theform.length;i++){ var tempobj=theform.elements if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") //disable em tempobj.disabled=true } } } </script> <script> <!-- function init() { prepareForm(); } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_validateForm() { //v4.0 var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args); if (val) { nm=val.id; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == ''); } function MM_callJS(jsStr) { //v2.0 return eval(jsStr) } function FDK_StripChars(theFilter,theString) { var strOut,i,curChar strOut = "" for (i=0;i < theString.length; i++) { curChar = theString.charAt(i) if (theFilter.indexOf(curChar) < 0) // if it's not in the filter, send it thru strOut += curChar } return strOut } function FDK_AllInRange(x,y,theString) { var i, curChar for (i=0; i < theString.length; i++) { curChar = theString.charAt(i) if (curChar < x || curChar > y) //the char is not in range return false } return true } function FDK_reformat(s) { var arg; var sPos = 0; var resultString = ""; for (var i = 1; i < FDK_reformat.arguments.length; i++) { arg = FDK_reformat.arguments; if (i % 2 == 1) resultString += arg; else { resultString += s.substring(sPos, sPos + arg); sPos += arg; } } return resultString; } function FDK_AddToValidateArray(FormName,FormElement,Validation,SetFocus) { var TheRoot=eval("document."+FormName); if (!TheRoot.ValidateForm) { TheRoot.ValidateForm = true; eval(FormName+"NameArray = new Array()") eval(FormName+"ValidationArray = new Array()") eval(FormName+"FocusArray = new Array()") } var ArrayIndex = eval(FormName+"NameArray.length"); eval(FormName+"NameArray[ArrayIndex] = FormElement"); eval(FormName+"ValidationArray[ArrayIndex] = Validation"); eval(FormName+"FocusArray[ArrayIndex] = SetFocus"); } function FDK_ValidateEmail(FormElement,Required,ErrorMsg) { var msg = ""; var val = FormElement.value; var msgInvalid = ErrorMsg; var theLen = FDK_StripChars(" ",val).length if (theLen == 0) { if (!Required) return ""; else return msgInvalid; } if (val.indexOf("@",0) < 0 || val.indexOf(".")<0) { msg = msgInvalid; } return msg; } function FDK_AddEmailValidation(FormName,FormElementName,Required,SetFocus,ErrorMsg) { var ValString = "FDK_ValidateEmail("+FormElementName+","+Required+","+ErrorMsg+")" FDK_AddToValidateArray(FormName,eval(FormElementName),ValString,SetFocus) } function FDK_ValidateUSPhone(FormElement,Required,ErrorMsg) { var msg = "" var theString = FormElement.value; var msgInvalid = ErrorMsg var theLen = FDK_StripChars(" \n\t\r",theString).length if (theLen == 0) if (!Required) return "" else return msgInvalid theString = FDK_StripChars("*() -./_\n\r",theString) if (!FDK_AllInRange("0","9",theString)) { msg = msgInvalid } else if (theString.length == 11) { if (theString.charAt(0) != "1") msg = msgInvalid } else if (theString.length != 10 && theString.length != 7) { msg = msgInvalid } if (msg == "") { if (theString.length == 10) FormElement.value=(FDK_reformat(theString,"(",3,") ",3,"-",4)) else if (theString.length == 7) FormElement.value=(FDK_reformat(theString,"",3,"-",4)) else //len == 11 FormElement.value=(FDK_reformat(theString,"",1,"(",3,") ",3,"-",4)) } return msg } function FDK_AddUSPhoneValidation(FormName,FormElementName,Required,SetFocus,ErrorMsg) { var ValString = "FDK_ValidateUSPhone("+FormElementName+","+Required+","+ErrorMsg+")" FDK_AddToValidateArray(FormName,eval(FormElementName),ValString,SetFocus) } function FDK_ValidateRadio(RadioGroup,ErrorMsg) { var msg = ErrorMsg; for (x=0;x<RadioGroup.length;x++) { if (RadioGroup[x].checked) { msg="" } } return msg; } function FDK_AddRadioValidation(FormName,FormElementName,SetFocus,ErrorMsg) { var ValString = "FDK_ValidateRadio("+FormElementName+","+ErrorMsg+")" FDK_AddToValidateArray(FormName,eval(FormElementName + '[0]'),ValString,SetFocus) } //--> </script> <link href="file:///C|/RND/richard.com/osstyle.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="file:///C|/RND/richard.com/menu.css" /> <style type="text/css"> <!-- .style10 { font-size: 16px; font-weight: bold; font-family: Verdana, Arial, Helvetica, sans-serif; } .style12 { font-size: 12px; font-weight: bold; font-family: Verdana, Arial, Helvetica, sans-serif; } .style13 {font-size: x-small; } .style15 { color: #FFFFFF; font-weight: bold; font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; } .req { background-color: #FFFF99; } body { background-color: #670065; } .stylehide { font-size: 6px; visibility: hidden; } .style18 {font-size: 10px} .style19 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold;} .style20 {font-size: 12px} .style23 { color: #E3E3E3; font-size: 4px; } --> </style> <link href="file:///C|/RND/richard.com/osstyle.css" rel="stylesheet" type="text/css" /> <style type="text/css"> } .style33 {color: #0000FF} --> </style></head> <body onload="prepareForm()"> <table border="2" cellpadding="8"> <tr> <td valign="top" bgcolor="#670065"><p> </p> </td> <td width="620" valign="top" bgcolor="#670065" class="rainbackgr"> <form action="http://RichHealthPlans.com/webber.php" method="get" enctype="multipart/form-data" name="quote_form" id="quote_form" onSubmit="MM_validateForm('First','','R','Last','','R','address1','','R','city','','R','Zip','','R','Email','','RisEmail','Phone','','R','Appl_DOB','','R','County','','R','Spouse_DOB','','R'); FDK_AddRadioValidation('quote_form','document.quote_form.Appl_Uses_Tobacco',true,'\'Field is required,\\nplease make a choice.\''); FDK_AddRadioValidation('quote_form','document.quote_form.Marital',true,'\'Field is required,\\nplease make a choice.\''); FDK_AddRadioValidation('quote_form','document.quote_form.Spouse_Sex',true,'\'Field is required,\\nplease make a choice.\''); FDK_AddRadioValidation('quote_form','document.quote_form.Spouse_Uses_Tobacco',true,'\'Field is required,\\nplease make a choice.\''); FDK_AddRadioValidation('quote_form','document.quote_form.Dep2_Sex',true,'\'Field is required,\\nplease make a choice.\''); FDK_AddRadioValidation('quote_form','document.quote_form.Dep3_Sex',true,'\'Field is required,\\nplease make a choice.\''); FDK_AddRadioValidation('quote_form','document.quote_form.Dep1_Sex',true,'\'Field is required ,\\nplease make a choice.\'');return document.MM_returnValue" > <table border="8" cellpadding="1" id="Form0"> <tr > <td width="80" height="26"><p class="style10">Applicant</p></td> <td width="515" colspan="4" valign="middle" bgcolor="#FFFF99"><div align="center" class="style33"><em>Required fields have this background </em></div></td> </tr> <tr> <td><div align="right" class="style12"> <p>First </p> </div></td> <td colspan="4"><div align="left" class="style12"> <p> <input name="First" id="First" type="text" class="req" size="20" tabindex="1" value="<?php echo $sessFirst; ?>"/> Last <input name="Last" id="Last" type="text" class="req" size="20" tabindex="2" value="<?php echo $sessLast; ?>" /> </p> </div></td> </tr> </table> </form></td> </tr> </table> <table><tbody id="waitingRoom" style="display: none"></tbody></table> <<!--WEBSITECEO:BEGIN:{764EEF2E-BC11-45CF-8627-300CE1BA2219}--> </body> </html> /code Quote Link to comment https://forums.phpfreaks.com/topic/114926-form-field-blank/#findComment-592811 Share on other sites More sharing options...
unkwntech Posted July 17, 2008 Share Posted July 17, 2008 I'm not understanding what the problem is. And you'll want to put code between \[code\] and \[/code\] Quote Link to comment https://forums.phpfreaks.com/topic/114926-form-field-blank/#findComment-592832 Share on other sites More sharing options...
jalea148 Posted July 18, 2008 Author Share Posted July 18, 2008 I'm not understanding what the problem is. And you'll want to put code between \[code\] and \[/code\] When I want to show my code, should it look like {i.e. are the square brackets included?} \[code\] my code \[/code\] The problem is form fields First & Last are initialized blank. They should be initialized with $sessFirst and $sessLast; that get their values from $_POST['First'] and $_POST['Last']. In Firefox, when the form appears, these fields appear null. However, if either field is double clicked a pull down menu appears with one of the menu lines containing the posted value. Other lines contain posted values from other trials – most several days old. In IE, nothing happens after the double click. Quote Link to comment https://forums.phpfreaks.com/topic/114926-form-field-blank/#findComment-593410 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.