3
Contributors
7
Replies
12
Views
4 Years
Discussion Span
Last Post by ehpratah
0
<?php
if (isset ($_POST['contact_name']) && isset ($_POST['contact_email']) && isset ($_POST['contact_text'])){

@$contact_name = $_POST['contact_name'];
@$contact_email = $_POST['contact_email'];
@$contact_text = $_POST['contact_text'];

if (!empty($contact_name) && !empty ($contact_email) && !empty ($contact_text)){
echo ("OK.");

} else{
echo "All fields are required.";

}

}

?>
<form action="index.php" method="post">
Name:<br><input type="text" name="contact_email"><br><br>
Email adress:<br><input type="text" name="contact_email"><br><br>
Message:<br>
<textarea name="contact_text" rows="6" cols="30"></textarea><br><br>
<input type="submit" value="Send">
</form>
0

Hi,

When you say your form doesn't work, what is it 'not' doing that you expect it to?

0

so in all the 3 fields i wrote a letter and when i click the cend button it must show: OK
but id doesnt show nothing

-1

hey i think this part of the code is wrong

<form action="index.php" method="post">

you must replace it with

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

0

hi you can also look at this code that i came up using your code with slight modification on it

<?php
if(isset($_POST['submit']))
{

$contact_name = $_POST['contact_name'];
$contact_email = $_POST['contact_email'];
$contact_text = $_POST['contact_text'];

if (!empty($contact_name) && !empty ($contact_email) && !empty ($contact_text)){
echo ("OK.");

} else{
echo "All fields are required.";

}

}

?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Name:<br><input type="text" name="contact_name"><br><br>
Email adress:<br><input type="text" name="contact_email"><br><br>
Message:<br>
<textarea name="contact_text" rows="6" cols="30"></textarea><br><br>
<input type="submit" value="Send">
</form>

not been tested if it really work but you can always find it out:D

Edited by ehpratah

1

hi nevermind my first post i think this is what your looking for

<?php



$contact_name = $_POST['contact_name'];
$contact_email = $_POST['contact_email'];
$contact_text = $_POST['contact_text'];



if (!empty($contact_name) && !empty ($contact_email) && !empty ($contact_text))
    {
echo "ok";
} else{
echo "All fields are required.";
}

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

Name:<br><input type="text" name="contact_name"><br><br>
Email adress:<br><input type="text" name="contact_email"><br><br>
Message:<br>
<textarea name="contact_text" rows="6" cols="30"></textarea><br><br>
<input type="submit" value="send">
</form>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.