I have two php files which are doing some database work so i want to show them on single page so i created an html file and include both of the php files, this methods work well every time i use but not working now, please help to solve. Both file works good if i open them individually very well but including them in one html file is not working, including single php file is not working either, i am using single css file for both of php file and i tried even without css but they do not appear in main html.
<html>
<body >
<? php include 'user_addf.php'; ?>
<? php include 'user_remf.php'; ?>
</body>
</html>
PHP file User_addf:
<link href="users_forms.css" rel="stylesheet" type="text/css" />
<div id="leftcolumn">
<form method="post" action="user_management_modf.php"><br/>
<legend> Add Users </legend>
<fieldset>
Username:
<input type="text" name="uname" id="" /><br /><br />
Password :
<input type="password" name="pass" id="" /><br /><br />
<input type="submit" value="Add User" />
</fieldset>
</form>
</div>
<?php
// PHP code
?>
2nd Php File user_remf:
<link href="users_forms.css" rel="stylesheet" type="text/css" />
<div id="rightcolumn">
<form method="post" action="user_remv.php"><br/>
<legend> Remove Users </legend>
<fieldset><br/>
<?php
include'connect.php';
$q=mysql_query("SELECT username FROM user");
echo "<select name=uname_list''><option>Select a username</option>";
WHILE($row=mysql_fetch_array($q))
{
echo "<option name='uname_remove' value=$row[username]>".$row[username]."</option>";
}
echo "</select>";
?>
<br/><br/><br/>
<input type="submit" value="Delete User" />
</fieldset>
</form>
</div>
You cannot have a space between <?
and php
it must be <?php
together.
Modify your code so that it is like this:
<?php include 'user_addf.php'; ?>
<?php include 'user_remf.php'; ?>
Having error reporting set would have given a parse/syntax error similar to this:
Parse error: syntax error, unexpected 'echo' (T_ECHO) in...
I used an "echo" statement in a quick test just to show you a possible message.
<? php
echo "Hello world";
Then in comments you stated:
No they are different, fist its like, in main.html and include 'user_addf.php'; include 'user_remf.php'; in main.php
You can only execute PHP in .html
files if you instructed Apache to treat .html
files as PHP.
Either you do that, or rename the extension to be .php
Add error reporting to the top of your file(s) which will help find errors.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// rest of your code
Sidenote: Error reporting should only be done in staging, and never production.