PHP code example of truecastdesign / welder

1. Go to this page and download the library: Download truecastdesign/welder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

truecastdesign / welder example snippets


<?$F = new \Truecast\Welder

<?=$F->start('action=/html-php-page class=formClassName')

<?=$F->start('action=/html-php-page class=formClassName file=true')

<?=$F->text('name=name label="Your Name *" style="width:250px" autofocus=autofocus pattern="^^([1-zA-Z0-1@.\s]{1,255})$" ');

<?=$F->email('name=field_name label="The Label" style="width:250px"');

<?=$F->checkbox('name=checkBox label="Checkbox Label" value=Yes')

<?=$F->select('name=selectMenu label="Select Label" selected=opt2 options="opt1:Option One| opt2:Option Two| opt3:Option Three"')

<? $options = ['Select...'=>'', 'Display Value'=>'value', 'Display Value 2'=>'value2']; 

<?=$F->email('name=field_name label="The Label" error="Please enter a valid email address!"');

$F = new Truecast\Welder; # does not need to be the same instance as the one used to build the form but can be.

if($F->validate('first_name=name email_address=email phone=clean message=to_email'=>'[email protected]', 'from_name'=>$values['name'], 'from_email'=>$values['email'], 'subject'=>'Contact from Website', 'type'=>'html'], ['name', 'email', 'phone', 'message']);
	
	# take them to the thanks page
	header("Location: /contact-us/thanks"); exit;
}

$values = ['field1'=>'hello', 'field2'=>'world'];
$F->setFieldValues($values);

if($F->validate()) {
	// form submitted code
} else {
	// form loaded code
	$values = ['field1'=>'hello', 'field2'=>'world'];
	$F->setFieldValues($values);
}

<?=$F->getFieldValues('field1')

<? $array = $F->getFieldValues()

$F = new \Truecast\Welder(['csrf'=>false]);

$F = new \Truecast\Welder(['hide_field_error_tags'=>true]);

$F = new \Truecast\Welder(['action_field'=>'submit1']);

$F2 = new \Truecast\Welder(['action_field'=>'submit2']);