hielo 65 Veteran Poster

This is too long

In that case then instead of trying to support some SPECIFIC individual properties, then expect CSS rules. In other words instead of: [table:border=2] (which by the way, does not allow you to specify units such as percentages, em, etc.)

you would write: [table border:2px] For ANY other css rule: [table border:2px;background-color:yellow;color:red] then you would just need one regex:
to convert it to: <table style="border:2px;background-color:yellow;color:red"> which in my opinion offers more styling options to your table. The expression you would need is: str.replace(/\[table\s*(.*?)\]/ig,'<table style="$1">');

(PS. What is the name of t={}, what {} means?

that is shorthand for var t= new Object() . There I am just initializing a variable that holds different rules which I then try to match against your input string. So, if you want to support only specific properties, you will need that "long" approach. But if you want to support ANY css rule, the the expression I showed you above will suffice.

hielo 65 Veteran Poster

But what if the user write it with inversion?

You would need to write ANOTHER expression that would try to do a match based on the reverse order. Basically execute back-to-back replace() operations:

function tables(str){
	var t={};
	t["<table border='$2' width='$4'>"]=/\[table(:|\s+)border=(.+?)(\s+|;)width=(.+?)\]/ig;
	t["<table width='$2' border='$4'>"]=/\[table(:|\s+)width=(.+?)(\s+|;)border=(.+?)\]/ig;
	t["<table border='$2'>"]=/\[table(:|\s+)border=(.+?)\]/ig;
	t["<table width='$2'>"]=/\[table(:|\s+)width=(.+?)\]/ig;
	t["<table>"]=/\[table\]/ig;

	for( var k in t)
	{
		str=str.replace(t[k],k)
	}	
return str;
}

var str="";
str+="[table:border=10;width=300]\n"
str+="[table]\n"
str+="[table:width=500]\n"
str+="[table:border=30]\n"
str+="[table:width=300;border=20]\n"
alert( tables(str) )
hielo 65 Veteran Poster

Do NOT give an element a name and/or id that is the same as a javascript function. This would result in a name collision. Rename your function to Calculate (upper case "C") and update the onclick attribute on line 111.

Also, in checkplan() it looks like this: var but = document.getElementById('calculate'); should be: var calculate = document.getElementById('calculate'); AND you are also missing the following in that function: var yrs = document.getElementById('length');

hielo 65 Veteran Poster

I am a newbie here and just wanna say Hi to everyone. I am Crystal from Louisiana, US.

Hi Crystal from Louisiana - Welcome!

actually what I want is to generate excel file with this sql :
"SELECT * FROM student_registration where year = '$year' and trimester = '$trimester' ORDER BY stu_ID"
which year and trimester are get from user's input.

May u give me further explanation about this?

avocado_juice, what was not clear about my previous post? As stated earlier, your problem is that you are first sending HTML and THEN you are attempting to query the db to send the excel file. You need to reverse those steps. Essentially the BEGINNING of your file should be:

<?php
if (isset($_POST["btnsub"]) && ($_POST["btnsub"] == "Submit"))
{
  //here you query the db and send the excel data. You already have the
  //the code for this

  //NOTICE: It is very important that you add the following
  //at the end of this if clause
  exit();
}

//AFTER the if clause you then begin with your HTML
include 'admin_homepage.php';
?>

Thus on initial load, the if clause will evaluate to false and go straight to the include statement which is the start of your HTML document. Once you post, the if clause will be true and it will query the db and send the query output.

hielo 65 Veteran Poster

REMOVE those "invalid" definitions from your initial CSS file. Instead, add them dynamically through javascript (by importing a "supplemental.css" file - http://www.hunlock.com/blogs/Howto_Dynamically_Insert_Javascript_And_CSS). The validator will not execute javascript so it should validate only the "good" css.

hielo 65 Veteran Poster

In case it is not clear, on the function I posted earlier, you need to pass the text where you have the [link] tags to html <a> tags:

var text = document.getElementById('tekst').value;
var result = links(text);
alert(result)
hielo 65 Veteran Poster

Look for tutorials on Regular Expressions.

hielo 65 Veteran Poster

try:

function links(str){
return str.replace(/\[link\s*=\s*(['"])?(.*?)\1\s*\](.+?)\[\/link\]/ig,'<a href="$2">$3</a>').replace(/\[link\](.+?)\[\/link\]/ig,'<a href="$1">$1</a>');
}
hielo 65 Veteran Poster

Based on what you posted, it looks like what you are actually doing is:

a. send some HTML markup by including admin_homepage.php'(probably the <html><head>...</head><body>...)
b. query the db
c. download excel file

The problem is that if you are going to force a download, you cannot send any HTML markup (or any other content for that matter) to the browser before you send the contents of the file.

So what you need to do is:
a. Determine if something was posted
If YES =>query the db and force the file download ( send the header stuff before you even query the db) and call

exit()

as soon as you send the excel data.

If NO => THEN you include your template file and put whatever else needs to be displayed on the "initial" page (possibly download and/or search options).

hielo 65 Veteran Poster

Replace the previous hielo.php with the following:

<?php
// database connection stuff here

$searchType='AND';
$condition ='';
$condition .= (isset($_GET['year'])  && !empty($_GET['year'])  ? $searchType."  `year`='" . mysql_real_escape_string($_GET['year'])  . "' " : '');
$condition .= (isset($_GET['brand']) && !empty($_GET['brand']) ? $searchType." `brand`='" . mysql_real_escape_string($_GET['brand']) . "' " : '');
$condition .= (isset($_GET['type'])  && !empty($_GET['type'])  ? $searchType."  `type`='" . mysql_real_escape_string($_GET['type'])  . "' " : '');


if(trim($condition)=="")
{
	$query = "(SELECT * FROM `table1`) UNION (SELECT * FROM `table2`) ORDER BY `year` DESC ";
}
else
{ 
	$condition=substr($condition,strlen($searchType));
	$query = "(SELECT * FROM `table1` WHERE $condition) UNION (SELECT * FROM `table2` WHERE $condition) ORDER BY `year` DESC ";
}

$totalQuery="SELECT COUNT(*) as `total` FROM ($query) as t";
echo sprintf(PHP_EOL.'<!-- %s: %s -->',__LINE__,$totalQuery);
$result = mysql_query($totalQuery, $connection) or die("Could not execute query : $totalQuery ." . mysql_error());

$rows = mysql_fetch_assoc($result);

if ($rows['total']==0) { echo "Nothing found."; }

// Start paging variables
$screen = intval($_GET['screen']);
$PHP_SELF = $_SERVER['PHP_SELF'];
$rows_per_page=16; // number of records per page
$total_records=$rows['total'];
$pages = ceil($total_records / $rows_per_page); // calculate number of pages required

if ($screen < 0)
	$screen=0;
$start = $screen * $rows_per_page; // determine start record
$query .= " LIMIT $start, $rows_per_page";
echo sprintf(PHP_EOL.'<!-- %s: %s -->',__LINE__,$query);
$result= mysql_query($query) or die("Could not execute query : $query ." . mysql_error());

$i=1;
while ($row=mysql_fetch_assoc($result))
{

	$id=$row["id"];
	$name=$row["name"];
	$type=$row["type"];
	$year=$row["year"];

	include "(template.php)";

	if ($i==4)
	{
		echo '<div class="clear"></div>';
		$i=0;
	}
	$i++;
}

echo '<div class="clear"></div>
<div class="wardrobe-pagination">';

$year=rawurlencode($_GET['year']);
$brand=rawurlencode($_GET['brand']);
$type=rawurlencode($_GET['type']);

// create the links
//the only parameter that keeps changing in the links below is …
hielo 65 Veteran Poster

Try saving the following as hielo.php. Be sure to read comments in code. If problem persists, post a link to hielo.php:

<?php
// database connection stuff here

$searchType='AND';
$condition='';
$condition .= (isset($_GET['year']) && !empty($_GET['year']) ? $searchType.' `year`='.mysql_real_escape_string($_GET['year']): '');
$condition .= (isset($_GET['brand']) && !empty($_GET['brand']) ? $searchType.' `brand`='.mysql_real_escape_string($_GET['brand']): '');
$condition .= (isset($_GET['type']) && !empty($_GET['type']) ? $searchType.' `type`='.mysql_real_escape_string($_GET['type']): '');


if ($condition=="")
{
	$query = "(SELECT * FROM `table1`) UNION (SELECT * FROM `table2`) ORDER BY `year` DESC ";
}
else
{ 
	$condition=substr($condition,strlen($searchType));
	$query = "(SELECT * FROM `table1` WHERE $condition) UNION (SELECT * FROM `table2` WHERE $condition) ORDER BY `year` DESC ";
}

$totalQuery="SELECT COUNT(*) as `total` FROM ($query) as t";
$result = mysql_query($totalQuery, $connection) or die("Could not execute query : $totalQuery ." . mysql_error());

$rows = mysql_fetch_assoc($result);

if ($rows['total']==0) { echo "Nothing found."; }

// Start paging variables
$screen = intval($_GET['screen']);
$PHP_SELF = $_SERVER['PHP_SELF'];
$rows_per_page=16; // number of records per page
$total_records=$rows['total'];
$pages = ceil($total_records / $rows_per_page); // calculate number of pages required

if ($screen < 0)
	$screen=0;
$start = $screen * $rows_per_page; // determine start record
$query .= " LIMIT $start, $rows_per_page";

$result= mysql_query($query) or die("Could not execute query : $query ." . mysql_error());

$i=1;
while ($row=mysql_fetch_assoc($result))
{

	$id=$row["id"];
	$name=$row["name"];
	$type=$row["type"];
	$year=$row["year"];

	include "(template.php)";

	if ($i==4)
	{
		echo "<div class=\"clear\"></div>";
		$i=0;
	}
	$i++;
}

echo "<div class=\"clear\"></div>
<div class=\"wardrobe-pagination\">";

$year=rawurlencode($_GET['year']);
$brand=rawurlencode($_GET['brand']);
$type=rawurlencode($_GET['type']);

// create the links
//the only parameter that keeps changing in the links below is 'screen', so initialized $url
//outside any of your constructs, then within you just need …
hielo 65 Veteran Poster

in that case you need to dynamically insert the script tag:

<html>
<head>
<script>
var X='hello';

function importScript(url){
 var headID = document.getElementsByTagName("head")[0];         
 var newScript = document.createElement('script');
 newScript.type = 'text/javascript';
 newScript.src = url;
 headID.appendChild(newScript);
}

window.onload=function(){
  importScript('url.com?lang=en&X='+X+'&');
};
</script>
</head>
<body>
</body>
</html>
hielo 65 Veteran Poster

are you saying that you want to "read" the "X" from the url and make it into a JS variable?

hielo 65 Veteran Poster

I'm assuming that somewhere you have an initial page where the person is specifying the year. Assuming you have:

<input type='text' name='year' value=''/>

similarly, you can provide the other search criteria:

<input type='text' name='year' value=''/>
<input type='text' name='brand' value=''/>
<input type='text' name='type' value=''/>

Now, if you want the results to meet ALL the search criteria, your selects will now need to be ANDed:

(select * from `table1` WHERE `year`='$cat' AND `type`='$type' AND `brand`='$brand')

as for your links, if you are able to generate: ".php?year=(year)" then generating .php?brand(brand)=&type(type)=&year=(year) should be trivial as long as you provide the initial search parameters on the INITIAL page, just like you have been doing with year.

hielo 65 Veteran Poster

assuming [0-9a-zA-Z_-] represents the set of allowed characters, and that $url contains the hyperlink you want to "clean", then try:

$url = preg_replace('#[^0-9a-zA-Z_-]#','',$url);
hielo 65 Veteran Poster

try parenthesizing your selects:

...
else
{ $query .= "(select * from `table1` WHERE `year`='$cat') union (select * from `table2` where `year`='$cat') order by `year` desc "; }
...

As for the second part of your question, you could put a dropdown with the list of available categories to sort by. Whenever the user makes a selection it would submit a request to the server with that category.

hielo 65 Veteran Poster

What you have now is fine. Also, regarding:

Humm ... well, i made the changes and amount does get updated but only to the last value available in the select list. So, for example:

$(document).ready(function () {
$('#item_name').change(function () {
	var value = $('#item_name').val();
	if(value == "institutional memberhip"){
		$("#amount").val("349.00");
	} else if(value == "associate memberhip"){
		$("#amount").val("99.00");
	} else {
		$("#amount").val("37.45");
	}
  });
});

The problem with that code is that you misspelled membership in you if clauses. Otherwise it would also work.

hielo 65 Veteran Poster

try changing: var value = $('#item_name').val(); to: var value = $('option:selected',this).attr('value');

hielo 65 Veteran Poster

elseif should be

else if

(you need a space in between).

Also, in your HTML, your <OPTION> tags need to have those values as well and don't forget that js is case sensitive:

<option value="institutional memberhip">Institutional Memberhip</option>
<option value="individual membership">Individual Membership</option>
hielo 65 Veteran Poster

I think I understand what you are asking now. Within your if clause you need to determine the current m/d/y and use that to reset the values of your drop downs:

<script>
//these will be updated upon load with the initially selected options
var initialDate={'date':-1,'month':-1,'year':-1};
window.onload=function(){
	initialDate.date=document.getElementById('daysOfMonth').selectedIndex;
	initialDate.month=document.getElementById('monthOfYear').selectedIndex;
	initialDate.year=document.getElementById('year').selectedIndex;
}


function isValidDate()
{
	var now = new Date();
	
	//advance one day
	now.setDate( now.getDate() - 1 );

	var Day=document.getElementById('daysOfMonth').value;
	var Month=document.getElementById('monthOfYear').value;
	var Year=document.getElementById('year').value;
	
	var str = Month + " " + Day + " " + Year;
	
	var selectedDate= new Date(str);
		
	if(selectedDate < now)
	{
		alert("You may not select dates in the past . . . only future days!!!");
		//now here you reset the selects to the initial values
		document.getElementById('daysOfMonth').selectedIndex=initialDate.date;
		document.getElementById('monthOfYear').selectedIndex=initialDate.month;
		document.getElementById('year').selectedIndex=initialDate.year;
	}	
}
</script>
hielo 65 Veteran Poster

Do you at least now how to insert the data into the DB? If not, then I suggest you first read an online tutorial on PHP:
http://www.w3schools.com/php/default.asp

If you are already familiar with the syntax of php, then try skipping to the "forms" section of the tutorial. Be sure the read the MySQL portion.

hielo 65 Veteran Poster

try:

...
          <div align="right">
<?php
if( isset($_POST['daysOfMonth']) &&!empty($_POST['daysOfMonth']) )
{
	$day = $_POST['daysOfMonth']; 
	$month = $_POST['monthOfYear']; 
	$year = $_POST['year'];
}
else
{
	$date = time();

	$day = date('d', $date); 
	$month = date('m', $date); 
	$year = date('Y', $date);
}
//We then determine how many days are in the current month
$days_in_month = cal_days_in_month(0, $month, $year);

$current_month = date('F');
?>		
            <select name="daysOfMonth" id="daysOfMonth" onchange="isValidDate()">
              <option>....</option>
		    <?php 
		    		echo sprintf('<option selected="selected" value="%s">%s</option>',$day,$day); 
				for($i = 1; $i <= $days_in_month; $i++)
				{
					echo "<option value=".$i.">".$i."</option>";
				}
			?>
            </select>
...
hielo 65 Veteran Poster
<script type="text/javascript">
function setValue(field)
{
	if(''!=field.defaultValue)
	{
		if(field.value==field.defaultValue)
		{
			field.value='';
		}
		else if(''==field.value)
		{
			field.value=field.defaultValue;
		}
	}
}
</script>
<input type="text" value="Enter Title" onfocus="setValue(this)" onblur="setValue(this)"/>
hielo 65 Veteran Poster

which part are you having trouble with? I suggest you post what you have thus far and provide more details regarding your problem.

hielo 65 Veteran Poster

<option><?php if($day == 32){$day = 1; echo $day;}else{ echo $day;} ?></option> <!--problem-->

Where did you initialize $day ? BEFORE the if clause you should have:

$day = isset($_POST['daysOfMonth']) && !empty($_POST['daysOfMonth']) ? $_POST['daysOfMonth'] : 1;
hielo 65 Veteran Poster

...but it gets one of them three times

Well, you originally were (incorrectly) nesting a while() within a for() so you would clearly end up with "duplicate" records. Based on your last feedback, then perhaps you shouldn't even be using the for construct at all:

$note = array();
$i=-1;
			while($n = $db->fetchArray($query)){
					++$i;
					echo "~" . $i . "~";
					$note[$i]['noteID'] = $n['noteID'];
					$note[$i]["title"] = $n['title'];
					$name = $db->getUserName($n['author']);
					$note[$i]["author"] = $name['first'] . " " . $name['last'];
					$note[$i]["date"] = $n['added'];
					$note[$i]["text"] = $n['text'];

			}
			echo "<pre style='text-align:left;'>";print_r($note);echo "</pre>";
			return $note;
hielo 65 Veteran Poster

The trouble I am having is that the variable $i in the for loop is only recognized as 0 inside of the while, but it shows as the number it is supposed to outside the while.

On the first iteration (when $i equals zero) BEFORE the while() you have NOT yet fetched any db records. As soon as the while() FINISHES executing the first time (again, when $i equals zero), then $query (assuming that it is a resource that "points" to the the result set of a previously executed sql command - a SELECT to be specific) is NO longer pointing to a valid result set. So on the next iteration of your for construct (when $i equals 1), then $db->fetchArray($query) NO longer returns an array.

So, instead of:

for(...){
 while(...){
 ...
 }
}

do:

while(...){
 for(...){
 }
}
hielo 65 Veteran Poster

at the end of your first regex you have: ...(\#[-a-z!//\d_]*)?$/i Try escaping those slashes: ...(\#[-a-z!\/\/\d_]*)?$/i ALSO, instead of:
$valid_url="...";

try using apostrophes:
$valid_url='...';

hielo 65 Veteran Poster

should be created < DATE_SUB(NOW(), INTERVAL 30 DAY) ( no '<=', simply use'<' )

as for the deletion, the function is named unlink()
http://us3.php.net/manual/en/function.unlink.php

hielo 65 Veteran Poster

It's because your SELECT query failed. Instead of: $sql_query = mysql_query("SELECT * FROM blog WHERE MATCH(title,post) AGAINST('$search_term')"); try using the following you you can find out WHY the error ocurred: $sql_query = mysql_query("SELECT * FROM blog WHERE MATCH(title,post) AGAINST('$search_term')")[B] or die(mysql_error())[/B] ;

hielo 65 Veteran Poster

there is no such thing as:
else OPEN_PARENTHESIS condition CLOSE_PARENTHESIS { ... }

the proper syntax for an else is a "braced block" with NO condition:
else{
...
}

there is:
if OPEN_PARENTHESIS condition CLOSE_PARENTHESIS { ... }

and also
elseif OPEN_PARENTHESIS condition CLOSE_PARENTHESIS { ... }

so if you really want to include that condition, you should use and elseif

hielo 65 Veteran Poster

You need to put quote around strings - words that are NOT PHP keywords - ex: $remark="Excellent"; because Excellent is NOT a php keyword. The same goes for the other remarks.

also, totalg IS a variable, so you MUST prefix it with a dollar sign in every instance of totalg.
WRONG: if(totalg <= 5.00 && totalg >= 4.51){ CORRECT: if($totalg <= 5.00 && $totalg >= 4.51){

hielo 65 Veteran Poster

try:

<?php
if ( isset($_POST['seo']) && $_POST['seo'] == 'Save' )
{
	foreach($_POST['title'] as $index=>$value)
	{
		$title = mysql_real_escape_string(trim($_POST['title'][$index])); 
		$description = mysql_real_escape_string(trim($_POST['description'][$index])); 
		$keywords = mysql_real_escape_string(trim($_POST['keywords'][$index])); 
		$res = mysql_query("UPDATE `content_en` SET `title`='$title',`description`='$description',`keywords`='$keywords' WHERE `id`=1");
		if (!$res) 
			die("Error saving the record!  Mysql said: ".mysql_error()); 
		header("Location: home.php");
	exit;
	}
}
$query = mysql_query("SELECT `id`, `title`, `description`, `keywords` FROM `content_en` WHERE `id` = 1") or die( mysql_error() ); 
echo '<form name="seo" action="home.php" method="post">';
while( $data = mysql_fetch_assoc($query) )
{
?>

	<div>Title: <input size="66" type="text" name="title[<?php echo $data['id']; ?>]" id="title[<?php echo $data['id']; ?>]" value="<? echo htmlentities($data['title'],ENT_QUOTES); ?>"></div>
	<div>Description: <input size="100" type="text" name="description[<?php echo $data['id']; ?>]" id="description[<?php echo $data['id']; ?>]" value="<? echo htmlentities($data['description'],ENT_QUOTES); ?>"></div>
	<div>Keywords: <input size="100" type="text" name="keywords[<?php echo $data['id']; ?>]" id="keywords[<?php echo $data['id']; ?>]" value="<? echo htmlentities($data['keywords'],ENT_QUOTES); ?>"></div>
<?php
}
?>
	<div><input type="submit" name="seo" value="Save" /></div>
</form>
hielo 65 Veteran Poster

Read http://www.php.net/manual/en/info.configuration.php#ini.magic-quotes-gpc
if that directive is enabled on your server and you typed/submitted the following:
O'Brian/O'Malley

then the server will auto-convert it to:
O\'Brian\/O\'Malley

then if you call stripslashes() it will change it back to what you originally typed:
O'Brian/O'Malley

notice that it removes only BACK slashes, not forward slashes.

Also, htmlentities() will first change <span>...</span> to &lt;span&gt; , but strip_tags() does NOT "understand" &lt;span&gt; . It will remove the tags only if they are "unencoded". So swap lines 53 and 54.

hielo 65 Veteran Poster

My question is whether there is any possibility for an user to override my validation and get away with an invalid entry ?

No. The expression allows exactly 10 characters, of which the first MUST be a zero and the remaining nine may be any of 1...9.

hielo 65 Veteran Poster

...var req = new Request.JSON where did you define the Request object? It looks like you forgot to "include/import/ling to" a javascript file!

hielo 65 Veteran Poster

...SET Fname='$a' AND Lname='$b' you need to get rid of AND. To update multiple fields, you need to separate them with a comma, NOT with the keyword AND. Try the following:

<?php
if( isset($_POST) && !empty($_POST) )
{

	mysql_connect("localhost","*****","****") or die('Could not connect:<br />' . mysql_error());
	mysql_select_db("*****", $con) or die( 'Unable to select db:<br />' . mysql_error() );

	$a=mysql_real_escape_string($_POST['e']);
	$b=mysql_real_escape_string($_POST['f']);

	$sql="UPDATE `Sample` SET `Fname`='$a',`Lname`='$b'";

	mysql_query($sql) or die('Unable to execute query: <br />'.$sql.'<br />'.mysql_error()) ;

	echo "Successful";

	mysql_close($con);
}
else
{
	echo "No data was posted!";
}
?>
hielo 65 Veteran Poster

perhaps the parent element of the table has the relevant setting - ex:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<style type="text/css">
<!--
#envelope{border-bottom:1px dotted black;}
-->
</style>

</head>
<body>
	<div id="envelope">
	<table summary="">
		<tr>
		<td>x</td>
		</tr>
	</table>
	</div>
</body>
</html>
hielo 65 Veteran Poster

only to find the CSS "hover" is NOT available in IE8. I've found the hover to be very useful in calling attention to links by changing their color.

Are you sure about that? The code below works fine for me. If anything, the lack of support would be in elements that are NOT links. For example, div:hover is not supported(AFAIK), but links have always been supported (at least since IE6).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<style type="text/css">
<!--
a:hover{background-color:yellow;color:red;}
-->
</style>

</head>
<body>
<a href="#">Hello</a>
</body>
</html>

As for javascript you can use the onmouseover and onmouseout attributes:

<div onmouseover="highlight(this)" onmouseout="highlight(this)">world</div>
<script language="JavaScript" type="text/javascript">
<!--
function highlight(e)
{
  if( e.style.backgroundColor=='yellow')
  {
  	e.style.backgroundColor='white';
	e.style.color='black';
  }
  else
  {
  	e.style.backgroundColor='yellow';
	e.style.color='red';
  }
}
//-->
</script>
hielo 65 Veteran Poster

it's called autocomplete: <input type="text" autocomplete="off" .../> http://www.htmlcodetutorial.com/forms/_INPUT_AUTOCOMPLETE.html

hielo 65 Veteran Poster

on your form, this:

<input type="submit" value="Calculate" />

needs a NAME attribute:

<input type="submit" name="Submit" value="Calculate" />

Notice the UPPER CASE "S" for Submit (lowercase "submit" is 'reserved' in javascript). So be sure to use "Submit" in your php code as well:

$calculate=$_POST['Submit'];
 if (isset($_POST['Submit']))
hielo 65 Veteran Poster

your submit button has name="submit", so you should be using that in $_POST, NOT 'Calculate'. You must use the NAME of the field:

WRONG:

$calculate=$_POST['Calculate'];
 if (isset($_POST['Calculate']))

CORRECT:

/* after this, $calculate should be set whatever the VALUE attribute is set to. In this case Calculate */
 $calculate=$_POST['submit'];
 if (isset($_POST['submit']))
hielo 65 Veteran Poster

put a % symbol BEFORE and AFTER the variable name:

"SELECT * FROM members WHERE name LIKE '%$searchKey%';"
hielo 65 Veteran Poster

assuming that allSelect is meant to be an array of references to all the SELECT elements, then you should be explicitly selecting/getting only the SELECT elements:

...
function init() {

  allSelect = document.getElementsByTagName("SELECT");
...
}

as for your loadLinks, try the following to see if you get the expected/selected value.

function loadLinks()
{
 if( this.selectedIndex > -1 )
  alert( this.options[this.selectedIndex].value )
 else
  alert('Nothing selected')
}

If you are still having problems, then post your updated code.

hielo 65 Veteran Poster

when you use var BEFORE your variable, it make that variable "private". In other words, it will NOT be visible outside your function. Thus, the variable allSelect in line 4 is NOT the same as the one in line 8. The allSelect variable declared in line 8 exists ONLY WITHIN that function. As soon as init() finishes executing, that variable is NOT accessible from outside. So, on line 8 you need to get rid of "var" so that your function populates the global variable (on line 4).

Also, line 16 is NOT correct. Why? Because init() will be called onload. In other words, WHILE the page is still loading, lines 7-14 will be ignored. The javascript interpreter will then try to execute line 16, but allSelect is still NOT an array. There isn't even a variable named i because:
a. i exists only within init() since it is declared with var b. even if you were to get rid of var , init() has NOT executed yet!

So you need to execute that line WITHIN the for loop in the init() function.

hielo 65 Veteran Poster

Glad to help!

Regards,
Hielo

PS: Don't forget to mark the thread as solved.

hielo 65 Veteran Poster
<HEAD>
   <script type="text/javascript">  
     
   function toggleElement(sel1, element1) {  
     
     element1 = document.frm1.elements[element1];  
     //alert(element1.value);  
     if (sel1.value == 'others') {  
     
       element1.style.display = 'inline';  
   
    }  
     else {  
     element1.value = ''; // input text will be empty  
       element1.style.display = 'none'; // hide text element  
     }  
     
     return;  
  }  
  
  window.onload=function(){
      toggleElement(document.getElementById('city'), 'txt1')
  }
 </script>  
</HEAD>


<BODY>
   <form name="frm1" >  
     
   <select name="city" id="city" onchange="toggleElement(this, 'txt1')">  
    <option value="patna">Choose Payment</option>  
    <option value="mumbai">Credit Card</option>  
    <option value="others" selected="selected">Others</option>  
   </select>  
   <input type="text" name="txt1" id="txt1" value="" /> any text  
      
   </form>  

</body>
FreddieBambino commented: Very helpful comment he made to me about Javascript +1
hielo 65 Veteran Poster
<?php 
if($logged_in) { 
  echo "Welcome back, $logged_row[username]&nbsp"; 
 ?>
<a href="<?= $_SERVER["REQUEST_URI"] . '&amp;action=logout' ?>"><?= $lang['ACC_LOGOUT'] ?></a>
<?php
} 
else {
 print('<a href="http://xxx/login.html">Login</a> / <a href="http://xxx.com/signup.html">Signup</a>');
} 
?>
hielo 65 Veteran Poster

I can go to your site now and attempt to request /Nathaniel10.php and you WILL find a reference to it in your log file. However, that does not mean that I "uploaded" said file to your server. It merely indicates that I "tried" to access a file named "Nathaniel10.php" (regardless of whether it exists or not).

You need to look at the status of the request. If the server returned 404, then it indicates that the server did not found that file and the requestor got a "404 - File not found" error message.

hielo 65 Veteran Poster

you cannot use myslq_real_escape_string() UNLESS you are connected to your DB first. Did you?

WRONG:

<?php
$username=mysql_real_escape_string($_POST['username']);
$password=mysql_real_escape_string($_POST['password']);

mysql_connect(...) or die( mysql_error() );
mysql_select_db(...) or die( mysql_error() );
mysql_query("SELECT * FROM Person WHERE username='$username' AND password='$password'" ) or die( mysql_error() );
?>

CORRECT:

<?php

mysql_connect(...) or die( mysql_error() );
mysql_select_db(...) or die( mysql_error() );

$username=mysql_real_escape_string($_POST['username']);
$password=mysql_real_escape_string($_POST['password']);

mysql_query("SELECT * FROM Person WHERE username='$username' AND password='$password'" ) or die( mysql_error() );
?>