|
Programming Guru
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 
|
<?php
$site = (isset($_GET['site'])) ? trim($_GET['site']) : "The forums";
?>
<html>
<head>
<title>Your own personal, yet generic welcome message to <?php echo $site; ?></title>
<script language="javascript" type="text/javascript">
window.onload = function() {
var welcomes = new Array(
"Welcome, %s, to <?php echo $site; ?>.",
"Welcome to <?php echo $site; ?>, %s.",
"Hey, %s, enjoy your stay at <?php echo $site; ?>!",
"Enjoy posting, %s, at <?php echo $site; ?>.",
"Hey, %s, hope you enjoy <?php echo $site; ?>.\n" +
"Its the new crack ya know...",
"<?php echo $site; ?>, %s, is like a big can of bugspray..."
);
// More to come...
var str = welcomes[Math.floor(Math.random() * welcomes.length)];
var newStr = " ";
var name = window.prompt("Hey, whats your tag?", "");
for(i=0;i<str.length;i++)
if(str.substr(i, 2) == "%s") {
newStr += name;
i++;
} else newStr += str.charAt(i);
alert(newStr.substr(1, newStr.length - 1));
window.close();
}
</script>
</head>
</html>
Couldnt decide wether to put it in JS or PHP, but since it had mroe JS, JS won...
__________________
|