Lydfreak Posted May 10, 2015 Share Posted May 10, 2015 Hi! I have a small problem. Jeg have a script (code128b-1.php) that generates a barcode from a number I write in a textbox. If I don't put a number in this textbox, then the barcode script still make a barcode that contains no data. How can I make a if-sentence that check if the variable $datatoencode1 is empty, and in case it is empty, then it will use the picture nullimage.png. Else I want to use the barcode that the script gives me. Code: <?php$datatoencode1 = $_POST['datatoencode1'];?><img src = "code128b-1.php?D=<?php echo $datatoencode1 ?>"> Link to comment https://forums.phpfreaks.com/topic/296175-help-with-if-sentence-in-barcode-script/ Share on other sites More sharing options...
Barand Posted May 10, 2015 Share Posted May 10, 2015 if (empty($datatoencode1)) echo "<img src='default.png'>"; else echo "<img src='code128b-1.php?D=$datatoencode1'>"; Link to comment https://forums.phpfreaks.com/topic/296175-help-with-if-sentence-in-barcode-script/#findComment-1511307 Share on other sites More sharing options...
Lydfreak Posted May 10, 2015 Author Share Posted May 10, 2015 if (empty($datatoencode1)) echo "<img src='default.png'>"; else echo "<img src='code128b-1.php?D=$datatoencode1'>"; Thank you! That really helped Link to comment https://forums.phpfreaks.com/topic/296175-help-with-if-sentence-in-barcode-script/#findComment-1511309 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.