Insert Records into custom object by using Apex Programming:

In this scenario we used custom controller, Apex:inputtext and apex:command Button for inserting records into custom object.

Visualforce Page:-

<apex:page sidebar="false" controller="DataLoadTestingClass">
<apex:form >
<div style="border:1px solid; width:200px;">
<div style="height:30px;width:150px;margin-top:20px;margin-left:20px;font-size:15px;color:blue;">
DATALOADTESTING
</div>
<table>
<tr>
<td>
Name
</td>
<td>
<apex:inputtext value="{!nameVal}"/>
</td>
</tr>
<tr>
<td>
City
</td>
<td>
<apex:inputtext value="{!cityVal}" />
</td>
</tr>
<tr>
<td>
Country
</td>
<td>
<apex:inputtext value="{!countryVal}" />
</td>
</tr>
<tr>
<td>
Phone
</td>
<td>
<apex:inputtext value="{!phoneVal}"/>
</td>
</tr>
<tr >
<td colspan="2" align="center">
<apex:commandButton value="INSERT" style="color:red;" action="{!doInsert}" />
</td>
</tr>
</table>
</div>
</apex:form>
</apex:page>

Apex Class:-

public with sharing class DataLoadTestingClass {
public String phoneVal { get; set; }
public String countryVal { get; set; }
public String cityVal { get; set; }
public String nameVal { get; set; }
public PageReference doInsert() {
DataloadTest__c objdlt = new DataLoadTest__c();
objdlt.name=nameVal;
objdlt.city__c=cityVal;
objdlt.country__c=countryVal;
objdlt.phone__c=phoneVal;
insert objdlt;
pagereference ref = new pagereference('/apex/insertdlttest');
ref.setredirect(true);
return ref;
}
}