DBookatay Posted September 15, 2007 Share Posted September 15, 2007 What is the correct way to write the code I am trying to do? if ($_POST['balance'] IS NULL) {$balance = $_POST['totalPymts'];} else {$balance = $_POST['balance']";} I'm stumped... Link to comment https://forums.phpfreaks.com/topic/69482-solved-correct-way-to-write-this/ Share on other sites More sharing options...
rarebit Posted September 15, 2007 Share Posted September 15, 2007 This should help inform you: <?php if(isset($_POST['test'])) { echo "passed<br>"; } if ($_POST['test'] == NULL) { echo "something<br>"; } if(empty($_POST['test'])) { echo "pass<br>"; } print "<html><head></head><body>"; print "<form action='test2.php' method='POST'><input type='text' name='test'><input type='submit' value='send'></form>"; print "</body></html>"; ?> Link to comment https://forums.phpfreaks.com/topic/69482-solved-correct-way-to-write-this/#findComment-349111 Share on other sites More sharing options...
watthehell Posted September 15, 2007 Share Posted September 15, 2007 <?php if (empty($_POST['balance'])) { $balance = $_POST['totalPymts']; } else { $balance = $_POST['balance']; } ?> Link to comment https://forums.phpfreaks.com/topic/69482-solved-correct-way-to-write-this/#findComment-349119 Share on other sites More sharing options...
darkfreaks Posted September 15, 2007 Share Posted September 15, 2007 i believe he wants it nulled ??? Link to comment https://forums.phpfreaks.com/topic/69482-solved-correct-way-to-write-this/#findComment-349120 Share on other sites More sharing options...
darkfreaks Posted September 15, 2007 Share Posted September 15, 2007 <?php if ($_POST['balance']=="NULL") {$balance = $_POST['totalPymts'];} else {$balance = $_POST['balance'];}?> Link to comment https://forums.phpfreaks.com/topic/69482-solved-correct-way-to-write-this/#findComment-349123 Share on other sites More sharing options...
DBookatay Posted September 15, 2007 Author Share Posted September 15, 2007 <?php if (empty($_POST['balance'])) { $balance = $_POST['totalPymts']; } else { $balance = $_POST['balance']; } ?> Thank you, I totally forgot about the "if (empty" idea... Link to comment https://forums.phpfreaks.com/topic/69482-solved-correct-way-to-write-this/#findComment-349133 Share on other sites More sharing options...
darkfreaks Posted September 15, 2007 Share Posted September 15, 2007 empty works alot better than null and your welcome i wasnt sure whether you wanted it null or empty so i had to guess Link to comment https://forums.phpfreaks.com/topic/69482-solved-correct-way-to-write-this/#findComment-349135 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.