tawevolution Posted October 26, 2006 Share Posted October 26, 2006 ok, this is what I have so far:[code]if($headof=1){$title=="Head of ";}else{$title=="none";}[/code]$headof is taken from an imput checkbox (i know that works) where if it it checked then the value is 1, but I dont know why the if statement doesnt work.At the bottom of the form I then have:[code]echo("$title");[/code]But nothing ever comes up?!Any help?Thanks, Evo[hr]below is the full code:[code]<?php$self = $_SERVER['PHP_SELF'];$real = $_POST['real'];$tag = $_POST['tag'];$dept = $_POST['dept'];$lang = $_POST['lang'];$headof = $_POST['headof'];?><p><form action="<?php echo( $self ); ?>" method="post" enctype="multipart/form-data"> <table width="500" border="0" align="center" cellpadding="3" cellspacing="0"> <tr> <td><strong>Member Language:</strong></td> <td><select name="lang"> <option value="err">Choose a Language</option> <option value="en">English</option> <option value="fr">French</option> <option value="de">German</option> <option value="us">American</option> </select> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td><strong>Real Name:</strong></td> <td><input name="real" type="text" size="30" /></td> </tr> <tr> <td><strong>TLS Name:</strong></td> <td><input name="tag" type="text" size="30" /></td> </tr> <tr> <td><strong>Department:</strong></td> <td><select name="dept"> <option value="err">Choose a Department</option> <option value="Management">Management</option> <option value="Programming">Programming</option> <option value="3D Artists">3D Artists</option> <option value="2D Artists">2D Artists</option> <option value="Website Development">Website Development</option> <option value="Sound Development">Sound Development</option> <option value="Translation">Translation</option> <option value="Beta Testing">Beta Testing</option> <option value="Other">Other</option> </select> </td> </tr> <tr> <td><strong>Head of Department?</strong></td> <td><input type="checkbox" name="headof" value="1" /></td> </tr> <tr> <td> </td> <td><input name="submit" type="submit" value="Submit" /> <input type="reset" name="Reset" value="Reset" /> </td> </tr></table></form></p><?php$1 = "1";if($headof=1){$title=="Head of ";}else{$title=="none";}#now echo the contents of the formecho("$lang, $real, $tag, $dept, $title");?>[/code] Link to comment https://forums.phpfreaks.com/topic/25154-if-else-statement-help/ Share on other sites More sharing options...
redarrow Posted October 26, 2006 Share Posted October 26, 2006 I dont get you logic but this is what i think you mean theo.[code]<?php$1 = "1";if($headof=1){$title=="Head of ";echo $title;}else{$title=="none";echo $title;}?>[/code] Link to comment https://forums.phpfreaks.com/topic/25154-if-else-statement-help/#findComment-114673 Share on other sites More sharing options...
Orio Posted October 26, 2006 Share Posted October 26, 2006 For check boxes, the test is not "if($headof=1)".To check if a checkbox was ticked, you either check if the value of $headof is "on" ($headof=="on"), or check if "$_POST['headof']" is set (isset($_POST['headof'])).The second option is the better one.Orio. Link to comment https://forums.phpfreaks.com/topic/25154-if-else-statement-help/#findComment-114674 Share on other sites More sharing options...
tawevolution Posted October 26, 2006 Author Share Posted October 26, 2006 [quote author=Orio link=topic=112772.msg457866#msg457866 date=1161860010]or check if "$_POST['headof']" is set (isset($_POST['headof'])).[/quote]erm, how / where do i put that in the code? Link to comment https://forums.phpfreaks.com/topic/25154-if-else-statement-help/#findComment-114677 Share on other sites More sharing options...
Orio Posted October 26, 2006 Share Posted October 26, 2006 Instead of:[code]if($headof=1){$title=="Head of ";}else{$title=="none";}[/code]You should put:[code]if(isset($_POST['headof'])){$title=="Head of ";}else{$title=="none";}[/code]Orio :) Link to comment https://forums.phpfreaks.com/topic/25154-if-else-statement-help/#findComment-114685 Share on other sites More sharing options...
tawevolution Posted October 26, 2006 Author Share Posted October 26, 2006 ok thanks guysevo Link to comment https://forums.phpfreaks.com/topic/25154-if-else-statement-help/#findComment-114688 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.