PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?
$xname = "$name";
$xmsg = "$msg";
$xemail = "$email";
$xurl = "$url";
$glog = "guestlog.php";
$fp = fopen ($glog, "a");
$split = " - ";
if (!$xname || !$xmsg) {
echo("one or more required fields were left blank.");
fputs ($fp,"<a href="mailto:$xemail">$xname</a>$split<a href="$xurl">www</a>$split$xmsg<br><br>");
exit;
}
if ($xname || $xmsg) {
echo("thank you, <b>$xname</b>, for your comment.<br><br>");
include("guestlog.php");
exit;
}
?>
this is my script... as u can tell i am a beginner. the problem i am having is that when someone submits a comment with no name or message the fputs () statement still writes onto the file and all that shows up is - www - for the website link. does any1 know how i can end the fputs () statement if no name nor message has been provided in the fields? if u need more knowlege of my problem my aim sn is 'discipline card'. thanks.
http://www.devnetwork.net/forums/viewtopic.php?t=511
would be something to look at which would make your script something like the code below (haven't tested it, it's quite late here) - provided you use POST in your form. If you use GET change $_POST to $_GET.