Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with onLoad in BODY using PHP 1

Status
Not open for further replies.

Zych

IS-IT--Management
Apr 3, 2003
313
US
Hello All,

I am having some problem with my code. Here it is:

Code:
<?php
  if($_POST['name'] != NULL) {
   echo "<body bgcolor='#7692AC' onLoad='alert('hello world!')'>";
   } else {
   echo "<body bgcolor='#000000'>";
   }
?>

Everything is working but the onLoad part. It runs through the color changes so I know that echo has been executed as it should. What am I doing wrong?

Thanks,

Zych
 
Just need to do this....

echo "<body bgcolor='#7692AC' onLoad=alert(\"Test\")>";

escape the double quotes, you had single quotes.


 
How about this:

Code:
<?php
  if($_POST['name'] != NULL) {
   echo "<body bgcolor='#7692AC' onLoad='alert(\"hello world!\")'>";
   } else {
   echo "<body bgcolor='#000000'>";
   }
?>

You need to escape the double quotes inside your echo statement.
 
Thanks. All great answers.

- Zych
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top