i am new to PHP. instead i learned the basic from w3schools and tizag. i'd created a registration form-like page using php tags, however when i uploaded to a php-based web hosting, i cant see anything..it juz show done in the browser status with blank page. Anyone kind enuf to check for me? much appreciate to those who help. Thanks.

<?php
$username = $_POST["name"];
$password = $_POST["password"];
$status = $_POST["status"];
$department = $_POST ["depart"];
$duemonth = $_POST ["due"];
$category = $_POST ["cate"];
$amount = $_POST ["amount"];
$specification = $_POST ["spec"];
if(!isset($_POST['submit'])){
?>
<html>
<head>
<title>::. CLAIM FORM</title>
<link rel="stylesheet" type="text/css"
href="my.css">
</head>
<body>
<br><br><br><br><br><br><br><br><br><br><br>
<h1>Welcome to the claim page.</h1>
<hr size=2 width=500px>
<h1>Please fill in all the details as required. Incomplete data 

will not be considered.</h1>
<div class="form-container">
 <form method="post" action="<?php echo $PHP_SELF;?>">

		<div><label>Name:<?php echo  $_POST["name"];?

></label><br></div>
			<div><label 

for="type">Department:</label>
				<select name="depart">
					<optgroup label="---

SELECT---">

					
<option>KKK</option>							
<option>KEE</option>					
<option>KPM</option>					
<option>KMP</option>					
<option>KKA</option>										
<option>KBP</option>					
<option>KAA</option>
					</optgroup>
				</select>
				</div>
			
			<div><label for="type">Due month:</label>
				<select name="due">
					<optgroup label="---

SELECT---">						
					<option>JAN</option>	
					<option>FEB</option>		
                                        <option>MAC</option>		
                                        <option>APR</option>		
                                        <option>MAY</option>		
					<option>JUN</option>		
					<option>JUL</option>
					<option>AUG</option>		
					<option>SEP</option>
					<option>OCT</option>		
					<option>NOV</option>
					<option>DEC</option>		
					</optgroup>
				</select>
			</div>
			<div><label for="type">Category:</label>
				<select name="cate">
					<optgroup label="---

SELECT---">

						

<option>Faks</option>
						

<option>Electricity</option>
						<option>Road 

tax</option>
						<option>Vehicle 

insurance</option>
						

<option>Petrol</option>
						</optgroup>
				</select>
			</div>
		<div><label for="name">Amount:</label></div>
		<div><input type="text" name="amount" 

value="RM"></div>


	<div><label for="name">Specification:</label> <input 

type="text" name="spec" size="50"/></div>
</form>

<h1>Please upload the bill as we may process it as soon as 

possible. Thank You.</h1>

<form enctype="multipart/form-data" action="uploader.php" 

method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" >
<h1>Choose a file to upload:</h1>
<div><label><input name="uploadedfile" type="file" ><input 

type="submit" value="Upload File" ></label>
</div></form>

<br>
<p class="submit"><input type="submit" value="Submit" ></p>
</div>
</body>
</html>
<?
} else {
<h1> Below is the infos you had submitted:</h1>
echo "<h1>Department:</h1>" .$department.".<br/>";
echo "<h1>Due month:</h1>" .$duemonth.".<br/>";
echo "<h1>Category:</h1>" .$category.".<br/>";
echo "<h1>Amount:</h1>" .$amount.".<br/>";
echo "<h1>Specification:</h1>" .$specification.".<br/>";{
echo $f."<br />";
}
}
?>

<div><label>Name:<?php echo $_POST["name"];? ></label><br></div> In this line, you have a whitespace after $_POST["name"];? here > It should have been like ?> .
Turn on error reporting. It will help you identify your errors. If you have access to php.ini file, turn on display_errors. If you don't have access to php.ini file, then, put

ini_set("display_errors","on"); 
error_reporting(E_ALL);

in your script.

Cheers,
Naveen

Edit: More about error_reporting here .

Edit 2: And here is one more error. This line should be echo'ed as well. <h1> Below is the infos you had submitted:</h1> Should have been echo "<h1> Below is the infos you had submitted:</h1>"; Edit 3:

{
echo $f."<br />";
}

What is this for ? This loop don't have a condition ! { } wont do anything.

thanks for your help....it works!!!

<?php
ini_set("display_errors","on");
error_reporting(E_ALL);
$username = $_POST["name"];
$password = $_POST["password"];
$status = $_POST["status"];
$department = $_POST ["depart"];
$duemonth = $_POST ["due"];
$category = $_POST ["cate"];
$amount = $_POST ["amount"];
$specification = $_POST ["spec"];
if(!isset($_POST['submit'])){
?>
<html>
<head>
<title>::. CLAIM FORM</title>
<link rel="stylesheet" type="text/css"
href="my.css">
</head>
<body>
<br><br><br><br><br><br><br><br><br><br><br>
<h1>Welcome to the claim page.</h1>
<hr size=2 width=500px>
<h1>Please fill in all the details as required. Incomplete data 

will not be considered.</h1>
<div class="form-container">
 <form method="post" action="<?php echo $PHP_SELF;?>">

		<div><label>Name:<?php echo  $_POST["name"];?></label><br></div>
			<div><label 

for="type">Department:</label>
				<select name="depart">
					<optgroup label="---

SELECT---">

					
<option>KKK</option>							
<option>KEE</option>					
<option>KPM</option>					
<option>KMP</option>					
<option>KKA</option>										
<option>KBP</option>					
<option>KAA</option>
					</optgroup>
				</select>
				</div>
			
			<div><label for="type">Due month:</label>
				<select name="due">
					<optgroup label="---

SELECT---">						
					<option>JAN</option>	
					<option>FEB</option>		
                                        <option>MAC</option>		
                                        <option>APR</option>		
                                        <option>MAY</option>		
					<option>JUN</option>		
					<option>JUL</option>
					<option>AUG</option>		
					<option>SEP</option>
					<option>OCT</option>		
					<option>NOV</option>
					<option>DEC</option>		
					</optgroup>
				</select>
			</div>
			<div><label for="type">Category:</label>
				<select name="cate">
					<optgroup label="---

SELECT---">

						

<option>Faks</option>
						

<option>Electricity</option>
						<option>Road 

tax</option>
						<option>Vehicle 

insurance</option>
						

<option>Petrol</option>
						</optgroup>
				</select>
			</div>
		<div><label for="name">Amount:</label></div>
		<div><input type="text" name="amount" 

value="RM"></div>


	<div><label for="name">Specification:</label> <input 

type="text" name="spec" size="50"/></div>
</form>

<h1>Please upload the bill as we may process it as soon as 

possible. Thank You.</h1>

<form enctype="multipart/form-data" action="uploader.php" 

method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" >
<h1>Choose a file to upload:</h1>
<div><label><input name="uploadedfile" type="file" ><input 

type="submit" value="Upload File" ></label>
</div></form>

<br>
<p class="submit"><input type="submit" value="Submit" ></p>
</div>
</body>
</html>
<?
} else {
echo "<h1> Below is the infos you had submitted:</h1>";
echo "<h1>Department:</h1>" .$department.".<br/>";
echo "<h1>Due month:</h1>" .$duemonth.".<br/>";
echo "<h1>Category:</h1>" .$category.".<br/>";
echo "<h1>Amount:</h1>" .$amount.".<br/>";
echo "<h1>Specification:</h1>" .$specification.".<br/>";
echo $f."<br />";
}
?>

Check this and compare it with your script. Oh, btw, you can ignore notices(if you get any!).

err..however the submit button seems not working..it doesnt show what the user had enter..any syntax error over there?

Ah! thats because, you don't have a name for submit button, but you are checking if submit is set. if(!isset($_POST['submit'])){ Just give a name to submit button. name="submit" and it will work.

thank you so much nav33n .... much appreciate what u'd trying to help... thanks again...
my prob solved..

:) You are welcome!

by the way, i created a login page, the submit button action is linked to welcome.php which shows the username on it. In this welcome.php also i created a link to the page where the codes shown above. However the username cant be shown at this page.
Look at this:

<div><label>Name:<?php echo  $_POST["name"];?></label><br></div>

which is within form margin. Is there any problem with this as well?

Nothing wrong with the code. Check if $_POST is correct. Check all the post-ed form variables by using print_r($_POST) in welcome.php.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.