Jump to content

WYS


whiteboikyle

Recommended Posts

Is not working for some odd reason...

 

<script language="Javascript">
var Editor; 
function Format(action) { 
	Editor.execCommand(action, false, null); 
} 
function Colour(colour) { 
	Editor.execCommand("forecolor",false, colour); 
} 
window.onload = function() { 
	Editor = document.getElementById('textbox').contentWindow.document; 
	Editor.designMode = "on"; 
	document.forms[0].onsubmit = function() { 
		var text = document.getElementById('text'); 
		text.value = Editor.body.innerHTML; 
	} 
} 
function createURL() { 
	if (window.attachEvent == undefined) { 
		var url = prompt("Enter an url",""); 
		if(!url.match("(^(http|https|ftp|ftps)://)")) { 
			url="http://"+url; 
		} 
		Editor.execCommand("inserthtml", false, '<a href="' + url + '">' + url + '</a>'); 
	} else { 
		document.getElementById('textbox').contentWindow.focus(); 
		Editor.execCommand("CreateLink",true); 
	} 
} 
function createPicture(){
	if (window.attachEvent == undefined) { 
		var url = prompt("Enter URL of Picture",""); 
		if(!url.match("(^(http|https|ftp|ftps)://)")) { 
			url="http://"+url; 
		} 
		Editor.execCommand("inserthtml", false, '<img src="' + url + '" style="max-height:400px; max-width:400px;>');
	} else { 
		document.getElementById('textbox').contentWindow.focus(); 
		Editor.execCommand("InsertImage",true); 
	} 
} 
</script>
<?php
if(isset($_GET['function'])){
	$error = "";
	$eCount = 0;
	$complete = 0;
	if(isset($_POST['Submit'])){
		$name = $_POST['name'];
		$subject = $_POST['subject'];
		$FName = $_POST['function_name'];
		$body = $_POST['text'];
		die($_POST['text']);
		$date = time();
		$cat = $_POST['cat'];

		if(get_magic_quotes_gpc()){
			$subject = stripslashes($subject);
			$body = stripslashes($body);
			$name = stripslashes($name);
		}
		$subject = mysql_real_escape_string($subject);
		$body = mysql_real_escape_string($body);
		$name = mysql_real_escape_string($name);

		if(HTML == 0){
			$name = strip_tags($name);
			$subject = strip_tags($subject);
			$body = strip_tags($body);
		}
		if(strlen($name) <= 1){
			$error++;
			echo("There was an error! Seems that your name was zero charcters long?<br />");
		}
		if(strlen($subject) < 2){
			$error++;
			echo("Your subject text was less then 2 charcters!<br />");		
		}
		if(strlen($body) < 10){
			$error++;
			echo("Your body text was less then 10 charcters!<br />");		
		}
		if($error == 0){
			$complete = 1;
			$result1 = $config->query("INSERT INTO news (ID, name, subject, body, date, cat) VALUES (NULL, '$name', '$subject', '$body', '$date', '$cat')");	
			echo("Your news has been submitted! <br />
				 Click <a href='main.php'>Countinue</a>.");
		}

	}
if($complete == "1"){
	echo("You have successfully purchased '$itemname' and was notified to the Higher Ranks and <br />
		 <a href='./main.php'>Go to main?</a>");
}
else{
	//Print out the errors
	if($eCount > 0){
		echo("<font color='red'>".$error."</font>");
	}
?>
<form action="./view.php?function=news" method="POST">
  <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="7%"><div align="left"><Font size="1" face="arial">Name:</font></div></td>
        <td width="93%"><div align="left"><Font face="arial" size="2"><b>
          <input type="hidden" name="name" value="<?php echo($myusername); ?>">
        <?php echo($myusername); ?></b></font></div></td>
      </tr>
      <tr>
        <td><div align="left"><Font size="1" face="arial">Title:</font></div></td>
        <td><div align="left"><Font face="arial" size="1">
          <input name="subject" type="text" size="40" maxlength="100">
        </font></div></td>
      </tr>
      <tr>
        <td colspan="2"><Font face="arial" size="1">News Category:
            <br />
        <select name="cat" id="cat" style="width:350px;">
             <option value="A">Admin</option>
              <option value="SC">StarCraft</option>
              <option value="CSS">Counter-Strike Source</option>
              <option value="D2">Diablo2</option>
              <option value="GW">Guild Wars</option>
              <option value="UN">Urgent News</option>
              <option value="WoW">World Of Warcraft</option>
              <option value="W3">Warcraft III</option>
              <option value="F">Forums</option>
            
        </select>
            <br />
        </font></td>
      </tr>
      <tr>
         <td colspan="2"><Font face="arial" size="1">Text:<br />
         <div style="width:400px;">
<div align="left" style="padding:2px; background-color:#7F7F7F">  
<input type="button" onClick="Colour('White')" style="background-color:#CCC; background-image:url(images/white.png); background-position:center; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" />
<input type="button" onClick="Colour('Yellow')" style="background-color:#CCC; background-image:url(images/yellow.png); background-position:center; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" />
<input type="button" onClick="Colour('Green')" style="background-color:#CCC; background-image:url(images/green.png); background-position:center; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" />  
<input type="button" onClick="Colour('Red')" style="background-color:#CCC; background-image:url(images/red.png); background-position:center; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" />  
<input type="button" onClick="Colour('Pink')" style="background-color:#CCC; background-image:url(images/pink.png); background-position:center; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" />  
<input type="button" onClick="Colour('Orange')" style="background-color:#CCC; background-image:url(images/orange.png); background-position:center; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" />  
<input type="button" onClick="Colour('Blue')" style="background-color:#CCC; background-image:url(images/blue.png); background-position:center; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" />  
<input type="button" onClick="Colour('Purple')" style="background-color:#CCC; background-image:url(images/purple.png); background-position:center; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" /> 
<input type="button" onClick="Colour('Black')" style="background-color:#CCC; background-image:url(images/black.png); background-position:center; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" /><br />  
<input type="button" onClick="createURL()" style="background-color:#CCC; background-image:url(images/link.png); background-position:center; background-repeat:no-repeat; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" />  
<input type="button" onClick="createPicture()" style="background-color:#CCC; background-image:url(images/camera.png); background-position:center; background-repeat:no-repeat; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" />  
<input type="button" onClick="Format('bold')" style="background-color:#CCC; background-image:url(images/bold.png); background-position:center; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" />  
<input type="button" onClick="Format('italic')" style="background-color:#CCC; background-image:url(images/italic.png); background-position:center; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" />  
<input type="button" onClick="Format('Underline')" style="background-color:#CCC; background-image:url(images/underline.png); background-position:center; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" />
<input type="button" onClick="Format('justifyleft')" style="background-color:#CCC; background-image:url(images/left.png); background-position:center; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" />
<input type="button" onClick="Format('justifycenter')" style="background-color:#CCC; background-image:url(images/center.png); background-position:center; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" />
<input type="button" onClick="Format('justifyright')" style="background-color:#CCC; background-image:url(images/right.png); background-position:center; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" />
<input type="button" onClick="Format('InsertUnorderedList')" style="background-color:#CCC; background-image:url(images/list.png); background-position:center; background-repeat:no-repeat; border-style:solid; border-color:#000; border-width:1px; width:25px; height:25px;" />
</div>
<div align="center">
<iframe id="textbox" style="width:398px; height:200px; border-style:solid; border-width:1px; background-color:#FFF;"></iframe>
<input type="hidden" id="text" name="text" />
</div> 
</div>
         </font></td>
      </tr>
  </table>
<Font face="arial" size="1">
<center>
	<input type="hidden" name="news_post" value="1">
        <input name='function_name' type='hidden' value='news' />
  <input name="Submit" type="submit" id="Submit" value="Submit">
</center>
</font>
</form>
<?php
}
}else{
die("<center>Your trying to view a retricted page!</center>");
}	
?>

 

THe $_POST['text'] echo's nothing at all for some reason..

Link to comment
Share on other sites

  • 2 weeks later...

Could it be because

<input type="hidden" id="text" name="text" />

has no value assigned to it ?

window.onload = function() { 
Editor = document.getElementById('textbox').contentWindow.document; 
Editor.designMode = "on"; 
document.forms[0].onsubmit = function() { 
var text = document.getElementById('text'); 
text.value = Editor.body.innerHTML; 
} 
} 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.