doesnt show anything
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>
<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></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>
<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."";
}
}
?>
evios
Junior Poster in Training
60 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
<div><label>Name:<?php echo $_POST["name"];? ></label></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."";
} What is this for ? This loop don't have a condition ! { } wont do anything.
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
thanks for your help....it works!!!
evios
Junior Poster in Training
60 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
<?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>
<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></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>
<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."";
}
?>
Check this and compare it with your script. Oh, btw, you can ignore notices(if you get any!).
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
err..however the submit button seems not working..it doesnt show what the user had enter..any syntax error over there?
evios
Junior Poster in Training
60 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
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.
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
thank you so much nav33n .... much appreciate what u'd trying to help... thanks again...
my prob solved..
evios
Junior Poster in Training
60 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
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></div>
which is within form margin. Is there any problem with this as well?
evios
Junior Poster in Training
60 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
Nothing wrong with the code. Check if $_POST['name'] is correct. Check all the post-ed form variables by using print_r($_POST) in welcome.php.
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356