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
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)
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: ""
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now