Page 1 of 1

insert $_POST[] in echo statement

Posted: Thu Apr 10, 2003 7:21 am
by jarow
In the final echo statement I am trying to insert the information from the form field $_POST['first_name'] in the following sentence. "Thank you $_POST['first_name'], please log in now". But I keep getting a parse error. What am I doing wrong?

Code: Select all

<?php

 $sql = "INSERT INTO USERS (first_name, last_name, email_address, username, password, signup_date) 
   VALUES('$first_name', '$last_name', '$email_address', '$username', '$password', NOW())"; 
   @mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>'); 

   if (mysql_affected_rows() < 1) { 
      echo 'There has been an error creating your account. Please contact the webmaster.'; 
      } 
	  else
	  { 
     echo 
  '<div align="center">
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Thank you , please <a href="bd_login.php"><font color="#FFFF00">login </font></a>now.</strong></font></p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</div>';
 	}
	}
} 


?>

Posted: Thu Apr 10, 2003 7:28 am
by pootergeist
just step out of the string and concatenate with a dot ' .$var

<strong>Thank you, ' .$_POST['first_name']. ' please <a href..............

Posted: Thu Apr 10, 2003 10:09 am
by twigletmac