Jump to content

can php get into the form? asap pls


yee

Recommended Posts

To get something from a form, you set the location of the form to goto the php file. Then use $var = $_POST['NAME']; in the php file to get the info from the formNAME being the name of a field in your form.EX: <input type='password' name='NAME' />

Link to comment
Share on other sites

yes the post above is how you pass data from a form to a php script, however, reading your post, I can't help think that you may be talking about loading php content into a form so the user can either use that data of change it.If thats the case, you'll need a file with your variables you want to use. To include those variables, use:

<?php include ('http://www.domain.com/variablesfile.php');?>

then when you want to place the data into fields, do this.lets say you have a text field that you want it to be prefilled with $variable1 from your variablesfile.php, in the input tag for the value attribute, you would insert

<?php echo "$variable1";?>

so your input field would look like this:

<input name="useraddress" id="useraddress" type="text" size="33" value="<?php echo '$variable1';?>" />

now if you want to do this for checkboxes, it gets more complicated. first you make sure your including the variables of course, but then you need to make something like this:

<?php if ($agreetoterms == "yes") {$termschecked =  "checked=\"checked\"";}else {$termschecked = "";};?>

and so on untill you have covered all options.Now for the input of the checkboxes:

<label><input type="checkbox" name="termsagreement" value="yes" <?php echo '$termschecked';?> />I agree to these Terms.</label>

If you are using radio buttons its the same as the checkboxes but every inctance of the word "checked" becomes "selected".I hope this helps somebody.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...