session_start();
include 'conn.php';
echo 'Welcome Back: <strong>'.$_SESSION['username'].'</strong>';
if (isset($_POST['id'])&&isset($_POST['DateApplied'])&&isset($_POST['LeaveType'])&&isset($_POST['LeaveFrom'])
&&isset($_POST['LeaveTo'])&&isset($_POST['CC'])&&isset($_POST['To'])&&isset($_POST['Message'])&&isset($_POST['Subject'])){
$id =$_POST['id'];
$DateApplied =$_POST['DateApplied'];
$LeaveType =$_POST['LeaveType'];
$LeaveFrom =$_POST['LeaveFrom'];
$LeaveTo =$_POST['LeaveTo'];
$CC =$_POST['CC'];
$To =$_POST['To'];
$Message=$_POST['Message'];
$Subject =$_POST['Subject'];
if (!empty($To)&&!empty($CC)&&!empty($Message)&&!empty($Subject)){
echo 'OK';
} else {
echo 'NOT OK';
}
}
hi please help. function not empty not working. echo "NOT OK" i didnt see when i hit submit.
heres my html code.
<?
if (isset($_SESSION['username']) == true){
$username = $_SESSION['username'];
$query = mysql_query("SELECT * FROM `employeeleavedetails` WHERE `username`='$username'");
}
while ($count = mysql_fetch_assoc($query)){
?>
<html>
<center>
<table>
</center>
<form action="LeaveApplication.php" method="POST">
<table border="1" align="center" width="450" bgcolor="GRAY">
<tr>
<td colspan="1" bgcolor="GOLD" align="center"><font size="2"><strong> Applicant </font></strong></td>
</tr>
<tr>
<td><font size="2" color="white"> Employee ID:</font>
<font color="White"> <input type="text" name="assignedID" value="<?php echo $count['assignedID']?>" size="3" readonly></font>
<input type="hidden" name="id">
<tr>
<td>
<font size="2" color="white"> Employee Name: </font> <font color="white"> <input type="text" name="FullName" value="<?php echo $count['FullName']?>" readonly></font>
</td>
</tr>
</td>
</tr>
<tr>
<td colspan="4" bgcolor="GOLD" align="center"><font size="2"><strong> Employee Leave Information </font></strong></td>
<tr>
<td><font size="2" color="white"> Date Applied: <input type="text" name="DateApplied" value="<?php echo date("Y/m/d"); ?>" readonly></font>
<input type="hidden" name="DateApplied"/>
</tr>
<td><font size="2" color="white" name="LeaveType"> Type of Leave: </font>
<select name="">
<option value="Annual Leave"> Annual Leave </option>
<option value="Sick Leave"> Sick Leave </option>
<option value="Vacation Leave"> Vacation Leave </option>
</select>
</tr>
<td><font size="2" color="white"> Leave From: </font>
<input type="text" name="LeaveFrom" value="<?php echo date("Y/m/d") ?>">
<tr>
<td><font size="2" color="white"> Leave To: </font>
<input type="text" name="LeaveTo" value="<?php echo date("Y/m/d") ?>">
<tr>
<td colspan="4" bgcolor="GOLD" align="center"><font size="2"><strong> This information will be sent via Email </font></strong></td>
<tr>
<td><font size="2" color="white"> Recommending Officer:<br>
<input type="text" name="CC">Ex. my.supervisor@yahoo.com</font>
</tr>
<tr>
<td><font size="2" color="white"> Approve By:
<input type="text" name="To">Ex. hr.manager@yahoo.com </font>
</tr>
<tr>
<td><font size="2" color="white"> Subject:
<input type="text" name="Subject"></font>
</tr>
<tr>
<td><font size="2" color="white"> Remarks: </font>
<textarea cols="45" rows="5" name="Message"></textarea>
</tr>
<center><font size="2">Annual Leave: <strong><?php echo $count['AnnualLeave']?></strong>
<font size="2">Sick Leave: <strong><?php echo $count['SickLeave']?></strong>
<font size="2"> Vacation Leave: <strong><?php echo $count['VacationLeave']?></strong> </font></center>
</table>
<br>
<center>
<input type="Submit" value="Apply">
<input type="Button" value="Reset">
<input type="Button" value="Exit" onclick="window.location='logout.php'">
</center>
<br>
</form>
<? }
mysql_close(); ?>
</html>
Function echo not working
Moderator: General Moderators
Re: Function echo not working
The subject says that function echo isn't working, yet in the middle of a bunch of code you put a note about a problem with empty.
I would suggest that you edit your post and put the question at the top, and then in the editor use the
I would suggest that you edit your post and put the question at the top, and then in the editor use the
Code: Select all
button to wrap the code you pasted. Trying to read a ton of code like that is very difficult (especially on my tired eyes)
Also in the middle you mention something about [b]empty[/b], try checking the manual for it to see what all evaluates as empty:
http://php.net/empty
Usually that is where there is a misunderstanding, that you think something should come back as empty when it doesn't.
-Greg- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Function echo not working
Code: Select all
if (!empty($To)&&!empty($CC)&&!empty($Message)&&!empty($Subject)){
echo 'OK';
} else {
echo 'NOT OK';
}
I was also about to tell you (OP) to wrap the code but i saw twinedev already did. Not only does wrapping the code make it easier to read but it also increases your chances of getting helped exponentially. Myself for example will often completely give the code a skip just because it's not wrapped so i would guess many others also have similar ideas towards unwrapped code. Hth
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering