Jxck
got that old thing back
- Apr 5, 2014
- 135
- 34
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.
$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
}
?>