I would like to use some php script in the body of a php document that changes the inclusion of a <div> or a <table> depending on the users input.
For instance:
<input name=user_input value="<?php echo $user ?>" etc. >
if ($user == "Fred")
{include ('Fred_Div.php');}
if ($user == "Graham")
{include ('Graham_Div.php');}
Where Fred_Div.php and Graham_Div.php have been predefined as simple HTML code snippets stored as .php files
I have tried using $_COOKIE but this doesn't seem to work. Perhaps I need to pre-define ?
Using php with <input>
Moderator: General Moderators
Re: Using php with <input>
Hi, can you explain a bit more clearly. I understand your explanation but your code doesn't seem right according to what you want.
Firstly correct:
<input name="user_input" value="<?php echo $user ?>" etc. >
Now, you said, the changes will be according to the user input, but you have already defined the input by saying "value="<?php echo $user ?>". This line will display fred or graham in the textbox.
It's better that you submit the form where it will go to a process page.
Firstly correct:
<input name="user_input" value="<?php echo $user ?>" etc. >
Now, you said, the changes will be according to the user input, but you have already defined the input by saying "value="<?php echo $user ?>". This line will display fred or graham in the textbox.
It's better that you submit the form where it will go to a process page.
-
Graham2107
- Forum Newbie
- Posts: 2
- Joined: Fri Jul 25, 2008 3:15 am
Re: Using php with <input>
Perhaps I didn't explain myself totally.
<input name="user_input" value="0" etc. >
if user_input equals "Fred" then include xyz.php and if user_input equals "Graham" then include abc.php
This is, the form actually changes format, depending on what the user_input is.
Does that make more sense ?
<input name="user_input" value="0" etc. >
if user_input equals "Fred" then include xyz.php and if user_input equals "Graham" then include abc.php
This is, the form actually changes format, depending on what the user_input is.
Does that make more sense ?
Re: Using php with <input>
Ya I understand. First, you cannot change your display simply by entering data in a textbox. You should summit the data, which means there should be a submit button and another page.
Or if you don't want to use a submit button, then you should use ajax.
http://www.tizag.com/ajaxTutorial/
Or if you don't want to use a submit button, then you should use ajax.
http://www.tizag.com/ajaxTutorial/