troubleshooting Question

Php textbox empty function!

Avatar of Toube
Toube asked on
PHP
3 Comments1 Solution327 ViewsLast Modified:
Hi!

I have this page :

http://www.toubes-page.net/td/yhteystiedot/index.php?id=content&page=palaute

And what I'm trying to achieve there is that if the user doesn't fill the two text boxes and hit submit the forms borders should become red.

I got it working, but now it already shows the red borders when you arrive to the page.. when browsing to the they should look normal.

Any ideas that I could try?

Heres the page code:

<span style="font-weight: bold;">Anna palautetta:</span><br/><br/>


<?php

if(isset($_POST['submit']))
{
       $name = ($_POST['name']);
       $email = ($_POST['email']);
       $otsikko = ($_POST['otsikko']);
       $message = ($_POST['message']);


if(!$_POST['name'])
{
      "";
}


else if(!$_POST['email'])
{

      "";
}


else
{
$to="johndoe@com";

$message="$name antoi palautetta sivuiltasi.\n \nOtsikko: $otsikko\n \nViesti:\n$message\n\nsähköpostiosoite: $email";

if(mail($to,"Toubes Design palautetta",$message,"From: $email\n")) {

echo "<div style=\"font-weight: bold; color: #691717;\">Kiitos palautteestasi!</div><br/>";

} else {

echo "Syntyi virhe lähetyksessä, yritä uudelleen.";

}

}
}

?>

<br/>
<div id="form">

<form action="<?php echo $HTTP_POST_VARS['PHP_SELF']; ?>" method="post">
<table>
<tr>

<td class="td1">*Nimi:</td><td>
<?php
if(($name) != null)
{
      echo ('<input type="text" name="name" value="'.$name.'" />');

}

      else
      {
            echo ('<input type="text" class="error" name="name" value="'.$name.'" />');
      }
?>

</td>
</tr>
<tr>
<td class="td1">*Sähköposti:</td><td>
<?php
if ($_POST['email'])
{
      echo ('<input type="text" class="error" name="email" value="'.$email.'" />');
}

      else if(($email) != null)
      {
            echo ('<input type="text" name="email" value="'.$email.'" />');
      }
      else
      {
            echo ('<input type="text"  name="email" value="'.$email.'" />');
      }

?>

</td>
</tr>
<tr>
<td class="td1">Otsikko</td><td>
<?php echo('<input type="text" name="otsikko" value="'.$otsikko.'" /></td>'); ?>
</tr>

<tr>
<td class="td1" valign="top">Viesti:</td><td><textarea name="message" cols="40" rows="5">

</textarea></td>
</tr>
<tr>
<td id="td1"></td><td><input id="redforms" type="submit" name="submit" value="Lähetä!" />
</td></tr></table>
</form>

<br class="clear" />
</div>

ASKER CERTIFIED SOLUTION
TeRReF

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros