PHP – Simple Email Sender

PHP – Email Sender

DOWNLOAD

 

You must create in the same folder 2 files:
1. email-form.php -> the email form
2. email-sender.php -> the PHP email sender engine

Simplest Email Sender – No Validation and Security controls

email-form.php

<html>
<body>
<!-- SIMPLE PHP EMAIL SENDER -->
<!-- Author: blog.lucedigitale.com - Andrea Tonin -->

<!-- FORM START -->
<!-- Il form invia a email-sender.php tutti i dati raccolti -->
<form method="post" action="email-sender.php">
Name: 
<br>
<input type="text" name="name">
<br>
E-mail: 
<br>
<input type="text" name="email">
<br>
Comment: 
<br>
<textarea name="comment" rows="5" cols="40"></textarea>
<br><br>
<input type="submit">
</form>
<!-- FORM END -->

</body>
</html>

email-sender.php

<?php 

// SIMPLE PHP EMAIL SENDER 
// Author: blog.lucedigitale.com - Andrea Tonin 

// EDIT THE 2 LINES BELOW AS REQUIRED
// email a cui inviare il messaggio e il suo soggetto
$email_to = "andreat@lucedigitale.com";
$email_subject = "New email from your website";

// $_REQUEST colleziona il dato ricevuto dal form 
$email_name = $_REQUEST['name']; 
$email_from = $_REQUEST['email']; 
$email_comment = $_REQUEST['comment']; 

$email_content = "\n Name: ".$email_name."\n Email: ".$email_from."\n Comment: \n"."\n".$email_comment;

// Create email headers
// Invio l'email all'indirizzo specificato nella variabile $email_to specificata all'inizio del codice
$headers = 'From: '.$email_name."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_content, $headers); 

// Messaggio di avvenuta spedizione, si arriva a questa porzione di codice solo se la parte precedente dello script ha funzionato correttamente
echo "Thanks! The mail has been sent successfully!";

?>
By |PHP, Web Design|Commenti disabilitati su PHP – Simple Email Sender

UNITY – JS Script – Ray casting

UNITY – JS Script – Ray casting

Ray casting is the use of ray-surface intersection tests to solve a variety of problems in computer graphics.
The first ray casting algorithm used for rendering was presented by Arthur Appel in 1968. The idea behind ray casting is to trace rays from the eye, one per pixel, and find the closest object blocking the path of that ray.

Ray casting traccia una linea da un oggetto verso l’infinito e ne rileva le intersezioni con altri oggetti. E’ come se l’oggetto avesse la capacità di vedere cosa si può intersecare con la sua traiettoria. Unity può tracciare linee di raycasting di lunghezza infinita, o limitata. Se la lunghezza è limitata tutti gli oggetti più lontani del limite imposto non saranno “visibili”. Il ray casting si basa sulla matematica dei vettori.

unity-raycasting

JAvascript Statement

static function Raycast(origin: Vector3, direction: Vector3, hitInfo: RaycastHit, distance: float = Mathf.Infinity, layerMask: int = DefaultRaycastLayers): bool;

origin: Vector3, -> l’origine del raggio (vettore)

direction: Vector3, -> la direzione del raggio (vettore)

hitInfo: RaycastHit, -> rileva se vi sono intersezioni

distance: float = Mathf.Infinity, -> lunghezza del raggio, se omesso = infinito

layerMask: int = DefaultRaycastLayers -> layer che saranno ignorati nel Ray casting

CASE 1: Raycast Debug.Log

1. Create a Sphere that falls and bource over a Cube (You have to use Physics 3D engine)

2. Attach to the Ball the script:

#pragma strict

function Update () {
		var hit : RaycastHit;
		if (Physics.Raycast (transform.position, -Vector3.up, hit)) {
			var distanceToGround = hit.distance;
                        // Casts a ray against all colliders in the scene 
                        // and returns detailed information on what was hit
			Debug.Log (distanceToGround);
		}
	}

CASE 2: Raycast Debug.Log + if

#pragma strict

function Update () {
    // function Update START -------------------------
		var hit : RaycastHit;
		if (Physics.Raycast (transform.position, -Vector3.up, hit)) {
			var distanceToGround = hit.distance;
			// Casts the ray against all colliders in the scene 
            // and returns detailed information on what was hit
			Debug.Log (distanceToGround);
			
			// Distance Controller START
			if (distanceToGround < 1)
       		{
             // Do a set of actions
             Debug.Log ("---- BOUNCE ----");
			}
			// Distance Controller END
		}
		
	// function Update END ----------------------------
	}

CASE 2: Raycast Debug.Log + if + function

#pragma strict

function Update () {
    // function Update() START -------------------------
		var hit : RaycastHit;
		
		// if Physics.raycast START
		if (Physics.Raycast (transform.position, -Vector3.up, hit)) {
			var distanceToGround = hit.distance;
			// Casts the ray against all colliders in the scene 
            // and returns detailed information on what was hit
			Debug.Log (distanceToGround);
			
			// Distance Controller START
			if (distanceToGround < 1)
       		{
             // Call a function           
             Bounce();
			}
			// Distance Controller END
		}
		// if Physics.raycast END
		
	// function Update() END ----------------------------
	}
	
	function Bounce ()
{
    Debug.Log ("---- BOUNCE FUNCTION ----");;
}
By |Unity3D|Commenti disabilitati su UNITY – JS Script – Ray casting

UNITY – JS Script – OnTrigger – Destroy

UNITY – JS Script – OnTrigger – Destroy

It will destroy the object if it enters or exit the trigger

1. Create a Sphere that falls and bource over a Box (You have to use Physics 3D engine)

2. Select the Box> Inspector> Box Collider> check ‘Is Trigger’, now the Box does not create collision, instead the Ball pass through it and this can be detected via code.

3. Attach to the Box the script

It will destroy the object if it enters the trigger


#pragma strict

function Start () {

}

// Destroy everything that enters the trigger START

	function OnTriggerEnter (other : Collider) {
		Destroy(other.gameObject);
	}

// Destroy everything that enters the trigger END


function Update () {


}

OR

It will destroy the object if it exit the trigger


#pragma strict

function Start () {

}

// Destroy everything that leaves the trigger START

	function OnTriggerExit (other : Collider) {
		Destroy(other.gameObject);
	}

// Destroy everything that leaves the trigger END


function Update () {


}

By |Unity3D|Commenti disabilitati su UNITY – JS Script – OnTrigger – Destroy

UNITY – JS Script – OnTrigger

UNITY – JS Script – OnTrigger

1. Create a Sphere that falls and bource over a Box (You have to use Physics 3D engine)

2. Select the Box> Inspector> Box Collider> check ‘Is Trigger’, now the Box does not create collision, instead the Ball pass through it and this can be detected via code.

3. Attach to the Box the script


#pragma strict

function Start () {

}

function OnTriggerEnter (other : Collider) {
		print("Trigger Enter");
}

function OnTriggerStay (other : Collider) {
		print("Trigger Stay");
}

function OnTriggerExit (other : Collider) {
		print("Trigger Exit");
}

function Update () {


}

Unity has 3 OnCollision events:

1. OnTriggerEnter

TRUE at first frame of the collision
VERO al primo frame della collisione

2. OnTriggerStay

TRUE for some frames, until the colliders are still in contact
VERO per diversi frames, finchè i colliders sono in contatto

3. OnTriggerExit

TRUE the first frame when the colliders are no longer in contact
VERO al primo frame che perdono il contatto

NOTICE: put – function OnCollision – OUTSIDE Start() or Update()

By |Unity3D|Commenti disabilitati su UNITY – JS Script – OnTrigger

UNITY – JS Script – OnCollision

UNITY – JS Script – OnCollision

1. Create a Sphere that falls and bource over a Box (You have to use Physics 3D engine)

2. Attach to the Sphere the script


#pragma strict

function Start () {

}

function OnCollisionEnter(collisionInfo : Collision) {
		print("Collision Enter");
}

function OnCollisionStay(collisionInfo : Collision) {
		print("Collision Stay");
}

function OnCollisionExit(collisionInfo : Collision) {
		print("Collision Exit");
}

function Update () {


}

Unity has 3 OnCollision events:

1. OnCollisionEnter

TRUE at first frame of the collision
VERO al primo frame della collisione

2. OnCollisionStay

TRUE for some frames, until the colliders are still in contact
VERO per diversi frames, finchè i colliders sono in contatto

3. OnCollisionExit

TRUE the first frame when the colliders are no longer in contact
VERO al primo frame che perdono il contatto

NOTICE: put – function OnCollision – OUTSIDE Start() or Update()

By |Unity3D|Commenti disabilitati su UNITY – JS Script – OnCollision