ShawnCplus 456 Code Monkey Team Colleague
function myfunction()
{
a=document.form.objective.value;
b=parseInt(a);
c=document.form.topic.value;
d=parseInt(c);
e=document.form.coordination.value;
f=parseInt(e);
g=document.form.instructor.value;
t=parseInt(g);
h=document.form.audiovisual.value;
i=parseInt(h);
j=document.form.enjoy.value;
k=parseInt(j);
l=document.form.recommend.value;
m=parseInt(l);
n = (b+d+f+t+i+k+m);
document.form.total1.value =n;

a1=document.form.benefit.value;
b1=parseInt(a1);
c1=document.form.learnt.value;
d1=parseInt(c1);
e1=document.form.apply.value;
f1=parseInt(e1);
g1=document.form.aspires.value;
t1=parseInt(g1);
h1=document.form.share.value;
i1=parseInt(h1);
j1=document.form.motivate.value;
k1=parseInt(j1);
l1=document.form.asset.value;
m1=parseInt(l1);
n1 = (b1+d1+f1+t1+i1+k1+m1);
document.form.total2.value =n1;

a2=document.form.trainer2.value;
b2=parseInt(a2);
c2=document.form.trainer3.value;
d2=parseInt(c2);
e2=document.form.trainer4.value;
f2=parseInt(e2);
g2=document.form.trainer5.value;
t2=parseInt(g2);
h2=document.form.trainer6.value;
i2=parseInt(h2);
n2 = (b2+d2+f2+t2+i2);
document.form.total3.value =n2;

a3=document.form.trainer9.value;
b3=parseInt(a3);
c3=document.form.trainer10.value;
d3=parseInt(c3);
e3=document.form.trainer11.value;
f3=parseInt(e3);
g3=document.form.trainer12.value;
t3=parseInt(g3);
h3=document.form.trainer13.value;
i3=parseInt(h3);
n3 = (b3+d3+f3+t3+i3);
document.form.total4.value =n3;

a4=document.form.trainer15.value;
b4=parseInt(a4);
c4=document.form.trainer16.value;
d4=parseInt(c4);
e4=document.form.trainer17.value;
f4=parseInt(e4);
g4=document.form.trainer18.value;
t4=parseInt(g4);
h4=document.form.trainer19.value;
i4=parseInt(h4);
j4=document.form.trainer20.value;
k4=parseInt(j4);
n4= (b4+d4+f4+t4+i4+k4);
document.form.total5.value =n4;

HAHAHAHAHAHAHAHAHA

ShawnCplus 456 Code Monkey Team Colleague

A) USE CODE TAGS! This isn't your first post, that's not an excuse anymore.

B) Get firebug getfirebug.com and put console.log(Request.responseText); right before the if block

ShawnCplus 456 Code Monkey Team Colleague

Why?!

axeman // this
. // is
att // a legal
= 40; // text

May be I don't understand your statement?

A) It's annoying, B) It's bad form, C) could break some IDEs, D) Hard to debug (not necessarily in his case but definitely in yours) having a dot on a line by itself.

ShawnCplus 456 Code Monkey Team Colleague

being able to inherit from more than one classes does not seem to be useful, that might be why it is not possible in C# or JAVA

Heh, that's a whole 'nother thread to talk about the benefits, caveats and downfalls of multiple inheritance. Suffice it to say that it's definitely a bonus that C++ has it (sometimes)

ShawnCplus 456 Code Monkey Team Colleague

See, for example: http://en.wikipedia.org/wiki/Virtual_inheritance
So class className is a suitable player for "diamond" inheritance.

Yeah, that's a bit easier to follow than what I said but essentially the same :)

ShawnCplus 456 Code Monkey Team Colleague

It's to solve the diamond inheritance problem where you have a base class, then 2 child classes then a 4th class that inherits from both of the previous classes. If the base class declares a function then there is ambiguity of that function in the 4th class. Declaring the 2 child classes as inheriting virtually will allow the implementation of the base class's to fall through to the 4th class.

ShawnCplus 456 Code Monkey Team Colleague

hi,

I am a newbie php programmer i dont understand what you mean.

You could please describe in full detail for me please?

May i also ask can you see anything wrong with it looking at the form?

Thank you
genieuk

Frankly there's a lot wrong but let's solve one issue at a time. The steps I'm walking you through are to debug. If error_reporting didn't give you an error then make sure to check your scripts for a "die" or "exit" function.

ShawnCplus 456 Code Monkey Team Colleague

heh, E_ALL is a PHP constant that tells error_reporting to display all errors, it doesn't mean anything to you. If that doesn't work then if you have command line access type php -l filename obviously replacing filename with the file that's giving you trouble.

ShawnCplus 456 Code Monkey Team Colleague

When you get a white page it usually means there was a fatal error and you don't have error reporting turned on. At the top of your script put error_reporting(E_ALL); (Take this out once you put the site live, you don't want errors showing on your page when you're not developing.

ShawnCplus 456 Code Monkey Team Colleague

so function.h is actually show.h and main.cpp is actually test.cpp? Yeah, that's not confusing at all.

ShawnCplus 456 Code Monkey Team Colleague

where is currentSize coming from, it's not in that function.

ShawnCplus 456 Code Monkey Team Colleague

You shouldn't have spaces in between the . and the poperty for one thing. axeman.att , not axeman. att . As a complete side note it's spelled "rogue", "rouge" is makeup. Also, what is in show.h you haven't posted the code. Or test.cpp for that matter.

ShawnCplus 456 Code Monkey Team Colleague

I don't want to deceive them, this is only temporary. My knowledge of PHP is weak what do you mean by the header() function ? And will it work ? And how do you use it?

As I said, look at the php manual for the function. http://php.net/header. It baffles me how many people use PHP and don't ever visit its website.

ShawnCplus 456 Code Monkey Team Colleague

You might be able to achieve that with header() redirects (check the PHP manual for the header() function) But I wouldn't exactly recommend intentionally deceiving your users.

ShawnCplus 456 Code Monkey Team Colleague

Aside from your scope issue you have 6 identical structs. Inheritance exists for a reason.

ShawnCplus 456 Code Monkey Team Colleague

Thank you for pointing out the error I didn't even see.

Everything seemed to work properly the way that I had it before, so I guess my question is...is it just good practice to close them in the reverse order you opened them, or does it really make a difference that just didn't happen to appear in this particular instance?

Thank you again

- Jim

It's not that it's "good practice." That's the right way to do it, it's like asking if you should put semicolons at the end of your line. It's how HTML/XML works.

<tagopen><innertag>blah blah</innertag></tagopen> = TagOpen CONTAINS innertag CONTAINS text

NOT

<tagopen><innertag>blah blah</tagopen></innertag> = TagOpen CONTAINS START innertag CONTAINS text, END TagOpen

ShawnCplus 456 Code Monkey Team Colleague

this is an easy but hard fix.
If you are using the session_register("name"); You need to upgrade it to the $_SESSION = "1";. that is if you built the site yourself. if this is a packaged software you might have to see if they have an updated version. if you get stuck let me know, i just figured how to change my site

Actually it should be $_SESSION['name'] = $name which is the equivalent of what session_register('name') does. If you do ="1" then it will be 1 and not what was intended.

ShawnCplus 456 Code Monkey Team Colleague

within your login.php you have to set the login session
somewhere within there is where you have to add
$_SESSION = "1";
or 0 which ever one you choose to put.
\\this creates the session.

then on the members page you have to check it if it doesn't equal 1 then go back the the login.php

I gave him the answer, you can't use session_register in PHP5

ShawnCplus 456 Code Monkey Team Colleague

As noted in my comment. session_register does NOT work in PHP4

<?php
session_start();

$UName = $_REQUEST['UserName'];
$PWD = $_REQUEST['PWD'];

$dbcnx = mysql_connect('my host', 'username', 'password');
if (!$dbcnx) {
  header ('Location: index.php?Msg=2');
  exit();
}

//we could connect to the database

//Select the DB we want to deal with
mysql_select_db ("charbel");

//Now we have to check if the username and password entered are correct
$MyDate = date("Y-m-d", time());
$sql="Select * from Member where UserName='$UName' AND PWD='$PWD' AND ExpiryDate>='$MyDate'";

$result=mysql_query($sql);
$num=mysql_num_rows($result);


if($num!=0)
{


  $RegistrationType = mysql_result($result,0,"RegType");
  $login = $RegistrationType;
  // session_register does NOT work in PHP4
  $_SESSION['login'] = $login;

  $logID = mysql_result($result,0,"MemberID");
  $_SESSION['logID'] = $logID;

  $Email = mysql_result($result,0,"Email");
  $_SESSION['Email'] = $Email;

  //redirect users depending on registration type
  if($RegistrationType=="1" || $RegistrationType=="3")
    header ('Location: Members.php');
  if($RegistrationType==2)
    header ('Location: Members2.php');
  exit();
}
else
{
  header ('Location: index.php?Msg=1');
  exit();
}

header ('Location: index.php?Msg=1');
exit;
?>

Whenever you upgrade a version of PHP make sure you read on php.net what has changed so stuff like this doesn't break.

ShawnCplus 456 Code Monkey Team Colleague

Well you never showed me where you tried to set it in login.php, none of your code shows that.

ShawnCplus 456 Code Monkey Team Colleague

ok what we do in that case;iam little bit confused with that script
ok what should i do to prevent that link being opened by copy url

What do you mean "what do we do"? I just told you what to do. You have to set $_SESSION["login"] when a user logs in. I think its the 4th time I've said it now

Ezzaral commented: I'm wondering if you will have pulled all your hair out before this is done. +21
ShawnCplus 456 Code Monkey Team Colleague

the login.php will only verify the username and password to log in; but also i set that in login it wont work; i tried that; the script is well done but only problem is the session written in members; if u got any ideas about that session if we can write it in another way the one with equal to zero; and i displayed in php.ini the display_errors=On and no errors;strange

I don't think you're hearing me. Right now you're trying to figure out what to check $_SESSION["login"] against but that's not your problem. The problem is that $_SESSION["login"] never EXISTS in the first place to check against. Session variables aren't just magically set because you want them to.

ShawnCplus 456 Code Monkey Team Colleague

u r right;but i tried everything and why in php4 it works well;
i dont know anymore what session should i put here ;i have tried everything 0,1 and 2 and 3; even if i remove the logout button the page cabe enetered ; so do u have any idea about for to put something in url so when i logg in can be accessed and when i log out can not be accesed again till he put again his username and password, i mean it is easy and iam stuck on it-

It's because PHP4 is a big bag of crap. All you have to do is set the damn variable in login.php. You're never setting it. PHP5 is supposed to give you an error when you try to access an index that doesn't exist (in this case, "login") which means you have error reporting off.

ShawnCplus 456 Code Monkey Team Colleague

Where are you getting $_SESSION["login"] from, you're not setting it anywhere? It doesn't just magically appear.

ShawnCplus 456 Code Monkey Team Colleague

In what page are you setting $_SESSION['login'] ?

Also, don't email files around when you're on a forum asking for help that limits your audience to one person. Post the code here

ShawnCplus 456 Code Monkey Team Colleague

Well if you read my reply I point out that what you're dealing with isn't a session problem OR the code you posted isn't the code that is the issue. Post the rest of your code.

The only code that could be wrong in what you posted is this

#
if ($_SESSION["login"] !=0 && $_SESSION["login"] !=3)
#
{
#
header ('Location: index.php?Msg=3');
#
}

If $_SESSION['login'] isn't set then that will return true.

ShawnCplus 456 Code Monkey Team Colleague

Well php4 or php5 sessions are based on cookies so there is no concept of "copying the url" to duplicate the session which leads me to believe you are checking logged-in state based on a GET variable in which case the code you posted isn't the code that's being executed.

ShawnCplus 456 Code Monkey Team Colleague

Well if you think of it more this way. Every noun should be a table, properties of that noun should be a column in said table. Ie., A customer would be a table and it has an id, and a name, etc. inf. Things that are that noun are a row in that table so if there are 4 customers lined up that's 4 rows in the customer table, not 4 tables since they're all customers just different values for their properties.

ShawnCplus 456 Code Monkey Team Colleague

Ok so what i get from that is i should have a central login table which includes the company_id when create a _session with it. then with all of the data on another table i should include the company id so that i can recal it later?

Like I said, that's just an example. I'd have to see what your current design is to know how to fix it.

ShawnCplus 456 Code Monkey Team Colleague

I'd be willing to bet there is a major design flaw if every customer having their own table is the solution. Relational databases are relational for a reason so tables can form relationships based on primary and foreign keys.
these tables for example (not real SQL commands, just examples)

Customer
id    INT(10) AUTOINC PK --
name  VARCHAR(50)         |
                          |
CustomerCompanyMap        |
customer_id  FK ----------'
business_id  FK ----------.
                          |
Business                  |
id  INT(10) AUTOINC PK ---'
name VARCHAR(50)

Creates a many to many relationship between companies and customers (companies can have many customers and customers can have many companies)

ShawnCplus 456 Code Monkey Team Colleague

... ... .. why does every customer have their own table?

ShawnCplus 456 Code Monkey Team Colleague

use ls -a to see hidden files. In Linux (and derivatives) files preceded with a . are hidden.

ShawnCplus 456 Code Monkey Team Colleague

it must be named .htaccess

ShawnCplus 456 Code Monkey Team Colleague

Is it named .htaccess on the server or is it named htaccess? The leading dot matters.

ShawnCplus 456 Code Monkey Team Colleague

If you mean transferring data from your localhost to your webhost on scheduled times then I would suggest downloading and using crone for your localhost server (not to be mixed with crome or chrome). With crone, you have the ability to schedule command line events which in this case you could schedule a php file to execute in the background.

I'm pretty sure you mean cron :)

ShawnCplus 456 Code Monkey Team Colleague

The implementation of the Javascript interpreter is really up to the browser. Technically nothing should be garbage collected until a page is closed because of javascript's lexical scoping but as I said its up to the browser.

No, there is no way to explicitly destruct an object.

ShawnCplus 456 Code Monkey Team Colleague

$_SESSION is an array, you can use two separate indexes for user authentication and the cart ie., $_SESSION['user'] for the login and $_SESSION['cart'] for the cart. With sessions this is usually called namespacing if you want to research it on your own.

ShawnCplus 456 Code Monkey Team Colleague

Oh.... so that works... ok, i learnt something new today. thanks!

but for me to use that will mean breaking up old code and base classes... =(

I think I can proceed from here now. thanks alot for your help.

Well you don't have to use that. The basic concept to learn is that when using dynamic variables with __get and __set its usually better practice to use a holder variable so you have better separation of class variables and dynamic variables.

ShawnCplus 456 Code Monkey Team Colleague

If you're doing a container of sorts where you dynamically add variables and get them you might want something like this.

class Container
{
  private $holder;
  public function __get($key)
  {
    return isset($this->holder[$key]) ? $this->holder[$key] : false;
  }

  public function __set($key, $value)
  {
    $this->holder[$key] = $value;
  }

  public function toArray()
  {
    return print_r($this->holder, true);
  }
}
jakesee commented: Very helpful +1
ShawnCplus 456 Code Monkey Team Colleague

finally! I actually given up on this thread because I thought no one would come inside a thread so many replies.

thanks for the insight ShawnCPlus. Unfortunately, that function doesn't do what I want. because it does not accept an object. maybe I phrased my question wrongly.

$object = new MyClass();
// after some funny operations
// that dynamically creates more member variables
$var = get_class_variables($object); //error.

I'll look up "Reflection" on PHP first. thanks!!

it's actually get_class_vars, not get_class_variables.
If that still doesn't work try

$var = get_class_vars(get_class($object));
ShawnCplus 456 Code Monkey Team Colleague

wow, that's a lot of ranting without actually answering his question.

$vars = get_class_vars('Class');
// or
$vars = get_class_vars(new Class());

There are more in-depth methods (see Reflection in the PHP manual) but this will get the job done

ShawnCplus 456 Code Monkey Team Colleague

What should I use besides JavaScript to password protect a page?

A serverside language. PHP, JSP, ASP, etc. etc.

ShawnCplus 456 Code Monkey Team Colleague

http://code.google.com/apis/maps/documentation/introduction.html

That literally gives you a step-by-step guide and code on exactly what to do.

ShawnCplus 456 Code Monkey Team Colleague

Take a look at the google documentation, it's fairly in depth. It should be right around the same page you used to sign up for the API key.

ShawnCplus 456 Code Monkey Team Colleague

I made this JavaScript that password protects a page. But the password you type in is completely visible! I want it so that the password are those black dots for each letter.... If anybody gots anything, please post it here, thx. Oh yea, here is the script

<HTML>
<BODY>
<SCRIPT>
function passWord() {
var testV = 1;
var pass1 = prompt('Please Enter Your Password',' ');
while (testV < 3) {
if (!pass1) 
history.go(-1);
if (pass1.toLowerCase() == "cheese") {
alert('You Got it Right!');
window.open('protectpage.html');
break;
} 
testV+=1;
var pass1 = 
prompt('Access Denied - Password Incorrect, Please Try Again.','Password');
}
if (pass1.toLowerCase()!="password" & testV ==3) 
history.go(-1);
return " ";
} 
</SCRIPT>
<CENTER>
<FORM>
<input type="button" value="Enter Here" onClick="passWord()">
</FORM>
</CENTER>
</BODY>
</HTML>

You do realize that you have the raw password "cheese" in javascript. Anyone that wants to can just view the source of the page, see the password then type it in. There's really no way to authenticate users on the client-side only and not be completely insecure.

ShawnCplus 456 Code Monkey Team Colleague

Its definitely E_ALL, my framework automatically sets it to that in development mode. fwrite returns an integer, not false, so there is no error there. (But for some reason it doesn't work)

I've heard the tip about using brackets always, but I've never have bothered because I don't forget to add brackets when I add another statement. (Which is weird, I always end up forgetting to close up multiple parenthesis, add periods to connect strings and variables, etc.)

Well its more of a style choice really but if you're building a framework it usually means you're going to release it to the public and I'd say a majority of programmers whether they use Allman/BSD or K&R/OTBS style they do prefer to have closing braces.

In your trigger function always exit after a header() call so in that case you will need the braces because of having 2 statements. You don't need the other exit so just move it right after the header() call inside that condition

ShawnCplus 456 Code Monkey Team Colleague

If it's just dying with no message you might want to check to see if you have your error_reporting ini value set to something other than E_ALL (development only, don't turn this on live). Also, consider using braces around your conditions even if it's only one statement. It disambiguates the statements and is less confusing. I can't tell you how many times I've forgot the braces then added another statement and wondered why it didn't execute.

Also, your classes are dynamically instantiating members you should probably define them before-hand to make things easier, ie.,

class Log
{
  /**
  * File handle for the log
  * @var Resource
  */
  private $handler = NULL;
ShawnCplus 456 Code Monkey Team Colleague

... ... ... holy crap what the heck are you doing? You just crushed an ant with Mt. Everest.

If you're trying to remote the $

$string = str_replace('$', '', $price);

In regular expressions $ is not a reference. It means End of Line. so the regex s$ would match a line with s at the end. You can escape it just like any other character with a backslash.

ShawnCplus 456 Code Monkey Team Colleague

Well for one, why are you using a heading generating script to generate an image when it uses web-safe font?

ShawnCplus 456 Code Monkey Team Colleague

That looks suspiciously like a homework question. Perhaps you should give a shot at coding it a bit yourself before we give you a hand.