I've created a private messaging system but I have an annoying problem with $_GET.
First of all here's the full code for the "sendmail.php" page which is used for the form to send the mail
<?php
include("header.php");
include("connect.php");
$mailid = $_GET['username'];
$replyname = $_GET['user'];
?>
<form action="send.php" method="post" name="sendpm">
<table>
<tr>
<td>
<font color='orange'>To</font>
</td>
<?php IF ($mailid != ''){ ?>
<td>
<input type="text" name="touser" id="touser" value="<?php echo $mailid;?>"/>
</td>
<?php }elseif($replyname != ''){ ?>
<td>
<input type="text" name="touser" id="touser" value="<?php echo $replyname;?>"/>
</td>
<?php }else{ ?>
<td>
<input type="text" name="touser" id="touser" value="<?php echo $replyname;?>"/>
</td>
<?php } ?>
</tr>
<tr>
<td>
<font color='orange'>Subject</font>
</td>
<td>
<input type="text" name="subject" id="subject" />
</td>
</tr>
<tr>
<td>
<font color='orange'>Message</font>
</td>
<td>
<textarea name="message" cols="60" rows="10" id="message"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Send PM" />
</td>
</tr>
</table>
</form>
<?php
include("footer.php");
?>
Okay so as you can see here
$mailid = $_GET['username'];
$replyname = $_GET['user'];
I can get two different results depending on where it comes from. The "mailid" is if you've been directed from a profile. The "replyname" is if you've clicked "reply" to a message you've received.
Now, if I try to send a mail from scratch, I will be told that "username" and "user" are undefined (as I haven't come from the links that include them). If I come from one link then the other will be undefined and vice versa.
I can 'solve' this by adding isset
but for some reason, that keeps displaying a "1" instead of the username that should be shown (and IS shown if I follow a link without isset).
This is very annoying and I've been trying to solve it for ages!
I just realised isset deals in true or false. So the "1" means it's true, so I've changed it to
IF(isset($_GET['username'])){
$mailid = $_GET['username'];
}
IF(isset($_GET['user'])){
$replyname = $_GET['user'];
}
I thought this would be fine but still shows 1?