jbwebdesign Posted January 1, 2009 Report Posted January 1, 2009 hello everyone, I was wondering if anyone can help me out.....I want to be able to set a variable as a value of one of my forms.....here is my code but it doesn't work Untitled Document send to: <?php $test = $_POST['test']; if(isset($test)){ $monster = "testing"; } ?> i want the value for $monster to be inside my text box by the name of "send_to" if you have any ideas on how i can do this, please help me out. thanks:D Quote
falkencreative Posted January 2, 2009 Report Posted January 2, 2009 I'm not totally sure what you are attempting to do, since what you say you want to do and what your code do are very different things... Are you looking for something like this? > Untitled Document $monster = "testing"; ?> </pre> <form action="" name="test" method="POST"> send to: </form> <br><br If so, your main issue is that you need to set the variable before the form is rendered. As my example shows, you'll just need to move the PHP code where you set your variable above your form. Also, remember your form needs a method (either POST or GET) Quote
falkencreative Posted January 2, 2009 Report Posted January 2, 2009 Also should mention: You shouldn't need to use this for your form's action: "<?php $_SERVER['PHP_SELF']; ?>" If it is going to redirect to the same page on submit, you can just leave it blank like this: "" Quote
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.
Note: Your post will require moderator approval before it will be visible.