phorce 131 Posting Whiz in Training Featured Poster

Do you mean reorganise the letter array into the most frequent? I've re done it to that now of:

char[] aLetter ={ 'e', 't', 'a', 'i', 'o', 'n', 's', 'r', 'h', 'u', 'l', 'c',
  'd', 'f', 'm', 'y', 'g', 'p', 'w', 'b', 'v', 'x', 'q', 'k', 'j', 'z' };

In essence, the way you've done it is "Hardcoded" and they should be sorted by means of like LINQ and not just a pre-defined array (This will make you pass your assignment, however, is not really a good way to program)

Your array should contain something like:

A = 8.2, B = 2.3 etc.. And then sorted that way.

Doing the method you've done, have you tried to match the the two values together? For example:

Alphabet: E T A I O N S R H U I C D F M Y G P W B V X Q K J Z
Ciphertext: C Y X S M P E T U V Q L I H K W J A D O R Z B G N

?

phorce 131 Posting Whiz in Training Featured Poster

Hey,

You have not included the frequency analysis itself - Just the alphabet array.

For example:

char[] aLetter = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 
                                 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };

Needs to have the frequencies (1.4, 3.2, 2.2) etc and then ordered by the most frequent.

Hope this helps

phorce 131 Posting Whiz in Training Featured Poster

Firstly because you are using a form.. Make sure you declare your using one:

<p>Please select the product you want to add 
<form method="post" action="test.php">
              <label>
              <select name="menu1" onchange="MM_jumpMenu('parent',this,0)">
                <option>Nylon Blisters</option>
                <option>PP plastic</option>
                            </select>
              </label>
              <input type="submit" name="submit" value="Update">
</p>

This code will just display the results of the form input.. But you can use '$name' to update your database:

<?php
	
	$name = $_POST['menu1'];
	
	echo $name;

?>
phorce 131 Posting Whiz in Training Featured Poster

Click on the 'Mark this thread as solved' Should be near the 'Quick reply box' =)

phorce 131 Posting Whiz in Training Featured Poster

This compiles for me:

I left the class functions (.cpp) file alone and the main but changed the class to:

#ifndef CHARACTER_H
#define CHARACTER_H

#include <iostream>
#include <string>
#include <vector>
class Character
{
       public:
        Character();
    
   private:
    
    int health;
    int magic;
    int level;
    int eyeColor;
    std::vector<std::string> inventory;
    std::vector<std::string> abilities;
    
};

#endif

Hope this helps :)

phorce 131 Posting Whiz in Training Featured Poster
<?php
	$id = (int) 1;
	
	$db=mysql_connect('localhost','root','') or die ('Cannot connect to MYSQL!');
	@mysql_select_db('dbriomra') or die('Cannot connect to database');
		
	$query="SELECT * FROM `profiles` WHERE txtempno='$id'";
	$result = mysql_query($query);
	
	if(mysql_affected_rows() >= 1)
	{
		echo '<form method="post" action="">';
		while($row = mysql_fetch_array($result))
		{
			echo '<input type="text" name="field" value="' .$row['txtename']. '">';
		}
		echo '</form>';
	}else{
		
	  echo 'There are no records to fetch';
	}
?>

Should return a value =) I don't know why you're posting stuff if you want to display something in a text box.. e.g:

<?php

$empno = $_POST['txtempno']; 
$empname = $_POST['txtename'];
$position = $_POST['txtpos']; 
$salary = $_POST['txtsal']; 
$aname=$_POST['txtaname'];
$address=$_POST['txtadd'];
$relation=$_POST['txtremp'];
$age=$_POST['txtage'];
$sss=$_POST['txtsss'];
$ph=$_POST['txtph'];
$pagibig=$_POST['txtpagibig'];
$tax=$_POST['txttax'];
$total=$_POST['txttotal'];
$sss2=$_POST['txtsss2'];
$ph2=$_POST['txtph2'];
$pagibig2=$_POST['txtpagibig2'];
$tax2=$_POST['txttax2'];
$total2=$_POST['txttotal2'];
$tded=$_POST['txttded'];
$tsal=$_POST['txttsal'];
$allotment=$_POST['txtallotment'];
phorce 131 Posting Whiz in Training Featured Poster

-stares blankly- :P

Ok, ok

I'm guessing this is one of your field names "empno"?

So you could correct the code like this:

<?php
	$id = (int) 1;
	
	$db=mysql_connect('localhost','root','') or die ('Cannot connect to MYSQL!');
	@mysql_select_db('dbriomra') or die('Cannot connect to database');
		
	$query="SELECT * FROM `profiles` WHERE empno='$id'";
	$result = mysql_query($query);
	
	if(mysql_affected_rows() >= 1)
	{
		echo '<form method="post" action="">';
		while($row = mysql_fetch_array($result))
		{
			echo '<input type="text" name="field" value="' .$row['empname']. '">';
		}
		echo '</form>';
	}else{
		
	  echo 'There are no records to fetch';
	}
?>

I asked for your field names, not your code.. You need to be more descriptive with your problem, otherwise it's hard to help you.

phorce 131 Posting Whiz in Training Featured Poster

What error does it give?

It was just an example since I don't have access to your database, I cannot tell what fields you have.. =) Maybe provide some extra details?

phorce 131 Posting Whiz in Training Featured Poster

Right, well, you can't SELECT everything and expect EVERYTHING to display in a text box (Well, you can, but it's not practical lol):

<?php
	$id = (int) 1;
	
	$db=mysql_connect('localhost','root','') or die ('Cannot connect to MYSQL!');
	@mysql_select_db('dbriomra') or die('Cannot connect to database');
		
	$query="SELECT * FROM `profiles` WHERE profile_id='$id'";
	$result = mysql_query($query);
	
	if(mysql_affected_rows() >= 1)
	{
		echo '<form method="post" action="">';
		while($row = mysql_fetch_array($result))
		{
			echo '<input type="text" name="field" value="' .$row['name']. '">';
		}
		echo '</form>';
	}else{
		
	  echo 'There are no records to fetch';
	}
?>

This example selects everything from the table profile, where the profile_id is 1 and if there is a record, displays a text box that has the value of the name.. For example "Phillip"

Hope this helps :)

phorce 131 Posting Whiz in Training Featured Poster

I'm confused to what you actually want to do here..

Do you want to display a record inside a text box, so like have an input box and its value is from the table?

OR display a record from the table onto a page?

To me, your code suggests that you're passing data from a form, selecting every record from the table, checking to see if the query executes..

phorce 131 Posting Whiz in Training Featured Poster

Could you please give us the code so we can try and resolve your issue :)

phorce 131 Posting Whiz in Training Featured Poster

Just a suggestion but because you're using a menue, why not use a switch statement instead?

For example:

#include <iostream>
int x;
int y;
int z;
void addFunc();
void subFunc();
void divFunc();
void multFunc();
using namespace std;

int main()
{
    int select;
    cout << "Welcome to calculator!" << endl << "You have four options" << endl << "Type 1 for add." << endl << "Type 2 			  for subtract." << endl << "Type 3 for divide." << endl << "Type 4 for multiply." << endl;
    cin >> select;
    
	switch (select)
	{
		case 1:
			addFunc();
		break;
		
		case 2:
			subFunc();
		break;
		
		case 3:
			divFunc();
		break;
		
		case 4:
			multFunc();
		break;
		
		default:
			cout << "Your number was not between 1-4";
		break;
		
	}
    return 0;
}

void addFunc()
{
    cout << "Choose a number to add." << endl;
    cin >> x;
    cout << "Choose another number to add" << endl;
    cin >> y;
    z = x + y;
    cout << "Your answer is " << z << endl;
}

void divFunc()
{
    cout << "Choose a number to divide." << endl;
    cin >> x;
    cout << "Choose another number to divide" << endl;
    cin >> y;
    z = x / y;
    cout << "Your answer is " << z << endl;
}

void subFunc()
{
    cout << "Choose a number to subtract." << endl;
    cin >> x;
    cout << "Choose another number to subtract." << endl;
    cin >> y;
    z = x - y;
    cout << "Your answer is " << z << endl; …
PrimePackster commented: Nice one.... +0
phorce 131 Posting Whiz in Training Featured Poster

If this has now been solved, please mark it as solved and give rep points (use the arrows next to someones name)

Thanks and good luck :)

phorce 131 Posting Whiz in Training Featured Poster

I don't get what you mean by "put it into a function", but I'll have a go :)

<?php

   function returnText($theText)
   {
   		return $theText;
   }
   
   if(!isset($_POST['submitted'])) { // check that form hasn't been submitted 
      echo '<form method="post" action="">';
      echo 'Enter something: <input type="text" name="theInput" value="" />';
      echo '<input type="submit" name="submit" value="Go!">';
      echo '<input type="hidden" name="submitted" value="TRUE" />';
      echo '</form>';
   }else{
   
   	  $text = $_POST['theInput'];
   
   	  echo $text; // this will display the text.
   	  
   	  echo returnText($text);
   }
   
 ?>
phorce 131 Posting Whiz in Training Featured Poster

Is this solved now? If so, mark thread as solved :)

phorce 131 Posting Whiz in Training Featured Poster

What is the problem with using sessions?

But to answer your question, I shouldn't think so if they cannot add items to the card (because, these will be stored within the session) so aslong as the visitor to your site can only browse and doesn't have to do anything "usery" then sessions can be kept clear, for now.

You'll obviously need to use them when the user signs in and stuff :)

phorce 131 Posting Whiz in Training Featured Poster

Hey there (Think this is what you're looking for):

First off your class:

class Sally
{
    public:
        Sally(); 

    private:
     
};

Only have public and private/protected etc.. Not twice =)

And the cpp file:

#include<iostream>
#include<string>
#include "Sally.h";

Sally::Sally(){};

Main:

#include <iostream>
#include "Sally.h"
using namespace std;

int main(){
    
    Sally so;
    
    return 0;
}

Should compile now =)

phorce 131 Posting Whiz in Training Featured Poster

Have you tried...

<?php 
include "db.php";
 
//Rows
$qtyRow = '<tr>';
$priceRow = '<tr>';
 
$nn=12; //Number of items, we split this later
 
$s=mysql_query("SELECT * FROM `test1`");
 
$c=mysql_num_rows($s);
 
if($c%$nn==0){
	$cc=$c/$nn;	
}else{
	$cc=$c/$nn+1;	
}
 
//$cc : Number of pages
 
$ss=@$_REQUEST['ss']; //Start position (eg: 6)
$other_tables = "";
 
if($ss=="" || $ss==null){
	$ss = 0; //Set to zero because it is incremented later
}
 
//Pages
echo "<table border=\"1\" align=\"center\">";
$sql=mysql_query("SELECT * FROM `test1` ORDER BY `id` DESC LIMIT $ss,$nn");
$inc = 0;
while($r=mysql_fetch_array($sql)){
	$id=$r['id'];  
	$name=$r['name'];
	if($inc == 0){
		$qtyRow .= "<tr>";
		$priceRow .= "<tr>";
	}
	$qtyRow .= "<td>$id</td>";
	$priceRow .= "<td>$name</td>";
	++$inc;
	if($inc == 3 || $inc == 6 || $inc == mysql_num_rows($sql)){
		//Display Table
		echo $qtyRow."</tr>";
		echo $priceRow."</tr>";
		echo "</table>";
 
		//To remove extra table
		if(mysql_num_rows($sql) <= 3){
			$inc = 7;
		}
 
		//Reset
		if($inc == 3){
			echo "<br><table border='1' align='center'>";
			$qtyRow = "<tr>";
			$priceRow = "<tr>";
		}
	}
}
echo "</table>";
$j=0;
echo"page : ";
for($i=1;$i<=$cc;$i++){
	echo"<a href=\"select.php?ss=$j\">$i</a>";
	echo"|";
	$j=$j+$nn; 
}
?>
phorce 131 Posting Whiz in Training Featured Poster

What I can see is that the variable "link" contains both the href and the image itself.

<?php
	ob_start();
    session_start();
    if(!isset($_SESSION['Username']))
    {
        $alt = 'Please Register';
	$link = ( '<a href="http://www.test.com/signup.php"><img src=/images/register.png" alt="' .$alt. '" /></a>' );
        echo $link;
    }else{
        $alt = 'Vote';
	$link = ( '<a href="http://www.test.com/thanks.php"><img src=/images/vote.png" alt="' .$alt. '" /></a>' );
        echo $link;
	
  }
?>

Is that what you mean?

phorce 131 Posting Whiz in Training Featured Poster

Look up 'Database Normalisation'

From what I can see, your table is not even in first normal form.. Which is why you're having this problem :)

phorce 131 Posting Whiz in Training Featured Poster

Hey Lee,

You're designing and structuring your database wrong, which, is why you're having this problem:

Items "qty1" and "qty2" are displayed. However since qty3 is NULL (nothing) it is not displayed. I have done this by:

qty2 SHOULD contain something.. Because let's say if I came along and ordered a book:

username='Phorce', book='PHP OOP', qty='1' -> I've ordered 1 book.. No redundant data.

Your way:

username='Phorce', book='PHP OOP', pizza='cheese' qty='1', qty='2', qty='3'

Everytime someone orders a product (whether it's a book, pizza, or even a monkey) it should have it's own row inside the table, and, therefore, can have it's own quantity..

I'm trying to put this across in a way you can understand :(!

phorce 131 Posting Whiz in Training Featured Poster

Right, what I'm guessing is your table looks like this:

order_number first_name, last_name, qty1 qty2 qty3
----------------------------------------------
1 Phorce In Time 1
2 James Henry 1
3 blah blah 2


You shouldn't really have null data in your table, it's bad practise..


order_number first_name, last_name, qty
------------------------------------
1 Phorce In Time 1
2 James Henry 1
3 blah blah 2

If that makes sense? Sorry if I'm completely missing the point here? ...

Each item ordered has a qty..

phorce 131 Posting Whiz in Training Featured Poster

Why do you have a table in your database with:

'qty1, qty2, qty3, qty4' etc? Just have 1 called 'qty' :S This way you wouldn't have to mess around with any of this!

phorce 131 Posting Whiz in Training Featured Poster

Can I just ask, do you want to display 20 records from the table? And each of these records have a field called 'qty' or something?

Also, I don't understand what you're doing with the last part.. Are you inserting something?

phorce 131 Posting Whiz in Training Featured Poster

Also, it's not really ideal to use shorthand php tags..

<?

?>

Use:

<?php

?>

Just minor :)

phorce 131 Posting Whiz in Training Featured Poster

No worries :) Could have been solved quicker my dear!

If your problem has been solved, please mark this thread as solved! And, give reputation if you think someone helped you!

Good luck :) !

phorce 131 Posting Whiz in Training Featured Poster
<?php
include 'connection.php'
?>

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Index</title>
</head>

<body>
<b>Update for:</b> <br  />
<?
$getdb = mysql_query("SELECT * FROM person WHERE firstName='$_POST[updateN]'");

while($getdata = mysql_fetch_array($getdb))
{
	echo "ID no. " . $getdata['personID'];
	echo "<br />";
	echo "Name: " . $getdata['firstName']	. " " . $getdata['lastName'];
	echo "<br />";
	echo "Age: " . $getdata['Age'];
}


mysql_close($connection);
?>

<hr  />

<p>
<form action="updateprocess.php" method="post">
	Please Enter your ID number stated above: <input type="text" name="pID"  /> <br  /><br  />
    
    
 	First Name: <input type="text" name="updateFN"  /> <br />
    
    Last Name:  <input type="text" name="updateLN"  /><br />
    
    Age: <input type="text" name="updateA"  /> <br /><br />
    
    <input type="submit" value="Update" />
</form>
</p>

</body>
</html>

The index of "pID" cannot be identified because it isn't be posted, because of this line:

Please Enter your ID number stated above: <input type="text" name"pID"  /> <br  /><br  />

You need to have an = between name="pId" I am pretty sure I resolved this in my last post?

It works fine on my server once the pID is being processed =)

PrettyBird commented: Very thorough and helpful +1
phorce 131 Posting Whiz in Training Featured Poster

Please, everytime you post code.. Can you put them in tags please? It just makes it easier to read things (and hopefully, sort your problem out in less time)

<form action="updatinginfo.php" method="post">
Please Enter your ID number stated above: <input type="text" name="pID" />


First Name: <input type="text" name="updateFN" />

Last Name: <input type="text" name="updateLN" />

Age: <input type="text" name="updateA" />


<input type="submit" value="Update" />
</form>

Hope this helps you :)

phorce 131 Posting Whiz in Training Featured Poster

You can't do it, you have 3 queries in 1 query?

$firstName = $_POST['updateFN'];
$lastName = $_POST['updateLN'];
$age = $_POST['updateA'];
$personID = $_POST['pID']; //line 7


$update= "UPDATE person SET firstName='$firstName', lastName='$lastName', Age='$age' WHERE personID='$personID'";
$result = mysql_query($update) or trigger_error('Cannot update user');

Try that :)

phorce 131 Posting Whiz in Training Featured Poster

Just a suggestion:

Put the data you're posting into variables:

$firstName = $_POST['updateFN'];
$id = $_POST['perID'];
phorce 131 Posting Whiz in Training Featured Poster

Also to add (Again, I believe)

If you use session, it's exactly what it is says.. SESSION (Meaning, they expire if like they close their browser etc) Whereas cookies can be set for sometime.

E.g. If I had a login form, and, an option was to set "Remember me" I wouldn't really store it in a session, I'd store it in a cookie (client-side)

Hope this helps =)

phorce 131 Posting Whiz in Training Featured Poster

hahaah.. yeah I just realised that I answered my last question in the previous post. Any security concerns about client or server side sessions?

Hey,

I BELIEVE that server side sessions are a lot more secure, rather than client side because they are on the persons machine. That's the way I view them, might be wrong :)

phorce 131 Posting Whiz in Training Featured Poster

haha woo :)! You're welcome, pleasure! If you ever need anything else, feel free to ask! I hope this project goes well for you. Take care =)

phorce 131 Posting Whiz in Training Featured Poster

41 replies later and ripping my hair out ;) woo!

Let me know how you get on!

phorce 131 Posting Whiz in Training Featured Poster
<?php
session_start();

include "db_connect.php";

$username = $_POST['username'];
$pass = $_POST['pass'];

mysql_select_db($dbname, $connect);
$sql="SELECT username, password FROM alunos WHERE username='". $username. "'";

$resultado = mysql_query($sql, $connect) or die(mysql_error());

$num = mysql_fetch_assoc($resultado);

if ($username == $num['username'] AND $pass == $num['password']) {
        $_SESSION['username'] = $username;
        header("Location: test.php"); // sorry xD
        } else {
        echo "Could not log in :(";
        }
mysql_close($con);
?>

Try that now =) I think there was a problem with the previous SQL statement!

phorce 131 Posting Whiz in Training Featured Poster
<?php
session_start();

include "db_connect.php";

$username = $_POST['username'];
$pass = $_POST['pass'];

mysql_select_db($dbname, $connect);
$sql="SELECT username, password FROM alunos WHERE username='". $username. "'";

$resultado = mysql_query($sql, $connect) or die(mysql_error());

$num = mysql_fetch_assoc($resultado);

if ($username == $num['username'] AND $pass == $num['password']) {
        echo "Yes logged in :)";
        } else {
        echo "Could not log in :(";
        }
mysql_close($con);
?>

Please can you run this code, login and tell me if it says:

Yes logged in :)
OR
Could not log in :(

phorce 131 Posting Whiz in Training Featured Poster

Change

$sql="SELECT username, password FROM alunos WHERE username='". $username. "' AND '". $pass ."'";

To:

$sql = "SELECT username, password FROM alunos WHERE username='$username' AND password='$pass'";

:)

phorce 131 Posting Whiz in Training Featured Poster

That sounds to me like it's not sessions, it's something to do with your database.. In "validpass.php" you check to see if the username/password is correct or not, if it's not correct then it will redirect you to the login form..

Are you sure your SQL query is right AND you're entering the correct details? :)

phorce 131 Posting Whiz in Training Featured Poster

Just to clarify, it works, then when you sign out.. It redirects you the page that says "Welcome, Guest!" and then when you try and sign back in, does it say "Welcome [blank]" or does it redirect you back to the login form?

This is really, really weird.. It's working perfectly fine on my system :(

phorce 131 Posting Whiz in Training Featured Poster

It's really weird haha! Can you please post what you are using for "logout"?

phorce 131 Posting Whiz in Training Featured Poster

Let's do a test =)

Create a new page (call it test.php) that has this code in it:

<?php
    session_start();

    function is_logged()
    {
        if(isset($_SESSION['loggedin']))
        {
            return true;
        }else{
           return false;
       }
   }

   if(is_logged())
   { 
        echo "Welcome, {$_SESSION['username']}";
   }else{
      echo "Welcome, Guest";
   }

And then change your "validpass.php" to this:

<?php
session_start();

include "db_connect.php";
mysql_select_db($dbname, $connect);
     
$username = $_POST['username'];
$pass = $_POST['pass'];
   
$sql="SELECT username, password FROM alunos WHERE username='". $username. "' AND '". $pass ."'";
$resultado = mysql_query($sql, $connect) or die(mysql_error());
if(mysql_affected_rows() == 1)
{
    $_SESSION['username'] = $username;
    $_SESSION['loggedin'] = 1;
    header("Location: test.php");
}else{
  header("Location: login_form.php");
}
mysql_close($con);

?>

If this doesn't work, can you please use this (in test.php):

var_dump ($_SESSION['username']);
var_dump ($_SESSION['loggedin']);

Hope this helps you =) It worked when I tried it on my server!

phorce 131 Posting Whiz in Training Featured Poster

Right, I'm really sorry about this.. >.< Let me write the script (again) and I'll see what the problem is.. :) Hopefully, this should finally work haha!

phorce 131 Posting Whiz in Training Featured Poster

That's weird haha

<?PHP
    session_start();

    include 'topo.php';
    //user 'logado' ou nao
    function is_logged()
    {
    if(isset($_SESSION['username'])) {
    return true;
    }else{
    return false;
    }
    }
    ?>
     
    <!--content-->
    <table width = 100%>
    <tr>
     
    <h2>Bem Vindo à Escola de Música de V.N.Gaia</h2>
     
    <tr>
    <font color = "green" size="3">
    Welcome,
	
	<?php
    if(is_logged())
    {
    echo $_SESSION['username'];
    }else{
    echo "Guest!";
    }
    ?>
    
	</font>
    </tr>

Removed the ob_start(); should work! That's the only thing I can think it might be.

phorce 131 Posting Whiz in Training Featured Poster

Does it work if you sign back in again? When you logout, it will unset the session and return back to "Welcome, guest"

phorce 131 Posting Whiz in Training Featured Poster
phorce 131 Posting Whiz in Training Featured Poster
<?PHP
    ob_start();
    session_start();

    include 'topo.php';
    //user 'logado' ou nao
    function is_logged()
    {
    if(isset($_SESSION['username'])) {
    return true;
    }else{
    return false;
    }
    }
    ?>
     
    <!--content-->
    <table width = 100%>
    <tr>
     
    <h2>Bem Vindo à Escola de Música de V.N.Gaia</h2>
     
    <tr>
    <font color = "green" size="3">
    Welcome,
	
	<?php
    if(is_logged())
    {
    echo $_SESSION['username'];
    }else{
    echo "Guest!";
    }
    ?>
    
	</font>
    </tr>

Try that. Just initialised the session_start();

phorce 131 Posting Whiz in Training Featured Poster

Try:

<?php
session_start();

include "db_connect.php";

$username = $_POST['username'];
$pass = $_POST['pass'];

mysql_select_db($dbname, $connect);
$sql="SELECT username, password FROM alunos WHERE username='". $username. "'";

$resultado = mysql_query($sql, $connect) or die(mysql_error());

$num = mysql_fetch_assoc($resultado);

if ($username == $num['username'] AND $pass == $num['password']) {
        $_SESSION['username'] = $username; // this will store the value of username in the session value.
	header("Location: index.php");
	} else {
	header("Location: login_form.php");
	}
mysql_close($con);
?>

You can also reduce the code by querying the username AND password together in one query.

phorce 131 Posting Whiz in Training Featured Poster

Did the session thing work?

And no problem, if you need anything else, feel free to ask =)

phorce 131 Posting Whiz in Training Featured Poster
<?PHP

include 'topo.php';

//user 'logado' ou nao
function is_logged()
{
   if(isset($_SESSION['username'])) { 
     return true;
 }else{
    return false;
 }
} 
?>

<!--content-->
<table width = 100%>
<tr>

<h2>Bem Vindo à Escola de Música de V.N.Gaia</h2>

<tr>
<font color = "green" size="3">
Welcome, 
<?php 
if(is_logged())
{
   echo $_SESSION['username']; 
}else{
  echo "Guest!";
}
?> 
</font>
</tr>

<td class = "table_title">
<h3> A Nossa Escola </h3>
<p align = "justify"> 
A Escola de Música de V.N.Gaia existe desde 1979. O nosso principal objectivo é incentivar o gosto musical de todas as pessoas seja qual for a idade.
<br/>
Os nossos Cursos estão divididos por graus (1º ao 5º) e no final de cada ano lectivo serão inseridas as notas dos alunos.
Essas notas resultam do trabalho, não só individual mas também a integração em grupo. 
</p>
</td>

<td width = 3%></td>

<td width = 20% class = "table_title"> 
<h3> Cursos </h3>
<table>
<tr>

<tr>
<td>Guitarra Elétrica</td>
</tr>

<tr>
<td> Piano</td>
</tr>

<tr>
<td> Violoncelo</td>
</tr>

<tr>
<td> Saxofone</td>
</tr>

<tr>
<td> <a href = "cursos.php"> <img src = "images/button.jpg"></img> </a> </td>
</tr>

</tr>
</table>
</td>


<td width = 3%></td>


<!----------JAVASCRIPT VALIDAR LOGIN---------------->
<script>
function validar() {
	if (document.getElementById("username").value.length==0) { 
		alert("Introduza o seu Login");
		document.getElementById("username").focus();
		return false;		
	}
	if (document.getElementById("pass").value.length==0) { 
		alert("Introduza a sua Password");
		document.getElementById("pass").focus();
		return false;		
	}
}
</script>

<?php
if(!is_logged())
{
?>
<!-------------------FORM LOGIN--------------------->
<td class = "table_title">
<h3> Log In </h3>
<form name="loginform" METHOD="POST" action="validapass.php" onsubmit="return validar()">
	<table class=textologin align="center" cellspacing="0" cellpadding="0" width="25%">
        <tr><td height="50"></td></tr>
			<tr>
               <td width="50">Username:&nbsp;</td>
               <td width="150" align="left"><input …
phorce 131 Posting Whiz in Training Featured Poster

By the looks of this script (I haven't ran it) but you're storing the users data in XML.. This isn't the safest route to go down..

I wouldn't go down the "Javascript" route either, do a simple check to see if the user is signed in or not.. You're already setting a session (username) if the user has successfully signed in.. Just do a check on it!