Jump to content

if + else statement help


tawevolution

Recommended Posts

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>&nbsp;</td>
      <td>&nbsp;</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>&nbsp;</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 form
echo("$lang, $real, $tag, $dept, $title");
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/25154-if-else-statement-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.