Jump to content

Recommended Posts

I suspect the problem is having

if(!empty(.....

insead of

if(empty(.....

 

! denotes not so "if (!empty" reads "if not empty", but that would mean that the error shows if the field is filled in rather than blank.

 

Still no luck (New code)

 

$errormsg = 'You left a field blank! Go back and fill it in.';
if(empty($_POST['fname']))
{
echo $errormsg;
}

I can't see anything wrong with that code at all. Try doing this...

$errormsg = 'You left a field blank! Go back and fill it in.';
echo "<h2>fname: ".$_POST['fname']."</h2>";
if(empty($_POST['fname']))
{
   echo $errormsg;
}

 

If the data you put into the fname field does not come up in a big F off h2 heading, then your problem is with your post.

 

Ooops, forgot to say that you have to put something into the fname field to test it.

 

I can't see anything wrong with that code at all. Try doing this...

$errormsg = 'You left a field blank! Go back and fill it in.';
echo "<h2>fname: ".$_POST['fname']."</h2>";
if(empty($_POST['fname']))
{
   echo $errormsg;
}

 

If the data you put into the fname field does not come up in a big F off h2 heading, then your problem is with your post.

 

Ooops, forgot to say that you have to put something into the fname field to test it.

 

I know my fname works because it sends a email what the fname was.

ok, lets see the form code and all the code on the receiving page up to and including the bit we have been looking at.  I'm off out to walk the dog for 5 mins and then I'll look at it.

 

ok This is the code:

<form action="unbanp.php" method="post">
  <p>Ingame Name </p>
  <p>
  <input type="text" name="fname" />
  </p>
  <p>-------------------------------------------</p>
  <p>Admin/Moderator That Banned you:</p>
  <p>
  <input type="text" name="aban" />
  </p>
  <p>-----------------------------------------</p>
  <p>IP Address:</p>
  <p>
  <input type="text" name="ip" />
    </p>
  <p>(http://www.whatsmyip.org)</p>
  <p>------------------------------------------------</p>
  <p>Reason Given why you were banned</p>
  <p>:
  <textarea name="aban2" cols="50" rows="6"></textarea>
  </p>
  <p>------------------------------------------------------</p>
  <p>Your Story</p>
  <textarea name="aban3" cols="50" rows="6"></textarea>
  <p>------------------------------------------------------------</p>
  <p>Additional Details?</p>
  <p><textarea name="aban4" cols="50" rows="6"></textarea></p>
  <p>----------------------------------------------------------
  <p>Email Address (So we can contact if you are unbanned)</p>
  <p>
    <input name="email" type="text" value="" size="50" maxlength="1" />
  </p>
    <input type="submit" />
  </p>
</form>

Need the code on unbanp.php too.  Up to the bit we were looking at.

 

.....
(design and shit up there)
.....
===============================================================================================================</
<?php

$errormsg = 'You left a field blank! Go back and fill it in.';
$fname=$_POST['fname'];
if($fname=="")
{
  echo $errormsg;
}//end if
else
{
   echo "String_post contained: ".$fname;
}
$ip=$_SERVER['REMOTE_ADDR'];
$to = '[email protected]';
$subject = "Unban Request - " . $_POST['fname'];
$from = '[email protected]';
$message = "Admin/Moderator That Banned - " . $_POST['aban'] . 
"\n\nIP Address - " . $_POST['ip'] . " | Tracked IP -" . $_SERVER['REMOTE_ADDR'] . 
"\n\nReason Given why player was banned - " . $_POST['aban2'] .
"\n\nYour Story - " . $_POST['aban3'] . 
"\n\nAdditional Details - " . $_POST['aban4'] . 
"\n\nEmail Address - " . $_POST['email'];

if(mail($to, $subject, $message, "From: $from"))
  echo "Unban Request Sent.";
else
  echo "Unban Request couldnt be Sent."; ?> 
<p>
Thank You For Submitting Your Unban Request!
<p>
</html>

It works for me! 

Try running unbanp.php through this syntax checker. http://www.meandeviation.com/tutorials/learnphp/php-syntax-check/

 

No errors were found, but note this is just a syntax check - there may be other errors or problems that will only appear when you upload and run the PHP script.

 

Also note that this file was checked against PHP 4. There are slight syntax differences between versions.

 

If you are a beginner try the PHP tutorial on this site

 

What exact output ARE you getting in your browser? Are you getting any of the output from this code at the end of the page -

if(mail($to, $subject, $message, "From: $from"))
  echo "Unban Request Sent.";
else
  echo "Unban Request couldnt be Sent."; ?>
<p>
Thank You For Submitting Your Unban Request!
<p>
</html>

 

And what does a "view source" of the page in your browser show?

What exact output ARE you getting in your browser? Are you getting any of the output from this code at the end of the page -

if(mail($to, $subject, $message, "From: $from"))
  echo "Unban Request Sent.";
else
  echo "Unban Request couldnt be Sent."; ?>
<p>
Thank You For Submitting Your Unban Request!
<p>
</html>

 

And what does a "view source" of the page in your browser show?

 

I'm not trying to show that.

It's supposed to be:

"You left your Name Empty." Then thats it. It wont send the email

I asked you three specific questions about what you are getting as output. We are not standing right next to you. If you aren't, can't, or won't communicate what you are doing and what results you are getting when you do it, no one can help you.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.