Jump to content

thibo1025

Members
  • Posts

    118
  • Joined

  • Last visited

Posts posted by thibo1025

  1. when I copied and pasted the code I had to translate it form what I had to a more basic version and I forgot to deleate a part.Thanks cocolate.However I might want to know how to change the font of an option but I read it could not be done in CSS... I found a tutorial using JS that makes the select act like a list:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>  <title>Select Replacement Test</title>  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />  <meta http-equiv="Content-Language" content="en-us" />  <style type="text/css">	}	input {	  display: block;	  margin: 0 0 0px;	  color: #ffffff;	}	select {	  display: block;	  width: 300px;	}	select.replaced {	  display: none;	}	ul.selectReplacement {	  margin: 0;	  padding: 0;	  height: 1.65em;	  width: 300px;	}	ul.selectReplacement li {	  background: #ffffff;	  color: #000000;	  cursor: pointer;	  display: none;	  font-size: 11px;	  line-height: 1.7em;	  list-style: none;	  margin: 0;	  padding: 0px 12px;	  width: 276px;	  border: solid 1px #000000;	}	ul.selectOpen li {	  display: block;	}	ul.selectReplacement li.selected {	  background: url(../tytd/images/fleche.gif) top right no-repeat;	  color: #000000;	  border: solid 1px #000000;	  display: block;	}	ul.selectOpen li.selected {	  background: #ffffff;	  display: block;	  border: solid 1px #000000;	}	ul.selectOpen li:hover,	ul.selectOpen li.hover,	ul.selectOpen li.selected:hover {	  background: #CCCCCC;	  color: #000000;	  border: solid 1px #000000;	}  </style>  <script type="text/javascript">	function selectReplacement(obj) {	  obj.className += ' replaced';	  var ul = document.createElement('ul');	  ul.className = 'selectReplacement';	  var opts = obj.options;	  for (var i=0; i<opts.length; i++) {		var selectedOpt;		if (opts[i].selected) {		  selectedOpt = i;		  break;		} else {		  selectedOpt = 0;		}	  }	  for (var i=0; i<opts.length; i++) {		var li = document.createElement('li');		var txt = document.createTextNode(opts[i].text);		li.appendChild(txt);		li.selIndex = opts[i].index;		li.selectID = obj.id;		li.onclick = function() {		  selectMe(this);		}		if (i == selectedOpt) {		  li.className = 'selected';		  li.onclick = function() {			this.parentNode.className += ' selectOpen';			this.onclick = function() {			  selectMe(this);			}		  }		}		if (window.attachEvent) {		  li.onmouseover = function() {			this.className += ' hover';		  }		  li.onmouseout = function() {			this.className = 			  this.className.replace(new RegExp(" hover\\b"), '');		  }		}		ul.appendChild(li);	  }	  obj.parentNode.insertBefore(ul,obj);	}	function selectMe(obj) {	  var lis = obj.parentNode.getElementsByTagName('li');	  for (var i=0; i<lis.length; i++) {		if (lis[i] != obj) {		  lis[i].className='';		  lis[i].onclick = function() {			selectMe(this);		  }		} else {		  setVal(obj.selectID, obj.selIndex);		  obj.className='selected';		  obj.parentNode.className = 			obj.parentNode.className.replace(new RegExp(" selectOpen\\b"), '');		  obj.onclick = function() {			obj.parentNode.className += ' selectOpen';			this.onclick = function() {			  selectMe(this);			}		  }		}	  }	}	function setVal(objID, selIndex) {	  var obj = document.getElementById(objID);	  obj.selectedIndex = selIndex;	}	function setForm() {	  var s = document.getElementsByTagName('select');	  for (var i=0; i<s.length; i++) {		selectReplacement(s[i]);	  }	}	window.onload = function() {	  (document.all && !window.print) ? null : setForm();	}  </script></head><body><form><select name="font" id="font"><option select>font</option><option value="Arial"><font face="Arial">Arial</font></option><option value="Arial Black"><font face="Arial Black">Arial Black</font></option><option value="Arial Narrow"><font face="Arial Narrow">Arial Narrow</font></option><option value="Book Antiqua">Book Antiqua</option><option value="Century Gothic">Century Gothic</option><option value="Comic Sans MS">Comic Sans MS</option><option value="Courier New">Courier New</option><option value="Franklin Gothic Medium">Franklin Gothic Medium</option><option value="Garamond">Garamond</option><option value="Georgia">Georgia</option><option value="Impact">Impact</option><option value="Lucida Console">Lucida Console</option><option value="Lucida Sans Unicode">Lucida Sans Unicode</option><option value="Microsoft Sans Serif">Microsoft Sans Serif</option><option value="Palatino Linotype">Palatino Linotype</option><option value="Tahoma">Tahoma</option><option value="Times New Roman">Times New Roman</option><option value="Trebuchet MS">Trebuchet MS</option><option value="Verdana">Verdana</option></select></form></body></html>

    An It works out well only the font still dosent change...

  2. I have my bbcode installed and I have a problem with a dropdown as buttonWhat I have tryed out is

    <select name="font" ><option select>Font</option><option onClick="txt.value+='[font=Times New Roman]text[/font]';"><><spanfont face="Times New Roman">Times New Roman</font></option><option onClick="txt.value+='[font=Comic Sans MS]text[/font]';"><font face="Comic Sans MS">Comic Sans MS</font></option></select>

    I cant figure how to make it work, my textarea is:

    <textarea cols='90' rows='10' id='txt' name='text'></textarea>

    note that inside the dropdown the font tag isn't doing anything...

  3. sure let me show you:

    <?phpsession_start();$logged_in = false;$msg = "";if ($_SESSION['online']){  $logged_in = true;}elseif (isset($_POST['username'])){$db=mysql_connect("localhost", "root", "");mysql_select_db("jny", $db);$username = mysql_real_escape_string(htmlentities($_POST['username']));$password = mysql_real_escape_string(htmlentities($_POST['password']));$query = mysql_query("SELECT username, password FROM Users WHERE username = '$username' AND password = '$password'");if(mysql_num_rows($query) == 1) {$_SESSION['online'] = true;$_SESSION['username'] = $username;$logged_in = true; }else{$msg .= "The username and password did not match.<br /><br />";}mysql_free_result($query); mysql_close($db);echo "<html>\n"; echo "<head>\n";/* Dont U want a title to your page */echo "</head>\n";echo "<body>\n";echo $msg;if ($logged_in) { include('[b]current page[/b]'); //Without the includes!!echo "<h1>Login</h1>\n<form action='' method='post'>\n<p>Username<br /><input type='text' name='username' /></p>\n<p>Password<br /><input type='password' name='password' /></p>\n<p>\n<br /><input type='submit' name='submit' value='Login' /></p>\</form>";}echo "</body></html>";?>

  4. right so In stead of righttingecho"There is a problem with the file";I should put echo $_FILES['file']['error'] ;right?well than:as the errors return in numbers, could you telle me what these number mean?

  5. to get data out of a database:

    <?php$con = mysql_connect("[b]host[/b]","[b]user[/b]","[b]pass[/b]");if (!$con){  die('Could not connect: ' . mysql_error());  }mysql_select_db("[b]database[/b]", $con);$result = mysql_query("SELECT [b]col name[/b] FROM [b]table[/b]"); while($row = mysql_fetch_array($result)){//$row['[b]col name[/b]'] is your value.}mysql_close($con);?>

    In Your Case:for the registration

    $db=mysql_connect("localhost", "root", "");mysql_select_db("jny", $db);$username = mysql_real_escape_string(htmlentities($_POST['username']));$password = mysql_real_escape_string(htmlentities($_POST['password']));$query = mysql_query("SELECT username, password FROM Users WHERE username = '$username' AND password = '$password'");if(mysql_num_rows($query) == 1) {  $_SESSION['online'] = true;  $_SESSION['username'] = $username;  $logged_in = true;  }else{  $msg .= "The username and password did not match.<br /><br />";}  mysql_free_result($query);   mysql_close($db);

  6. humm... I propose We see your attempt of script first because what you are asking is rather complicated...But I can help you a bit for few reasons:$_POST['name'] is an arraw and not a function. it contains the value of the input called name in a form.what do you mean by "in a row"? you mean if you have an arraw that contains differant values you could compare the values in the arraw?That is possible with a foreach method.Read the php tutorial of W3schools

  7. the problem is not there, whenever the file is in ".wma" or that the file contains a space, the sending fails:if the file is in ".wma"the array $_FILES is emptyif the file contains a spaceit returns"There is a problem with the file." (wich is my error message in the script)Is it normal or not?

  8. I know that but the content of the directory is only files, the files in it are uploaded by php on another script so this is exactly what I was looking for.

  9. I am using the formular used given by W3schools and when I try to upload a file, I have to be sure that this file dose not contain spaces in it's title otherwise he dose not understand that it is a file. How could I fix this?

    //page where the form is.echo "<form action='file.php' method='post' enctype='multipart/form-data'>\n";echo "<label for='file'>File:</label>\n";echo "<input type='file' name='file' id='file' />\n";echo "<br />\n";echo "<input type='submit' name='submit' value='OK' />\n";echo "</form>\n";

    //My file.php pageif ($_FILES["file"]["error"] > 0){ // this is my line 42.  echo "There is a problem with the file.";}else{  echo "File: " . $_FILES["file"]["name"] . "<br />\n";  echo "Type: " . $_FILES["file"]["type"] . "<br />\n";  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />\n";  if (file_exists("fichiers/" . $_FILES["file"]["name"])){	echo "the file '" . "fichiers/" . $_FILES["file"]["name"] . "' already exists.";  }  else{// Enrogistrement du fichier dans "fichiers/":	move_uploaded_file($_FILES["file"]["tmp_name"],"fichiers/" . $_FILES["file"]["name"]);	echo "the file '" . "fichiers/" . $_FILES["file"]["name"] . "' was saved.";  }}

    and this is what I get!

    Notice: Undefined index: file in ***********\file.php on line 42Notice: Undefined index: file in ***********\file.php on line 46Notice: Undefined index: file in ***********\file.php on line 47 Notice: Undefined index: file in ***********\file.php on line 48Notice: Undefined index: file in ***********\file.php on line 49Notice: Undefined index: file in ***********\file.php on line 50
    or my message There is an error with the file.any help for fixing errors?
  10. w3schools says you need to put the sessions on the top...So maybe you could go like this:

    <?php/* check login script, included in db_connect.php. */$last_active = $_SESSION['last_active'];session_start();if (!isset($_SESSION['username']) || !isset($_SESSION['password'])) {	$logged_in = 0;	return;} else {	if($last_active<$time) {	   $timeout = 1;	   require "logout.php";	}	// remember, $_SESSION['password'] will be encrypted.	if(!get_magic_quotes_gpc()) {		$_SESSION['username'] = addslashes($_SESSION['username']);	}	// addslashes to session username before using in a query.	$pass = $db_object->query("SELECT password FROM users WHERE username = '".$_SESSION['username']."'");	if(DB::isError($pass) || $pass->numRows() != 1) {		$logged_in = 0;		unset($_SESSION['username']);		unset($_SESSION['password']);		// kill incorrect session variables.	}	$db_pass = $pass->fetchRow();	// now we have encrypted pass from DB in	//$db_pass['password'], stripslashes() just incase:	$db_pass['password'] = stripslashes($db_pass['password']);	$_SESSION['password'] = stripslashes($_SESSION['password']);	//compare:	if($_SESSION['password'] == $db_pass['password']) { 		// valid password for username		$logged_in = 1; // they have correct info					// in session variables.	} else {		$logged_in = 0;		unset($_SESSION['username']);		unset($_SESSION['password']);		// kill incorrect session variables.	}}// clean upunset($db_pass['password']);$_SESSION['username'] = stripslashes($_SESSION['username']);$time = time();?>

  11. I want to resize a textarea and my idea was to do it like this but it dosen't work...

    <script language="javascript">var rows = 10</script><span onClick="rows = rows--">smaller</span><span onClick="rows = rows++">bigger</span><script language="javascript">var txt = "<textarea cols=\'90\' rows=\'" + rows + "\' id=\'txt\' name=\'txt\'></textarea>"document.write(txt) </script>

    My idea might be false but give me a hint, I am stuck on this problem.

  12. the usual connection for local database is:

    mysql_connect("localhost", "root"); // password is not needed for local connection (in general)

    than you need to select your database:

    mysql_select_db users or die( "Unable to select database"); //quotations arent needed for the name of the database selected.

  13. to be clear, if you have a variable:$variable = "content";to send the content, you can add it to your link:<a href="yourpage.php?variable=<? echo $variable ?>">link</a>and on yourpage.php, you need to use the get or request method to get the variable back<?$_GET['variable'] = $variable;?>this way you get the information back to the name '$variable'This one technique but there are also other techniques withs forms and sessions, as jesh said.

  14. I can't see where the problem comes from...is your index 'index.htm' or 'index.php'?If it is in HTML It will not understand the php code and ignore it.otherwise,Did you try to open 'contents.php' directly?If nothing appears, than php might not be installed on your host.

  15. otherwise I have a problem...I have Two functions:

    //Function to fix php errors.function fix($tekst) {$tekst = str_replace("<","<",$tekst);$tekst = str_replace(">",">",$tekst);$tekst = str_replace('"','\"',$tekst);$tekst = str_replace("\'", "'",$tekst);$tekst = str_replace("\\", "\\",$tekst); // I know that one is useless but it sorts aout fine like this.$tekst = str_replace("amp;","&",$tekst);return $tekst;}

    and

    //BBcode function.function bbcode($tekst){// Alignment of a text:$tekst = str_replace("[center]", "<div align='center'>", $tekst);$tekst = str_replace("[/center]", "</div>", $tekst);$tekst = str_replace("[left]", "<div align='left'>", $tekst);$tekst = str_replace("[/left]", "</div>", $tekst);$tekst = str_replace("[right]", "<div align='right'>", $tekst);$tekst = str_replace("[/right]", "</div>", $tekst);//So for spaceing you will need something like this :$tekst = str_replace(array("\r\n", "\n", "\r"), '<br>', $tekst); //To create a link of the type [url=http://www.w3schools.com/]W3schools[/url]$tekst= str_replace("[url=","<a  location='blank' href='",$tekst);$tekst= str_replace("]","' >",$tekst);$tekst= str_replace("[/url]","</a>",$tekst);// If You Want to add an image too:$tekst= str_replace("[img=","<img src='",$tekst);$tekst= str_replace("]","' />",$tekst);// Underline, bold and Italic text:$tekst= str_replace("[b]","<strong>",$tekst);$tekst= str_replace("[/b]","</strong>",$tekst);$tekst= str_replace("[i]","<i>",$tekst);$tekst= str_replace("[/i]","</i>",$tekst);$tekst= str_replace("[u]","<u>",$tekst);$tekst= str_replace("[/u]","</u>",$tekst);// Set the color of a text:$tekst= str_replace("[color=","<font color='",$tekst); //closing this tag is set for [url]$tekst= str_replace("[/color]","</a>",$tekst);return $tekst;}

    And I send a text from a form to a file.how should I do it?

    fwrite($fh, bbcode(fix($tekst)));

    or

    fwrite($fh, fix(bbcode($tekst)));

×
×
  • Create New...