Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
Dynamic form posting
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Jxck" data-source="post: 351907" data-attributes="member: 45068"><p>I have a site that produces form's from a table called 'form_parts' this the dictates what type of field it is, what the ghost text is and its ID etc. I then display this on pages that have 'link to form' active. I hope to then process this to mail it via the PHP mail function. However I don't know how to dynamically pull the fields (will be different fields for every page) and then email them as a content. Here is my existing code, I can't even get it to mail with basic hard coded contents.</p><p></p><p>$mail is defined in an include file that is required by the file that requires this file. It is the users email address. A lot of the code has been changed but I haven't changed the commenting from my original non-dynamic method which seemingly worked fine.</p><p></p><p>[code]</p><p></p><p><?php</p><p>//A temp check to see if the field 'Full Name' was completed before submission. What needs to happen is a check of all mandatory fields and highlight incomplete ones</p><p></p><p>if(isset($_REQUEST['submit'])){</p><p></p><p>//Basic information in order to send the email, for now the 'admin_email' is the track it monitor</p><p></p><p>$admin_email ="*";</p><p></p><p>//This pulls all the information that is required and not optional or based on another selection.</p><p></p><p></p><p>//Sending the mail function</p><p>mail($admin_email,"Testing self service.","testing","From:". $mail);</p><p></p><p>//The action performed after sending the email, in this case a dismissable balloon alert.</p><p>echo "Thank you for contacting us!";</p><p>}</p><p></p><p>else{</p><p>?></p><p><formmethod="post"></p><p><divclass='panel panel-default'></p><p><divclass='panel-body'id='form'></p><p><?php</p><p></p><p>$getFormQuery ="SELECT id,type,sortno,dropdownid,contentid,label,shadowtext,active FROM form_parts WHERE contentid = $contentid AND active = 1 ORDER BY sortno ASC"ordie("Error!:". mysqli_error($link));</p><p>$getForm = $link->query($getFormQuery);</p><p></p><p>while($formInfo = mysqli_fetch_array($getForm)){</p><p></p><p>$label = $formInfo["label"];</p><p>$ftype = $formInfo["type"];</p><p>$shadowtext = $formInfo["shadowtext"];</p><p></p><p>if(($ftype)=="Text"){</p><p>echo "<label>$label</label>";</p><p>echo "<br><center><input type='text' class='form-control' placeholder='$shadowtext'></center><br>";</p><p>}</p><p>if(($ftype)=="Date"){</p><p>echo "<label>$label</label>";</p><p>echo "<br><center><input type='date' class='form-control' placeholder='$shadowtext'></center><br>";</p><p>}</p><p>}</p><p></p><p>?></p><p><br></p><p><inputtype="submit"class="btn btn-success"value="Submit"></p><p></div></div></p><p></form></p><p></p><p><?php</p><p>}</p><p>?></p><p>[/code]</p></blockquote><p></p>
[QUOTE="Jxck, post: 351907, member: 45068"] I have a site that produces form's from a table called 'form_parts' this the dictates what type of field it is, what the ghost text is and its ID etc. I then display this on pages that have 'link to form' active. I hope to then process this to mail it via the PHP mail function. However I don't know how to dynamically pull the fields (will be different fields for every page) and then email them as a content. Here is my existing code, I can't even get it to mail with basic hard coded contents. $mail is defined in an include file that is required by the file that requires this file. It is the users email address. A lot of the code has been changed but I haven't changed the commenting from my original non-dynamic method which seemingly worked fine. [code] <?php //A temp check to see if the field 'Full Name' was completed before submission. What needs to happen is a check of all mandatory fields and highlight incomplete ones if(isset($_REQUEST['submit'])){ //Basic information in order to send the email, for now the 'admin_email' is the track it monitor $admin_email ="*"; //This pulls all the information that is required and not optional or based on another selection. //Sending the mail function mail($admin_email,"Testing self service.","testing","From:". $mail); //The action performed after sending the email, in this case a dismissable balloon alert. echo "Thank you for contacting us!"; } else{ ?> <formmethod="post"> <divclass='panel panel-default'> <divclass='panel-body'id='form'> <?php $getFormQuery ="SELECT id,type,sortno,dropdownid,contentid,label,shadowtext,active FROM form_parts WHERE contentid = $contentid AND active = 1 ORDER BY sortno ASC"ordie("Error!:". mysqli_error($link)); $getForm = $link->query($getFormQuery); while($formInfo = mysqli_fetch_array($getForm)){ $label = $formInfo["label"]; $ftype = $formInfo["type"]; $shadowtext = $formInfo["shadowtext"]; if(($ftype)=="Text"){ echo "<label>$label</label>"; echo "<br><center><input type='text' class='form-control' placeholder='$shadowtext'></center><br>"; } if(($ftype)=="Date"){ echo "<label>$label</label>"; echo "<br><center><input type='date' class='form-control' placeholder='$shadowtext'></center><br>"; } } ?> <br> <inputtype="submit"class="btn btn-success"value="Submit"> </div></div> </form> <?php } ?> [/code] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
Dynamic form posting
Top