p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Undefined variable problem


Message #1 by David Long <davidl@w...> on Tue, 2 Jan 2001 12:35:32 -0000
-----Original Message-----

From: kumudha [mailto:kumudha@e...]

Sent: 02 January 2001 05:55

To: listsupport@w...

Subject: php





hi



    there is a php error which says undefined variable action.How to define

it and as what.





<?php 

   if ($action == "setcookie"){

   setcookie("visitor",time() + 90 * 86400);

   }

   if(isset($visitorname)):

?>



welcome <b><? echo $visitorname ?></b>!



<? else: ?>

<form>



<?php <input type="hidden" name="action" value="setcookie"> ?>

welcome,please tell us your name:<input type="text" name="visitor"><br>

<input type="submit" value="  ok ">

</form>

<? endif; ?>



--- 

NEED TECHNICAL TIPS, TOOLS, AND INSIGHTS?  Is FREE okay?

Visit EarthWeb for the latest in IT Management, Software Development, 

Web Development, Networking & Communications, and Hardware & Systems.  

Click on http://www.earthweb.com for FREE articles, tutorials,

and discussions from the experts.

---

You are currently subscribed to beginning_php as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-beginning_php-$subst('Recip.MemberIDChar')@p2p.wrox.com

Message #2 by "Joel Wickard" <jwickard@l...> on Tue, 2 Jan 2001 17:26:26 -0000
according to the code you have posted, you need to change the line:



    <?php <input type="hidden" name="action" value="setcookie"> ?>



to read:



    <?php echo("<input type='hidden' name='action' value='setcookie'>); ?>



because the way you originally had it written, php was never parsing the

sentence as an html statement, therefore, never creating the variable

named action.



--- 

NEED TECHNICAL TIPS, TOOLS, AND INSIGHTS?  Is FREE okay?

Visit EarthWeb for the latest in IT Management, Software Development, 

Web Development, Networking & Communications, and Hardware & Systems.  

Click on http://www.earthweb.com for FREE articles, tutorials,

and discussions from the experts.

---

You are currently subscribed to beginning_php as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-beginning_php-$subst('Recip.MemberIDChar')@p2p.wrox.com


  Return to Index