Variable Titles Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Cosarin
Forum Newbie
Posts: 5
Joined: Thu May 25, 2006 3:22 pm

Variable Titles Problem

Post by Cosarin »

I hope someone can help. I am a bit of a newbie to php.

I am running two programs on my site. Both require logins. I have placed login panels to both on my homepage.

The only problem is that both scripts need variables called username and password.

This causes a validation error as you can imagine.

I know that one method would be to change one of the programs variable names, but this will violate my licences.

I cant think of it, but is there a way I could write a simple php page that collects variable for one of them using new names such as username2 and password2, rename them to username and password but retain the results, and then automatically post them to the second program script using the correct variable names?

I hope someone can help with this.

Regards

Cosarin
Last edited by Cosarin on Sun Aug 13, 2006 2:46 pm, edited 1 time in total.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

The only problem is that both scripts need variable called username and password.
Are they invoked at the same time? What is the conflict here?
Cosarin
Forum Newbie
Posts: 5
Joined: Thu May 25, 2006 3:22 pm

Post by Cosarin »

Volka.

No there are not invoked at the same time.

I can simply leave them both called the same titles, and everything works fine.

The problem is that two fields with the same title name cause validation errors.

The validation errors do not stop anything working, but I like to keep things neat so that my pages validate correctly.

Hope you can help

Cosarin
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Can you modify the PHP code from either of the two scripts that are using the login forms? If so, go into one and change all references to $_POST['username'] and $_POST['password'] to $_POST['newusernamefield'] and $_POST['newpasswordfield']. That should correct it in the code. Then just change the username and password field names in the form for that login process to newusernamefield and newpasswordfield (or whatever you choose for them, but you get the point).
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I still do not see the problem ...because I'm not sure what the scenario really is.

Two scripts that react on same user input. They do not run at the same time. Validation errors.
Ok, makes me guess that maybe, just maybe there are two form elements on the same page having the same field/names ..?..
If so, there is no problem with validation

Code: Select all

<?xml version="1.0"?>
<!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>xyz</title>
	</head>
	<body>
		<form method="post" action="whatever1">
			<div>
				<input type="text" name="username" />
				<input type="text" name="password" />
				<input type="submit" />
			</div>
		</form>
		<form method="post" action="whatever2">
			<div>
				<input type="text" name="username" />
				<input type="text" name="password" />
				<input type="submit" />
			</div>
		</form>
	</body>
</html>
http://validator.w3.org/check wrote:This Page Is Valid XHTML 1.0 Strict!
Or is it not about the html code but the two scripts trying to authenticate the user from the same http request data?
If so, why do they need different credentials to authenticate the same user? ;)
Post Reply