IHaveAQuestion Posted August 28, 2014 Share Posted August 28, 2014 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/lIwLZ1Gthanks. Quote Link to comment https://forums.phpfreaks.com/topic/290705-using-inline-php-the-username-already-exists/ Share on other sites More sharing options...
Jacques1 Posted August 28, 2014 Share Posted August 28, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/290705-using-inline-php-the-username-already-exists/#findComment-1489187 Share on other sites More sharing options...
Digitizer Posted August 28, 2014 Share Posted August 28, 2014 @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) Quote Link to comment https://forums.phpfreaks.com/topic/290705-using-inline-php-the-username-already-exists/#findComment-1489224 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.