0

I have a section in my PHP page containing this bit of code:

echo '<div style="float:left;"><h3><strong>Edit User Account</strong></h3>
                                Date Registered: ' . $db_regdate . '<br>
                                User Type: ' . $usertype . '<br><br>
                            <form class="right_aligned" id="form1" name="form1" method="post" action="">
          				      <label>First Name*</label>
                				  <input name="firstname" type="text" id="firstname" value="' . $db_firstname . '"/>
                        <label>Last Name*</label>
                				  <input name="lastname" type="text" id="lastname" value="' . $db_lastname . '" />
                			     <label>Email Address*</label>
                				  <input name="email" type="text" id="email" value="' . $db_email . '" size="32" />                 			  
                				<label>New Password</label>
                                    <input name="password" type="password" id="password" size="10" />
                			    <label>Verify Password</label>
                			      <input name="verifypass" type="password" id="verifypass" size="10" />
        	                   <label>User Type </label>
                                  <select name="usertype" class="header" id="usertype">
                                    <option>Admin</option>
                                    <option>Staff</option>
                                    <option selected="selected">Client</option>
                                  </select>
                				<label></label>
                				  <input type="submit" name="submit_edit" id="submit_edit" value="save" />
                            </form>';

As you can see, I have concatenated (or whatever the appropriate term is) some essential variables within the form. This is basically an edit form so the variables basically load content from the database and display is on the form as 'initial values'.

What I'm trying to do it relocate the form to a file named edit_user.html. HOWEVER, if I try to use PHP include to include the form from an external file I do not get the same result. Instead of displaying the content of the variables, it does not parse the variables as a variable and instead it just displays:

' . $variable . ' in each field.

Where am I going wrong?

I am using this instead of the echo statement:

include('modules/forms/edit_user.html');

If I try to echo the include, I get the same result :(

Edited by ElegantElephant: n/a

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by ElegantElephant
0

i think the problem is you've saved your code in an html file.
As it's php code, you need to save it as a php file not html.

include('modules/forms/edit_user.php');

1

Thanks for your reply, but it still seems to bring the same problem :(

This worked for me just now on a test, you will need to change the sql details to suit your needs but...
in the main php and sql page

$sql  = "select * from users where username='emhmk1'";

$q = mysql_query($sql);
$r = mysql_fetch_array($q);
include ('name.html');

bear with me wth the code, it's very cruedly written!!
then in the edit html page (i called mine name.html)

<form action="" name="form" method="post">
Name:<br />
<input type="text" name="name" value="<?php echo  $r['username'];?>" />
</form>

That echo's out my username in the value of the input box.

Hope it helps

Votes + Comments
Thanks.
0

This worked for me just now on a test, you will need to change the sql details to suit your needs but...
in the main php and sql page

$sql  = "select * from users where username='emhmk1'";

$q = mysql_query($sql);
$r = mysql_fetch_array($q);
include ('name.html');

bear with me wth the code, it's very cruedly written!!
then in the edit html page (i called mine name.html)

<form action="" name="form" method="post">
Name:<br />
<input type="text" name="name" value="<?php echo  $r['username'];?>" />
</form>

That echo's out my username in the value of the input box.

Hope it helps

Ahh, that makes more sense. Thanks a lot, I really appreciate it :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.