Jump to content

Using inline PHP; <h1><font color="000088">The username <?php '.$username.' ?> already exists";</h1>


IHaveAQuestion

Recommended Posts

ISSUE.
A User enters information into a form.
If the 'username' is already taken, a 'message' in Red and with larger font-size will be returned, for example,
"The username $username already exists."
If the username is 'mattd' then the message should say, "The username mattd already exists."

Within my php application, I have included 'inline html'.
Here is part of the code:

 

....
if (mysql_num_rows($query_run)==1) {
// it will never = more than one because only
//one user will or will not exist
?>

<html>
</body>
<h1><font color="#FF0066">The username <?php echo $username; ?>already exists.</h1>
</body>
</html>

<?php
}else{
//start the registration process
$query = "INSERT INTO `Names` VALUES
....

 

1. At one point I did get this: "The username mattd already exists."
2. But now I only get "The username already exists."
I am not retrieving the $username variable.

 

This screenshot is found here:
http://imgur.com/lIwLZ1G


thanks.

Link to comment
Share on other sites

What does this have to do with HTML? This is clearly a PHP problem.

 

You said you don't retrieve the $username variable. My guess is that the code was written a long time ago when the register_globals setting was still around. Back in those days, the PHP core developers thought it's a good idea to automatically create variables from input parameters. For example, if the script was executed with a form parameter called “username”, then PHP would automatically create a $username variable. This quickly turned out to be a major security vulnerability (see the link), so the whole feature was deprecated in 2009 and removed in 2012. But appearently it lives on in your code.

 

Define your variables properly, and the problem will go away.

Link to comment
Share on other sites

@jacques1: He may have turned off warnings/errors reporting so to him, the error

//The line below was formatted according to html style he defined
The username 
Notice: Undefined variable: username in <file_path>.php on line 5
already exists.

he is getting just the line

The username already exists

You are right. he may not have defined $username.

 

@IHaveAQuestion: Can you post the full code you wrote? and please write them in code section (using <> icon in this editor)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.