I've two working domain names on a single server.

How do i forward all visitors to all files around the old temporary domain towards the new correct domain? Appears like this can be an Search engine optimization problem? But, because the temporary testing domain is not registered, wouldn't it be also indexed? Is a problem?

I am presently using:

RewriteEngine On
# Force to WWW
RewriteCond %{HTTP_HOST} ^thecorrectdomain\.com
RewriteRule (.*) http://www.thecorrectdomain.com/$1 [R=301,L]
#

The wrong domain may be the setup that people employed for testing, before we pointed the domain title towards the new server. The second reason is the right domain.

The wrong testing domain appears like: http://1234.hostingcompany.com/~username/index.php

The intended correct domain appears like: http://thecorrectdomain.com/index.php

Or perhaps is this something which the webhost needs to do at their level?

Presuming hostingcompany supports .htaccess. You produce a .htaccess in http://1234.hostingcompany.com/~username/ which consists of something similar to:

RewriteEngine On

#might not be necessary
RewriteBase /~username

RewriteRule .* http://thecorrectdomain.com/$0 [R=301]

PS while testing use 302, rather than 301.