Jump to content

Recommended Posts

Ok, so I'm pretty new at this, but I'm really frustrated with myself right now because I can't figure out what is going on here.

 

I've got the code below up near the very top inside the <body> tag.

<?php 

{

$success = ('<p class="style2">The user account was successfully created.</p>') ;

$duplicate = ('<p class="style2">The username supplied already exists within the system.</p>') ;
}

{
	if  	($_GET['msg']=('duplicate'))
  				$msg = $duplicate ;
	elseif	($_GET['msg']=('success'))
				$msg = $success ;
}

?>

 

Then, farther down the page, it calls for the $msg variable...

<?php echo $msg ; ?>

 

The page always returns the text from $duplicate no matter what the $_GET['msg'] is set as in the URL.  It even shows that when there is NO "?msg=" in the URL.  I tried adding a

if(isset($_GET['msg']

line, and that stopped it from showing when there was no "?msg=" in the URL, but it also forced the same response no matter what (which I understand, because it's just looking to see if it's set then setting the variable.)

 

Anyway, I'm rambling - can anyone tell me what I'm doing wrong?  The page is located at http://www.radioimaging101.com/new_user.php

 

Thank you.

 

Hey Mike,

 

What happens if you try this code:

<?php
$success = '<p class="style2">The user account was successfully created.</p>';
$duplicate = '<p class="style2">The username supplied already exists within the system.</p>';

if($_GET['msg'] == 'duplicate') {
	$msg = $duplicate;
} elseif($_GET['msg'] == 'success') {
               $msg = $success ;
}
?>

Also, you should double-check the position of your brackets.  Brackets denote the beginning and end of a block structure.  These structures include function definitions, loops, and conditional statements.  Writing something like:

 

{
if(/* some conditional statement */)
   /* action */
else
   /* another action */
}

 

Is wrong.  Instead, it's:

 

if(/* some conditional statement */)
{
   /* action */
}
else
{
   /* another action */
}

 

The same thing goes for loops and function definitions:

 

while(/* some condition is true */)
{
   /* stuff to do */
}

function myFunction($arg)
{
   /* do something with $arg */
}

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.