function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gage Staruch 9Gage Staruch 9 

query contacts agains variable on controller to update value

I am trying to put in a query for a value that is entered in a field on the visual force page. When the submit button is selected it will go through and query the contact data and match the email address on that to the text field that we have created on the vf page. Once it has found a match it will update the contact id on the case record and insert the data. 
public class attachController
    public case objcase{get;set;}
    public Attachment myAttachment{get;set;}
    public string fileName{get;set;}
    public Blob fileBody{get;set;}
    RecordType recordId = [SELECT Id FROM RecordType WHERE DeveloperName = 'Product_Case'];
    Id recId = (recordId != null) ? recordId.Id : null;
    Group queueId = [select Id from Group where Type = 'Queue' AND DeveloperNAME = 'Product_Support_Case_Queue' LIMIT 1];
    Id ownerId = (queueId != null) ? queueId.Id : null;
    Contact emailContact = [SELECT Id, Email FROM Contact WHERE Email = objcase.email__c LIMIT 1]
        id conId = (emailContact != null) ? emailContact.Id : null;
    public attachController(Apexpages.standardcontroller controller)
        objcase = (Case)controller.getRecord();
        myAttachment = new Attachment();
    public PageReference submit(){
        if (fileName != null){
            objcase.RecordTypeId = recId;
            objcase.ownerId = ownerId;
            objcase.ContactId = conId;
            insert objcase;
            myAttachment = new Attachment();
            Integer i=0;
            myAttachment .clear();
            myAttachment.Body = fileBody;
            myAttachment.Name = fileName ;
            myAttachment.ParentId =;            
            insert myAttachment;
        } else {
            objcase.RecordTypeId = recId;
            objcase.ownerId = ownerId;
            insert objcase;
        pagereference pr = Page.thankYouForSubmittingYourProductCase;                          
        return pr;