Post by Dexx on Nov 11, 2005 22:05:19 GMT
* You need a host that supports PHP to use this. Im sure it could be done with just javascript too. But i dont know how
What will this script do?
It will add a input button to the other buttons below with the value + or -. Clicking the button when it has a + will save the current name in the Name field and store it in a cookie. When the value is - you delete the current name in the cookie.
The Code
How do i use it?
Create a new file, name it to whatever you want, but I took saybox.php. Now place the code above.
But edit:
URL=saybox.php - to what you name the page
USERNAME - your username on saybox
and saybox.co.uk to saybox2.co.uk if you're on server2
Now it just to link it to your site by using a frame (Works best because each time + or - is pressed the page refreshes)
<iframe src="saybox.php" style="width: 150px; height: 350px; border: 0px" frameborder="0" scrolling="no"></iframe>
Example;
kaffekokare.se/sb_SaveName.php
What will this script do?
It will add a input button to the other buttons below with the value + or -. Clicking the button when it has a + will save the current name in the Name field and store it in a cookie. When the value is - you delete the current name in the cookie.
The Code
<?PHP
ob_start();
define('BR', "
");
if(isset($_GET['save'])){
setCookie('sbName', $_GET['save'], time()+3600, '/');
header('Location: saybox.php');
die;
}
if(isset($_GET['del'])){
setCookie('sbName', '', time()-3600, '/');
header('Location: saybox.php');
die;
}
?>
<script language="javascript" src="http://saybox.co.uk/output.php?user=Dexxaboy"></script>
<script language="javascript">
function sbSaveName(){
if(document.sayboxform.saybox_name.value != 'Your Name'){
window.location = '?save='+document.sayboxform.saybox_name.value
}
}
function sbDelName(){
window.location = '?del';
}
<?PHP
if(isset($_COOKIE['sbName'])){
echo 'document.sayboxform.saybox_name.value = "'.$_COOKIE['sbName'].'";'.BR;
echo 'document.getElementById(\'SBbuttons\').innerHTML = document.getElementById(\'SBbuttons\').innerHTML+\'<input type="button" value="-" onClick="sbDelName();" class="SBinput" style="margin-right: 2px;" />\';'.BR;
}
else{
echo 'document.getElementById(\'SBbuttons\').innerHTML = document.getElementById(\'SBbuttons\').innerHTML+\'<input type="button" value="+" onClick="sbSaveName();" class="SBinput" style="margin-right: 2px;" />\';'.BR;
}
?>
</script>
</div>
ob_start();
define('BR', "
");
if(isset($_GET['save'])){
setCookie('sbName', $_GET['save'], time()+3600, '/');
header('Location: saybox.php');
die;
}
if(isset($_GET['del'])){
setCookie('sbName', '', time()-3600, '/');
header('Location: saybox.php');
die;
}
?>
<script language="javascript" src="http://saybox.co.uk/output.php?user=Dexxaboy"></script>
<script language="javascript">
function sbSaveName(){
if(document.sayboxform.saybox_name.value != 'Your Name'){
window.location = '?save='+document.sayboxform.saybox_name.value
}
}
function sbDelName(){
window.location = '?del';
}
<?PHP
if(isset($_COOKIE['sbName'])){
echo 'document.sayboxform.saybox_name.value = "'.$_COOKIE['sbName'].'";'.BR;
echo 'document.getElementById(\'SBbuttons\').innerHTML = document.getElementById(\'SBbuttons\').innerHTML+\'<input type="button" value="-" onClick="sbDelName();" class="SBinput" style="margin-right: 2px;" />\';'.BR;
}
else{
echo 'document.getElementById(\'SBbuttons\').innerHTML = document.getElementById(\'SBbuttons\').innerHTML+\'<input type="button" value="+" onClick="sbSaveName();" class="SBinput" style="margin-right: 2px;" />\';'.BR;
}
?>
</script>
</div>
How do i use it?
Create a new file, name it to whatever you want, but I took saybox.php. Now place the code above.
But edit:
URL=saybox.php - to what you name the page
USERNAME - your username on saybox
and saybox.co.uk to saybox2.co.uk if you're on server2
Now it just to link it to your site by using a frame (Works best because each time + or - is pressed the page refreshes)
<iframe src="saybox.php" style="width: 150px; height: 350px; border: 0px" frameborder="0" scrolling="no"></iframe>
Example;
kaffekokare.se/sb_SaveName.php